"""
Run with:
  python manage.py shell < announcements/seed.py
"""
from django.contrib.auth import get_user_model
from announcements.models import Announcement

User = get_user_model()

# Get or create admin user
admin = User.objects.filter(is_superuser=True).first()
if not admin:
    print("No superuser found. Create one first with createsuperuser.")
    exit()

print(f"Seeding as: {admin.username}")

# Clear existing
Announcement.objects.all().delete()
print("Cleared existing announcements.")

announcements = [
    # ── TAARIFA ──
    {
        "title": "Water Interruption — Makongeni & Section 9",
        "body": (
            "Thika Water & Sewerage Company announces a planned water interruption "
            "in Makongeni and Section 9 estates on Friday 30th May from 8AM to 5PM "
            "due to maintenance works on the main pipeline. Residents are advised to "
            "store adequate water. Normal supply will resume by 6PM."
        ),
        "category": "taarifa",
        "neighborhood": "makongeni",
        "priority": "urgent",
        "is_broadcast": False,
    },
    {
        "title": "Road Closure — Landless Junction",
        "body": (
            "The road at Landless junction near the matatu stage will be closed from "
            "Monday to Wednesday for tarmacking works. Motorists and pedestrians are "
            "advised to use alternative routes via Kiandutu road. Inconvenience is regretted."
        ),
        "category": "taarifa",
        "neighborhood": "landless",
        "priority": "high",
        "is_broadcast": False,
    },
    {
        "title": "Power Outage — Township & Ngoigwa",
        "body": (
            "Kenya Power announces a planned outage on Saturday 1st June from 9AM to 3PM "
            "affecting Township, Ngoigwa and parts of Thika town centre. This is to facilitate "
            "upgrade of transformer equipment. Emergency contacts: 0703-070-707."
        ),
        "category": "taarifa",
        "neighborhood": "township",
        "priority": "high",
        "is_broadcast": False,
    },
    {
        "title": "Security Alert — Kiandutu Area",
        "body": (
            "Residents of Kiandutu are advised to be vigilant following reports of "
            "theft incidents in the estate between 10PM and 2AM. "
            "Please report suspicious activities to Thika Police Station: 0722-111-222. "
            "Community policing meetings every Tuesday at the chief's office."
        ),
        "category": "taarifa",
        "neighborhood": "kiandutu",
        "priority": "urgent",
        "is_broadcast": False,
    },

    # ── SHUGHULI ──
    {
        "title": "Thika Stadium — Gor Mahia vs AFC Leopards",
        "body": (
            "The highly anticipated Mashemeji Derby comes to Thika! "
            "Gor Mahia FC takes on AFC Leopards at Thika Municipal Stadium "
            "on Sunday 2nd June 2026, kickoff 3PM. "
            "Tickets: KES 200 (terraces), KES 500 (covered stand). "
            "Available at the stadium gate from 1PM."
        ),
        "category": "shughuli",
        "neighborhood": "all",
        "priority": "high",
        "is_broadcast": False,
    },
    {
        "title": "Thika Day Celebrations 2026",
        "body": (
            "Join us for the annual Thika Day celebrations at Blue Post Hotel grounds. "
            "Cultural performances, food festival, trade fair and live music. "
            "Saturday 7th June from 10AM. Free entry for children under 12. "
            "Organized by Thika Sub-County Administration."
        ),
        "category": "shughuli",
        "neighborhood": "all",
        "priority": "normal",
        "is_broadcast": False,
    },
    {
        "title": "Baraza — Kamenu Ward Development Meeting",
        "body": (
            "Residents of Kamenu Ward are invited to a public baraza on Saturday 31st May "
            "at Kamenu Primary School grounds, starting 10AM. "
            "Agenda: Bursary applications, road projects update, water project progress. "
            "MCA Hon. Peter Mwangi will be present. All residents welcome."
        ),
        "category": "shughuli",
        "neighborhood": "kamenu",
        "priority": "normal",
        "is_broadcast": False,
    },

    # ── KAZI ──
    {
        "title": "Plumber Needed — Thika Greens Resident",
        "body": (
            "Looking for an experienced plumber for a 2-day job in Thika Greens estate. "
            "Work involves fixing leaking pipes and installing new bathroom fixtures. "
            "Must have own tools. Pay: KES 1,500 per day. "
            "Contact via ThikaConnect inbox or call 0712-345-678. Start date: 3rd June."
        ),
        "category": "kazi",
        "neighborhood": "thika_greens",
        "priority": "normal",
        "is_broadcast": False,
    },
    {
        "title": "Receptionist Wanted — Thika Town Clinic",
        "body": (
            "A busy medical clinic in Thika town is hiring a receptionist. "
            "Requirements: Diploma in Business Administration or equivalent, "
            "computer literate, good communication skills, aged 20-30. "
            "Salary: KES 18,000-22,000. Send CV to thikaclinic2026@gmail.com "
            "or drop at the clinic opposite Equity Bank. Deadline: 5th June."
        ),
        "category": "kazi",
        "neighborhood": "all",
        "priority": "normal",
        "is_broadcast": False,
    },
    {
        "title": "Bodaboda Riders Needed — Delivery Company",
        "body": (
            "FastDeliver Kenya is recruiting 10 bodaboda riders in Thika. "
            "Requirements: Valid driving licence (class A), own motorcycle, "
            "smartphone, honest and hardworking. "
            "Earnings: KES 800-1,500 per day depending on deliveries. "
            "WhatsApp your name and licence number to 0798-765-432."
        ),
        "category": "kazi",
        "neighborhood": "all",
        "priority": "high",
        "is_broadcast": False,
    },
    {
        "title": "Security Guards — Gatuanyaga Factory",
        "body": (
            "A manufacturing company in Gatuanyaga industrial area is hiring "
            "10 security guards for day and night shifts. "
            "Requirements: Certificate of Good Conduct, height 5'6\" and above, "
            "aged 25-40. Salary: KES 15,000 + allowances. "
            "Report in person to the factory gate with your documents. Monday-Friday 8AM-4PM."
        ),
        "category": "kazi",
        "neighborhood": "gatuanyaga",
        "priority": "normal",
        "is_broadcast": False,
    },

    # ── BIASHARA ──
    {
        "title": "Mama Pima Groceries — Fresh Produce Daily",
        "body": (
            "Get the freshest vegetables, fruits and groceries delivered to your door "
            "anywhere in Thika! We source directly from Thika farms. "
            "Order before 8AM, delivered by noon. "
            "Tomatoes KES 80/kg, Sukuma KES 30/bunch, Avocados KES 20 each. "
            "Order on ThikaConnect inbox or WhatsApp 0701-234-567."
        ),
        "category": "biashara",
        "neighborhood": "all",
        "priority": "normal",
        "is_broadcast": False,
    },
    {
        "title": "Affordable Plots — Gatuanyaga 50x100",
        "body": (
            "Own a piece of Thika! Affordable residential plots in Gatuanyaga area. "
            "Size: 50x100 ft. Price: KES 450,000 (negotiable). "
            "Title deed ready. Water and electricity nearby. "
            "10% deposit secures your plot. Call/WhatsApp 0722-987-654. "
            "Viewing every weekend 9AM-5PM."
        ),
        "category": "biashara",
        "neighborhood": "gatuanyaga",
        "priority": "normal",
        "is_broadcast": False,
    },
    {
        "title": "Thika Hardware — Building Materials Sale",
        "body": (
            "SALE! Up to 30% off on all building materials this month at Thika Hardware. "
            "Located along Thika-Garissa road, 200m from Total petrol station. "
            "Iron sheets, cement, steel bars, roofing materials, paints and more. "
            "Free delivery within Thika for orders above KES 10,000. "
            "Open Mon-Sat 7AM-7PM, Sun 8AM-2PM. Tel: 067-21234."
        ),
        "category": "biashara",
        "neighborhood": "all",
        "priority": "high",
        "is_broadcast": False,
    },

    # ── MATATU ──
    {
        "title": "Route 237 Suspension — Thika-Nairobi",
        "body": (
            "Matatu operators on Route 237 (Thika-Nairobi via Thika Road) announce "
            "partial suspension of services on Saturday morning due to operator strike. "
            "Alternative: Use Route 45 via Ruiru or Route 38 via Eastern bypass. "
            "Services expected to resume by 2PM. We apologise for the inconvenience."
        ),
        "category": "matatu",
        "neighborhood": "all",
        "priority": "urgent",
        "is_broadcast": False,
    },
    {
        "title": "New Matatu Stage — Makongeni Estate",
        "body": (
            "A new official matatu stage has been gazetted at Makongeni shopping centre "
            "for routes serving Kiandutu, Ngoigwa and Thika town. "
            "Effective from 1st June 2026. Touts and operators must comply. "
            "The old stage at the junction will be decommissioned. "
            "Issued by: Thika Sub-County Transport Office."
        ),
        "category": "matatu",
        "neighborhood": "makongeni",
        "priority": "normal",
        "is_broadcast": False,
    },

    # ── HARAMBEE ──
    {
        "title": "Harambee — Baby Wanjiku Medical Fund",
        "body": (
            "We are raising funds for baby Wanjiku (8 months) who needs urgent heart surgery "
            "at Kenyatta National Hospital. Total needed: KES 350,000. Raised so far: KES 120,000. "
            "Please contribute via M-Pesa Paybill: 123456, Account: WANJIKU. "
            "Every shilling counts. May God bless your generous heart. "
            "Contact: Mama Wanjiku — 0711-222-333."
        ),
        "category": "harambee",
        "neighborhood": "all",
        "priority": "urgent",
        "is_broadcast": False,
    },
    {
        "title": "School Fees Harambee — Ngoigwa Family",
        "body": (
            "The Mwangi family of Ngoigwa seeks your support to raise KES 45,000 "
            "for their three children's school fees for Form 1, Form 3 and Class 8. "
            "The father recently lost his job. "
            "Contribute via M-Pesa: 0722-444-555 (Peter Mwangi). "
            "Thank you for your kindness — ThikaConnect Community."
        ),
        "category": "harambee",
        "neighborhood": "ngoigwa",
        "priority": "high",
        "is_broadcast": False,
    },
]

created = 0
for data in announcements:
    Announcement.objects.create(created_by=admin, **data)
    created += 1
    print(f"  ✓ [{data['category'].upper()}] {data['title'][:50]}")

print(f"\n✅ Seeded {created} announcements successfully!")
print(f"   Visit http://localhost:8000/admin/announcements/announcement/ to view them.")