import os
import django
from datetime import date, time

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'conf_system.settings')
django.setup()

from cms.models import HeroSection, AboutSection, ConferenceTheme, ScheduleSession, CommitteeMember, Award, Sponsor

def seed():
    HeroSection.objects.get_or_create(id=1)
    AboutSection.objects.get_or_create(id=1)
    
    hero = HeroSection.objects.get(id=1)
    hero.title = "XXXVI Annual Conference & International Symposium"
    hero.subtitle = "Global Perspectives in Angiosperm Systematics, Traditional Knowledge & Biodiversity Conservation. A curated program bridging classical taxonomy with modern ecological challenges, hosted at a NAAC A++, Category-I Central University."
    hero.date_text = "November 20–22, 2026"
    hero.location_text = "Guru Ghasidas Vishwavidyalaya, Bilaspur"
    hero.save()
    
    about = AboutSection.objects.get(id=1)
    about.heading = "About the Conference"
    about.subheading = "Rooted in Taxonomic Excellence"
    about.description = "The Indian Association for Angiosperm Taxonomy (IAAT) was established in 1990 with the objective of promoting research and academic exchange in the field of plant taxonomy and allied disciplines. The XXXVI Annual Conference serves as the premier convergence point for global botanists, researchers, and ecological stewards."
    about.established_year = "1990"
    about.headquarters = "University of Calicut, Kerala"
    about.edition = "XXXVI"
    about.dates = "Nov 20–22, 2026"
    about.save()
    
    themes = [
        ("Advances in Angiosperm Systematics", "forest", "Modern trends in angiosperm classification\nIntegrative approaches in plant taxonomy\nClassical and contemporary taxonomic methodologies\nSpecies delimitation and revisionary studies"),
        ("Molecular Phylogenetics, DNA Barcoding and Evolution", "biotech", "Genomic and phylogenetic insights in angiosperms\nDNA barcoding and molecular identification\nEvolutionary relationships among plant groups\nBioinformatics tools in systematics"),
        ("Floristic Diversity and Biogeography", "travel_explore", "Floristic surveys and vegetation analysis\nEndemism and species distribution patterns\nPhytogeography of Indian floristic regions\nBiodiversity documentation and inventory studies"),
        ("Ethnobotany, Traditional Knowledge and Economic Botany", "psychiatry", "Indigenous knowledge systems and plant use\nMedicinal and economically important plants\nTraditional healthcare practices\nCommunity-based biodiversity conservation"),
        ("Reproductive Ecology and Plant–Animal Interactions", "hub", "Pollination biology and floral ecology\nExtrafloral nectaries and mutualistic interactions\nSeed dispersal ecology\nNectar robbing, herbivory, and defense mechanisms"),
        ("Biodiversity Conservation and Climate Change", "eco", "Conservation strategies and restoration ecology\nThreats to plant diversity\nClimate change and plant adaptation\nClimate-resilient plant diversity"),
        ("Digital Taxonomy and AI Applications", "database", "Artificial intelligence in species identification\nDigital herbaria and virtual collections\nImage analysis and automated taxonomy\nDatabases and biodiversity informatics"),
        ("Emerging Interdisciplinary Frontiers", "science", "Multi-omics in plant biology\nCitizen science initiatives\nConservation technologies\nPolicy and future perspectives")
    ]
    
    ConferenceTheme.objects.all().delete()
    for i, (title, icon, subs) in enumerate(themes):
        ConferenceTheme.objects.create(title=title, icon_name=icon, description="", subtopics=subs, order=i)
        
    CommitteeMember.objects.all().delete()
    office_bearers = [
        ("Prof. D. Narasimhan", "President", "Chennai"),
        ("Prof. A.K. Pandey", "Vice-President (O.S.)", ""),
        ("Prof. Santhosh Nampy", "Secretary (H.Q.)", "Kozhikode"),
        ("Prof. Milind Sardesai", "Secretary (O.S.)", ""),
        ("Prof. Debabrata Maity", "Treasurer", "Kolkata"),
    ]
    for i, (name, desig, inst) in enumerate(office_bearers):
        CommitteeMember.objects.create(category='OFFICE', name=name, designation=desig, institution=inst, order=i)
        
    advisors = [
        ("Dr. John McNeill", "Royal Botanic Garden", "Edinburgh, UK"),
        ("Prof. Tod F. Stuessy", "Ohio State University", "USA"),
        ("Prof. Susanne S. Renner", "Washington University", "USA"),
        ("Dr. Kanchi N. Gandhi", "Harvard University", "USA"),
        ("Dr. Norbert Kilian", "Botanic Garden Berlin", "Germany"),
    ]
    for i, (name, desig, inst) in enumerate(advisors):
        CommitteeMember.objects.create(category='INTERNATIONAL', name=name, designation=desig, institution=inst, order=i)
        
    Award.objects.all().delete()
    Award.objects.create(
        title="Prof. A.K. Pandey Award for Revisionary Studies",
        description="Established in 2023 through the generous endowment of Prof. Arun K. Pandey, this award recognizes outstanding revisionary studies in angiosperm taxonomy.",
        eligibility="Maximum age: 65 years\nMust be a Life Member of IAAT\nApplicant should hold a Ph.D. related to Angiosperm Taxonomy",
        order=1
    )
    Award.objects.create(
        title="Prof. Santhosh Nampy IAAT Young Scientist Award",
        description="Instituted in 2023 through the generous donation of Prof. Santhosh Nampy, this award recognizes outstanding contributions by young scientists in angiosperm systematics and taxonomy.",
        eligibility="Maximum age: 35 years\nMust be a Life Member of IAAT\nApplicant should hold a Ph.D. in Angiosperm Taxonomy",
        order=2
    )
    Award.objects.create(
        title="Dr. A.K. Pradeep Young Researcher Award",
        description="Instituted in 2023 through contributions from the students of Dr. A.K. Pradeep, this award recognizes the best research paper presented by a young researcher.",
        eligibility="Maximum age: 28 years\nLife/Annual member of IAAT\nOnly original research papers considered\nPh.D. holders are not eligible",
        order=3
    )
    Award.objects.create(
        title="S.M. & M.R. Almeida Award in Plant Nomenclature",
        description="Instituted in 2023 through the generous donation of Dr. Suchandra Dutta, this award recognizes excellence in plant nomenclature research.",
        eligibility="Maximum age: 32 years\nLife/Annual member of IAAT\nOriginal nomenclatural studies only\nPh.D. holders are not eligible",
        order=4
    )

    ScheduleSession.objects.all().delete()
    ScheduleSession.objects.create(day_number=1, date=date(2026, 11, 20), start_time=time(9, 0), end_time=time(10, 30), title="Inauguration & Lamp Lighting", description="Welcome address, release of souvenir, and presidential remarks.", venue="Main Auditorium", speaker_name="Hon'ble Vice-Chancellor")
    ScheduleSession.objects.create(day_number=1, date=date(2026, 11, 20), start_time=time(10, 30), end_time=time(12, 0), title="Advances in Angiosperm Systematics", description="Opening keynote on modern trends in angiosperm classification.", venue="Plenary Hall", speaker_name="Prof. D. Narasimhan")
    ScheduleSession.objects.create(day_number=1, date=date(2026, 11, 20), start_time=time(12, 0), end_time=time(13, 30), title="Molecular Phylogenetics & DNA Barcoding", description="Genomic and phylogenetic insights in angiosperms.", venue="Hall A", speaker_name="Dr. John McNeill")
    ScheduleSession.objects.create(day_number=1, date=date(2026, 11, 20), start_time=time(14, 30), end_time=time(16, 0), title="Young Researcher Award Sessions", description="Oral presentations for IAAT young researcher awards.", venue="Hall B", speaker_name="")

    Sponsor.objects.all().delete()
    Sponsor.objects.create(name="Botanical Survey of India", category="Partner", order=1)
    Sponsor.objects.create(name="International Association for Plant Taxonomy", category="Partner", order=2)
    Sponsor.objects.create(name="Guru Ghasidas Vishwavidyalaya", category="Host", order=3)
    Sponsor.objects.create(name="Indian Association for Angiosperm Taxonomy", category="Organizer", order=4)

    print("CMS Seeded successfully!")

if __name__ == '__main__':
    seed()
