from django.core.management.base import BaseCommand
from django.db import transaction
from base.models import Category, Tag, Guideline
from blog.models import Blog, BlogImage
from service.models import Service
from project.models import Event, EventImage


class Command(BaseCommand):
    help = "Seed comprehensive education platform data including guidelines, pages, blogs, services, and events"

    def handle(self, *args, **options):
        self.stdout.write("Seeding comprehensive education platform data...")

        with transaction.atomic():
            # Create categories first
            categories = self.create_categories()

            # Create tags
            tags = self.create_tags()

            # Create guidelines
            self.create_guidelines()

            # Create blogs
            self.create_blogs(categories, tags)

            # Create services
            self.create_services(categories)

            # Create events
            self.create_events(categories, tags)

        self.stdout.write(
            self.style.SUCCESS("Successfully seeded all education platform data!")
        )

    def create_categories(self):
        """Create categories for blogs, services, and events"""
        categories_data = [
            # Education Categories
            {"name": "Study Abroad"},
            {"name": "University Admissions"},
            {"name": "Scholarships"},
            {"name": "Student Life"},
            {"name": "Career Guidance"},
            # Service Categories
            {"name": "Admission Consulting"},
            {"name": "Visa Assistance"},
            {"name": "Test Preparation"},
            {"name": "Career Counseling"},
            {"name": "Documentation"},
            # Event Categories
            {"name": "University Fairs"},
            {"name": "Webinars"},
            {"name": "Workshops"},
            {"name": "Seminars"},
            {"name": "Info Sessions"},
        ]

        categories = {}
        for data in categories_data:
            category, created = Category.objects.get_or_create(
                name=data["name"], defaults=data
            )
            categories[data["name"]] = category
            if created:
                self.stdout.write(f"Created category: {data['name']}")

        return categories

    def create_tags(self):
        """Create tags for blogs and events"""
        tags_data = [
            "Study Abroad",
            "UK Education",
            "USA Universities",
            "Canada Study",
            "Scholarships",
            "Student Visa",
            "IELTS",
            "TOEFL",
            "Career Advice",
            "University Application",
            "Personal Statement",
            "Student Life",
            "International Students",
            "Education",
            "Learning",
            "Study Tips",
            "Admission",
            "Funding",
            "Accommodation",
            "Culture Shock",
        ]

        tags = {}
        for tag_name in tags_data:
            tag, created = Tag.objects.get_or_create(name=tag_name)
            tags[tag_name] = tag
            if created:
                self.stdout.write(f"Created tag: {tag_name}")

        return tags

    def create_guidelines(self):
        """Create comprehensive study guidelines for different countries"""
        guidelines_data = [
            {
                "title": "Complete Guide to Studying in the United Kingdom",
                "slug": "study-in-uk",
                "country": "uk",
                "study_level": "all",
                "short_description": "Comprehensive guide for international students planning to study in the UK. Covers top universities, visa requirements, costs, and post-study opportunities.",
                "overview": "<p>The United Kingdom is one of the world's most popular destinations for international students, known for its prestigious universities, rich history, and diverse culture. With institutions like Oxford, Cambridge, and Imperial College London, the UK offers world-class education across all disciplines.</p>",
                "eligibility_criteria": "<h3>Academic Requirements</h3><ul><li>Completed secondary education with good grades</li><li>For undergraduate: A-levels or equivalent</li><li>For postgraduate: Bachelor's degree with minimum 2:1 or equivalent</li><li>Specific course prerequisites</li></ul>",
                "language_requirements": "<h3>English Language Requirements</h3><ul><li>IELTS: 6.0-7.5 overall</li><li>TOEFL iBT: 80-110</li><li>PTE Academic: 54-76</li><li>Cambridge English: 169-191</li></ul>",
                "financial_requirements": "<h3>Financial Requirements</h3><ul><li>Tuition fees: £10,000 - £38,000 per year</li><li>Living costs: £1,023 - £1,334 per month (outside London)</li><li>London living costs: £1,334 - £1,600 per month</li><li>Proof of funds required for visa</li></ul>",
                "application_process": "<h3>Application Steps</h3><ol><li>Research courses and universities (6-12 months before)</li><li>Check entry requirements</li><li>Prepare documents</li><li>Apply through UCAS (undergraduate) or directly (postgraduate)</li><li>Receive offers</li><li>Apply for student visa</li><li>Arrange accommodation</li></ol>",
                "deadline_information": "<h3>Key Deadlines</h3><ul><li>UCAS undergraduate: January 15th</li><li>Postgraduate: Varies by university (typically January-April)</li><li>Student visa: Can apply 3 months before course start</li></ul>",
                "visa_process": "<h3>Student Visa Process</h3><ul><li>Apply online with CAS from university</li><li>Pay healthcare surcharge (£470 per year)</li><li>Provide financial evidence</li><li>Biometric appointment</li><li>Decision within 3 weeks</li></ul>",
                "tuition_fees": "<h3>Tuition Fees 2024</h3><ul><li>Undergraduate: £10,000 - £26,000 per year</li><li>Postgraduate: £12,000 - £38,000 per year</li><li>Medical degrees: Up to £50,000 per year</li><li>MBA: £15,000 - £60,000</li></ul>",
                "living_costs": "<h3>Living Costs</h3><ul><li>Accommodation: £400 - £800 per month</li><li>Food: £150 - £250 per month</li><li>Transport: £50 - £100 per month</li><li>Utilities: £50 - £100 per month</li><li>Entertainment: £100 - £200 per month</li></ul>",
                "scholarship_info": "<h3>Available Scholarships</h3><ul><li>Chevening Scholarships</li><li>Commonwealth Scholarships</li><li>University-specific scholarships</li><li>GREAT Scholarships</li><li>Marshall Scholarships</li></ul>",
                "working_while_studying": "<p>International students can work up to 20 hours per week during term time and full-time during vacations. Minimum wage is £9.50-£10.42 per hour depending on age.</p>",
                "post_study_options": "<p>Graduate Route visa allows students to stay for 2 years (3 years for PhD) after graduation to work. Opportunities to switch to skilled worker visa.</p>",
                "useful_resources": "<ul><li>UK Government Student Visa Information</li><li>UCAS Application Portal</li><li>British Council Study UK</li><li>UKCISA International Student Advice</li></ul>",
                "is_featured": True,
                "status": "published",
                "order": 1,
            },
            {
                "title": "Study in USA: Complete International Student Guide",
                "slug": "study-in-usa",
                "country": "usa",
                "study_level": "all",
                "short_description": "Everything you need to know about studying in the United States - from application process to visa requirements and career opportunities.",
                "overview": "<p>The United States remains the top destination for international students worldwide, offering unparalleled diversity in education, research opportunities, and career prospects. With over 4,000 accredited institutions, students can find programs tailored to every interest and career goal.</p>",
                "eligibility_criteria": "<h3>Academic Requirements</h3><ul><li>High school diploma or equivalent</li><li>Minimum GPA requirements (varies by university)</li><li>Standardized test scores (SAT/ACT for undergraduate, GRE/GMAT for graduate)</li><li>English proficiency test scores</li></ul>",
                "language_requirements": "<h3>English Language Requirements</h3><ul><li>TOEFL iBT: 80-100</li><li>IELTS: 6.5-7.5</li><li>Duolingo English Test: 105-120</li><li>PTE Academic: 53-73</li></ul>",
                "financial_requirements": "<h3>Financial Requirements</h3><ul><li>Undergraduate tuition: $20,000 - $50,000 per year</li><li>Graduate tuition: $25,000 - $55,000 per year</li><li>Living expenses: $10,000 - $15,000 per year</li><li>Proof of funds required for I-20</li></ul>",
                "application_process": "<h3>Application Timeline</h3><ol><li>Research universities (12-18 months before)</li><li>Prepare for standardized tests</li><li>Request recommendations</li><li>Write personal statement</li><li>Submit applications</li><li>Apply for student visa</li><li>Prepare for departure</li></ol>",
                "deadline_information": "<h3>Application Deadlines</h3><ul><li>Early Decision/Early Action: November 1st</li><li>Regular Decision: January 1st - January 15th</li><li>Rolling Admissions: Varies</li><li>Graduate programs: December - February</li></ul>",
                "visa_process": "<h3>F-1 Student Visa Process</h3><ul><li>Receive I-20 from university</li><li>Pay SEVIS fee</li><li>Complete DS-160 form</li><li>Schedule visa interview</li><li>Prepare financial documents</li><li>Attend interview</li></ul>",
                "tuition_fees": "<h3>Tuition Costs 2024</h3><ul><li>Public universities (out-of-state): $25,000 - $35,000</li><li>Private universities: $35,000 - $55,000</li><li>Community colleges: $5,000 - $10,000</li><li>Graduate programs: $30,000 - $70,000</li></ul>",
                "living_costs": "<h3>Living Expenses</h3><ul><li>Accommodation: $800 - $1,500 per month</li><li>Food: $300 - $500 per month</li><li>Transportation: $100 - $300 per month</li><li>Health insurance: $500 - $1,200 per year</li><li>Personal expenses: $200 - $400 per month</li></ul>",
                "scholarship_info": "<h3>Scholarship Opportunities</h3><ul><li>University merit scholarships</li><li>Need-based financial aid</li><li>Private organization scholarships</li><li>Government-sponsored programs</li><li>Athletic scholarships</li></ul>",
                "working_while_studying": "<p>F-1 students can work on-campus up to 20 hours per week. Optional Practical Training (OPT) allows off-campus work during and after studies.</p>",
                "post_study_options": "<p>OPT provides 12 months of work authorization (24 months for STEM fields). H-1B visa sponsorship available for employment.</p>",
                "is_featured": True,
                "status": "published",
                "order": 2,
            },
            {
                "title": "Study in Canada: International Student Guide 2024",
                "slug": "study-in-canada",
                "country": "canada",
                "study_level": "all",
                "short_description": "Discover why Canada is a top choice for international students with its quality education, multicultural environment, and post-graduation opportunities.",
                "overview": "<p>Canada has emerged as one of the most popular study destinations due to its high-quality education, affordable tuition fees, and welcoming immigration policies. Canadian degrees are recognized worldwide, and the country offers excellent post-study work opportunities.</p>",
                "eligibility_criteria": "<h3>Admission Requirements</h3><ul><li>Secondary school completion</li><li>Minimum grades vary by program</li><li>English/French language proficiency</li><li>Program-specific prerequisites</li></ul>",
                "language_requirements": "<h3>Language Requirements</h3><ul><li>IELTS: 6.0-7.0 overall</li><li>TOEFL iBT: 80-100</li><li>PTE Academic: 58-65</li><li>French: TEF/TCF for French programs</li></ul>",
                "financial_requirements": "<h3>Financial Proof</h3><ul><li>Tuition: CAD 15,000 - 35,000 per year</li><li>Living expenses: CAD 10,000 - 15,000 per year</li><li>Proof of funds: CAD 10,000 + tuition for one year</li><li>Additional funds for family members</li></ul>",
                "application_process": "<h3>Application Steps</h3><ol><li>Choose program and institution</li><li>Check admission requirements</li><li>Prepare application documents</li><li>Submit application</li><li>Receive letter of acceptance</li><li>Apply for study permit</li></ol>",
                "deadline_information": "<h3>Application Deadlines</h3><ul><li>Fall intake: January - March</li><li>Winter intake: June - September</li><li>Spring/Summer intake: September - November</li><li>Varies by institution</li></ul>",
                "visa_process": "<h3>Study Permit Process</h3><ul><li>Get letter of acceptance</li><li>Apply online or paper application</li><li>Provide biometrics</li><li>Medical examination if required</li><li>Processing time: 2-16 weeks</li></ul>",
                "tuition_fees": "<h3>Tuition Fees</h3><ul><li>Undergraduate: CAD 15,000 - 30,000 per year</li><li>Graduate: CAD 17,000 - 35,000 per year</li><li>MBA: CAD 30,000 - 60,000</li><li>College diplomas: CAD 12,000 - 20,000</li></ul>",
                "living_costs": "<h3>Cost of Living</h3><ul><li>Accommodation: CAD 600 - 1,200 per month</li><li>Food: CAD 300 - 500 per month</li><li>Transport: CAD 80 - 120 per month</li><li>Utilities: CAD 150 - 200 per month</li></ul>",
                "scholarship_info": "<h3>Scholarships Available</h3><ul><li>Canadian Commonwealth Scholarship</li><li>Vanier Canada Graduate Scholarships</li><li>University-specific scholarships</li><li>Provincial government scholarships</li></ul>",
                "working_while_studying": "<p>International students can work up to 20 hours per week during academic sessions and full-time during scheduled breaks.</p>",
                "post_study_options": "<p>Post-Graduation Work Permit (PGWP) allows graduates to work for up to 3 years. Express Entry system provides pathway to permanent residency.</p>",
                "is_featured": True,
                "status": "published",
                "order": 3,
            },
        ]

        for guideline_data in guidelines_data:
            guideline, created = Guideline.objects.get_or_create(
                slug=guideline_data["slug"], defaults=guideline_data
            )
            if created:
                self.stdout.write(
                    self.style.SUCCESS(f"Created guideline: {guideline.title}")
                )

        # Create additional guidelines for other countries
        additional_countries = [
            ("australia", "Australia"),
            ("germany", "Germany"),
            ("france", "France"),
            ("netherlands", "Netherlands"),
            ("ireland", "Ireland"),
        ]

        for country_code, country_name in additional_countries:
            guideline, created = Guideline.objects.get_or_create(
                slug=f"study-in-{country_code}",
                defaults={
                    "title": f"Study in {country_name}: Complete Guide for International Students",
                    "country": country_code,
                    "study_level": "all",
                    "short_description": f"Comprehensive guide for studying in {country_name}, covering admission requirements, costs, visa process, and student life.",
                    "overview": f"<p>{country_name} offers excellent education opportunities for international students with world-class universities, diverse programs, and vibrant student life.</p>",
                    "status": "published",
                    "order": Guideline.objects.count() + 1,
                },
            )
            if created:
                self.stdout.write(
                    self.style.SUCCESS(f"Created guideline: {guideline.title}")
                )

    def create_blogs(self, categories, tags):
        """Create blog posts with educational content"""
        blogs_data = [
            {
                "category": categories["Study Abroad"],
                "title": "Top 10 Universities in the UK for International Students 2024",
                "slug": "top-10-universities-uk-2024",
                "subtitle": "Discover the best UK universities offering world-class education and excellent student support",
                "description": """
                    <h2>Why Choose UK Universities?</h2>
                    <p>The United Kingdom has long been a preferred destination for international students seeking quality education. With centuries-old institutions and modern universities, the UK offers diverse academic opportunities.</p>
                    
                    <h3>1. University of Oxford</h3>
                    <p>Consistently ranked among the top universities globally, Oxford offers exceptional academic programs and research opportunities.</p>
                    
                    <h3>2. University of Cambridge</h3>
                    <p>Known for its rigorous academic standards and beautiful campus, Cambridge provides an unparalleled learning experience.</p>
                    
                    <h3>3. Imperial College London</h3>
                    <p>Specializing in science, engineering, medicine, and business, Imperial is a world leader in research and innovation.</p>
                """,
                "keypoints": [
                    "World-class education system",
                    "Strong international student support",
                    "Excellent post-study work opportunities",
                    "Rich cultural experience",
                    "Globally recognized degrees",
                ],
                "featured_image": "blog/blog/featured_image/uk-universities.jpg",
                "tags": [
                    tags["UK Education"],
                    tags["Study Abroad"],
                    tags["University Application"],
                ],
                "views": 1250,
            },
            {
                "category": categories["Scholarships"],
                "title": "How to Secure Scholarships for International Studies",
                "slug": "secure-scholarships-international-studies",
                "subtitle": "Complete guide to finding and applying for scholarships to fund your education abroad",
                "description": """
                    <h2>Understanding Scholarship Opportunities</h2>
                    <p>Securing scholarships can significantly reduce the financial burden of studying abroad. This guide covers various types of scholarships and application strategies.</p>
                    
                    <h3>Types of Scholarships</h3>
                    <ul>
                        <li><strong>Merit-based scholarships:</strong> Awarded based on academic excellence</li>
                        <li><strong>Need-based scholarships:</strong> For students with financial constraints</li>
                        <li><strong>Country-specific scholarships:</strong> For students from particular regions</li>
                        <li><strong>Subject-specific scholarships:</strong> For specific fields of study</li>
                    </ul>
                    
                    <h3>Application Tips</h3>
                    <p>Start early, research thoroughly, and tailor each application to the specific scholarship requirements.</p>
                """,
                "keypoints": [
                    "Start applications 12-18 months in advance",
                    "Research university-specific scholarships",
                    "Prepare strong recommendation letters",
                    "Write compelling personal statements",
                    "Meet all deadlines",
                ],
                "featured_image": "blog/blog/featured_image/scholarships.jpg",
                "tags": [tags["Scholarships"], tags["Funding"], tags["Study Abroad"]],
                "views": 890,
            },
            {
                "category": categories["Student Life"],
                "title": "Adapting to Student Life in a New Country",
                "slug": "adapting-student-life-new-country",
                "subtitle": "Practical tips for international students to settle in and thrive abroad",
                "description": """
                    <h2>Making the Transition Smooth</h2>
                    <p>Moving to a new country for studies can be challenging. This guide helps you navigate cultural differences and build a support system.</p>
                    
                    <h3>Cultural Adaptation</h3>
                    <p>Understanding and respecting local customs, food, and social norms is crucial for a positive experience.</p>
                    
                    <h3>Building Community</h3>
                    <p>Join student clubs, participate in campus activities, and connect with both international and local students.</p>
                    
                    <h3>Academic Success</h3>
                    <p>Learn the education system, seek help when needed, and develop effective study habits.</p>
                """,
                "keypoints": [
                    "Research the local culture before arrival",
                    "Join student organizations and clubs",
                    "Attend orientation programs",
                    "Build a support network",
                    "Balance studies and social life",
                ],
                "featured_image": "blog/blog/featured_image/student-life.jpg",
                "tags": [
                    tags["Student Life"],
                    tags["International Students"],
                    tags["Culture Shock"],
                ],
                "views": 670,
            },
            {
                "category": categories["Career Guidance"],
                "title": "Career Opportunities After Studying Abroad",
                "slug": "career-opportunities-after-studying-abroad",
                "subtitle": "Leverage your international education for global career success",
                "description": """
                    <h2>Global Career Prospects</h2>
                    <p>An international degree opens doors to global career opportunities. Learn how to maximize your overseas education for career advancement.</p>
                    
                    <h3>Post-Study Work Visas</h3>
                    <p>Understand the work visa options available in different countries after graduation.</p>
                    
                    <h3>Networking Strategies</h3>
                    <p>Build professional connections during your studies that can lead to job opportunities.</p>
                    
                    <h3>Skill Development</h3>
                    <p>International education develops valuable skills like cross-cultural communication and adaptability.</p>
                """,
                "keypoints": [
                    "Research post-study work visa options",
                    "Network with professionals in your field",
                    "Gain international work experience",
                    "Develop cross-cultural competencies",
                    "Leverage university career services",
                ],
                "featured_image": "blog/blog/featured_image/career-opportunities.jpg",
                "tags": [
                    tags["Career Advice"],
                    tags["Study Abroad"],
                    tags["International Students"],
                ],
                "views": 540,
            },
        ]

        for blog_data in blogs_data:
            # Extract tags before creating blog
            blog_tags = blog_data.pop("tags", [])

            blog, created = Blog.objects.get_or_create(
                slug=blog_data["slug"], defaults=blog_data
            )

            if created:
                # Add tags to the blog
                blog.tags.set(blog_tags)
                self.stdout.write(f"Created blog: {blog.title}")

    def create_services(self, categories):
        """Create educational services"""
        services_data = [
            {
                "category": categories["Admission Consulting"],
                "title": "University Admission Consulting",
                "slug": "university-admission-consulting",
                "icon": "🎓",
                "subtitle": "Expert guidance for successful university applications",
                "description": """
                    <h2>Comprehensive Admission Support</h2>
                    <p>Our experienced consultants provide personalized guidance for university applications to top institutions worldwide.</p>
                    
                    <h3>Services Include:</h3>
                    <ul>
                        <li>University and program selection</li>
                        <li>Application strategy development</li>
                        <li>Document preparation and review</li>
                        <li>Personal statement guidance</li>
                        <li>Interview preparation</li>
                    </ul>
                    
                    <p>We help you showcase your strengths and create compelling applications that stand out.</p>
                """,
                "keypoints": [
                    "Personalized university selection",
                    "Expert application review",
                    "Interview preparation",
                    "Deadline management",
                    "Success rate: 95%",
                ],
                "featured_image": "project/project/featured_image/admission-consulting.jpg",
            },
            {
                "category": categories["Visa Assistance"],
                "title": "Student Visa Processing",
                "slug": "student-visa-processing",
                "icon": "📋",
                "subtitle": "Complete visa application support for international students",
                "description": """
                    <h2>Stress-Free Visa Processing</h2>
                    <p>Navigate the complex visa application process with our expert assistance and ensure timely approval.</p>
                    
                    <h3>Our Visa Services:</h3>
                    <ul>
                        <li>Document checklist and preparation</li>
                        <li>Application form filling assistance</li>
                        <li>Financial documentation guidance</li>
                        <li>Interview preparation</li>
                        <li>Follow-up and status tracking</li>
                    </ul>
                """,
                "keypoints": [
                    "Document preparation guidance",
                    "Application review",
                    "Interview coaching",
                    "Timely submission",
                    "High success rate",
                ],
                "featured_image": "project/project/featured_image/visa-assistance.jpg",
            },
            {
                "category": categories["Test Preparation"],
                "title": "IELTS & TOEFL Preparation",
                "slug": "ielts-toefl-preparation",
                "icon": "📚",
                "subtitle": "Comprehensive test preparation for English language proficiency exams",
                "description": """
                    <h2>Achieve Your Target Score</h2>
                    <p>Our specialized coaching programs help you master the skills needed to excel in IELTS and TOEFL exams.</p>
                    
                    <h3>Preparation Features:</h3>
                    <ul>
                        <li>Customized study plans</li>
                        <li>Practice tests and mock exams</li>
                        <li>Expert feedback and improvement strategies</li>
                        <li>Speaking and writing practice sessions</li>
                        <li>Time management techniques</li>
                    </ul>
                """,
                "keypoints": [
                    "Personalized study plans",
                    "Regular mock tests",
                    "Expert instructors",
                    "Score improvement guarantee",
                    "Flexible scheduling",
                ],
                "featured_image": "project/project/featured_image/test-prep.jpg",
            },
            {
                "category": categories["Career Counseling"],
                "title": "Career Guidance and Planning",
                "slug": "career-guidance-planning",
                "icon": "💼",
                "subtitle": "Strategic career planning for international education and beyond",
                "description": """
                    <h2>Shape Your Future Career</h2>
                    <p>Our career counselors help you align your education choices with long-term career goals and market demands.</p>
                    
                    <h3>Career Services:</h3>
                    <ul>
                        <li>Career assessment and profiling</li>
                        <li>Industry and job market analysis</li>
                        <li>Education pathway planning</li>
                        <li>Skill gap analysis</li>
                        <li>Long-term career strategy</li>
                    </ul>
                """,
                "keypoints": [
                    "Personalized career assessment",
                    "Industry trend analysis",
                    "Education pathway mapping",
                    "Skill development planning",
                    "Long-term strategy",
                ],
                "featured_image": "project/project/featured_image/career-guidance.jpg",
            },
            {
                "category": categories["Documentation"],
                "title": "Document Preparation Services",
                "slug": "document-preparation-services",
                "icon": "📄",
                "subtitle": "Professional assistance with all academic and application documents",
                "description": """
                    <h2>Perfect Your Application Documents</h2>
                    <p>Ensure your application documents are polished, professional, and meet all requirements.</p>
                    
                    <h3>Document Services:</h3>
                    <ul>
                        <li>Statement of Purpose writing</li>
                        <li>Letter of Recommendation guidance</li>
                        <li>Resume/CV preparation</li>
                        <li>Academic transcript evaluation</li>
                        <li>Document formatting and proofreading</li>
                    </ul>
                """,
                "keypoints": [
                    "Professional SOP writing",
                    "LOR guidance",
                    "CV/Resume preparation",
                    "Document proofreading",
                    "Formatting excellence",
                ],
                "featured_image": "project/project/featured_image/document-prep.jpg",
            },
        ]

        for service_data in services_data:
            service, created = Service.objects.get_or_create(
                slug=service_data["slug"], defaults=service_data
            )
            if created:
                self.stdout.write(f"Created service: {service.title}")

    def create_events(self, categories, tags):
        """Create educational events"""
        events_data = [
            {
                "category": categories["University Fairs"],
                "title": "International Education Fair 2024",
                "slug": "international-education-fair-2024",
                "subtitle": "Meet representatives from top universities worldwide",
                "description": """
                    <h2>Connect with Global Education Leaders</h2>
                    <p>Join our largest education fair of the year featuring representatives from over 100 universities across 20 countries.</p>
                    
                    <h3>Event Highlights:</h3>
                    <ul>
                        <li>Direct interaction with university admissions officers</li>
                        <li>On-spot application reviews</li>
                        <li>Scholarship information sessions</li>
                        <li>Visa guidance workshops</li>
                        <li>Career counseling sessions</li>
                    </ul>
                    
                    <p>Don't miss this opportunity to explore your study abroad options!</p>
                """,
                "live_link": "https://example.com/education-fair-2024",
                "support_for": "All prospective international students",
                "is_documented": True,
                "keypoints": [
                    "100+ participating universities",
                    "On-spot application review",
                    "Scholarship opportunities",
                    "Visa guidance",
                    "Free admission",
                ],
                "featured_image": "event/event/featured_image/education-fair.jpg",
                # 'tags': [tags['Study Abroad'], tags['University Application'], tags['Scholarships']]
            },
            {
                "category": categories["Webinars"],
                "title": "Study in USA: Complete Application Webinar",
                "slug": "study-usa-application-webinar",
                "subtitle": "Learn everything about US university applications",
                "description": """
                    <h2>Master the US Application Process</h2>
                    <p>This comprehensive webinar covers all aspects of applying to US universities for international students.</p>
                    
                    <h3>Webinar Topics:</h3>
                    <ul>
                        <li>Understanding the US education system</li>
                        <li>Application timeline and deadlines</li>
                        <li>Standardized test requirements</li>
                        <li>Financial documentation</li>
                        <li>Visa application process</li>
                    </ul>
                """,
                "live_link": "https://example.com/usa-webinar",
                "support_for": "Students planning to study in USA",
                "is_documented": True,
                "keypoints": [
                    "Application timeline guidance",
                    "Document requirements",
                    "Financial planning",
                    "Visa process explanation",
                    "Q&A session",
                ],
                "featured_image": "event/event/featured_image/usa-webinar.jpg",
                # 'tags': [tags['USA Universities'], tags['University Application']]
            },
            {
                "category": categories["Workshops"],
                "title": "IELTS Writing Masterclass Workshop",
                "slug": "ielts-writing-masterclass",
                "subtitle": "Improve your IELTS writing score with expert guidance",
                "description": """
                    <h2>Ace the IELTS Writing Test</h2>
                    <p>Join our intensive workshop focused on improving your IELTS writing skills and achieving your target band score.</p>
                    
                    <h3>Workshop Content:</h3>
                    <ul>
                        <li>Task 1 and Task 2 strategies</li>
                        <li>Grammar and vocabulary enhancement</li>
                        <li>Time management techniques</li>
                        <li>Sample answers and feedback</li>
                        <li>Common mistakes to avoid</li>
                    </ul>
                """,
                "live_link": "https://example.com/ielts-workshop",
                "support_for": "IELTS test takers",
                "is_documented": False,
                "keypoints": [
                    "Writing task strategies",
                    "Grammar and vocabulary tips",
                    "Time management",
                    "Personalized feedback",
                    "Practice exercises",
                ],
                "featured_image": "event/event/featured_image/ielts-workshop.jpg",
                # 'tags': [tags['IELTS'], tags['Test Preparation']]
            },
            {
                "category": categories["Seminars"],
                "title": "Scholarship Opportunities Seminar",
                "slug": "scholarship-opportunities-seminar",
                "subtitle": "Learn how to fund your international education",
                "description": """
                    <h2>Maximize Your Scholarship Potential</h2>
                    <p>Discover various scholarship opportunities and learn effective application strategies in this informative seminar.</p>
                    
                    <h3>Seminar Coverage:</h3>
                    <ul>
                        <li>Types of scholarships available</li>
                        <li>Eligibility criteria</li>
                        <li>Application requirements</li>
                        <li>Essay writing tips</li>
                        <li>Interview preparation</li>
                    </ul>
                """,
                "live_link": "https://example.com/scholarship-seminar",
                "support_for": "Students seeking financial aid",
                "is_documented": True,
                "keypoints": [
                    "Scholarship types explained",
                    "Application strategies",
                    "Essay writing guidance",
                    "Interview preparation",
                    "Success stories",
                ],
                "featured_image": "event/event/featured_image/scholarship-seminar.jpg",
                # 'tags': [tags['Scholarships'], tags['Funding']]
            },
        ]

        for event_data in events_data:
            # Extract tags before creating event
            event_tags = event_data.pop("tags", [])

            event, created = Event.objects.get_or_create(
                slug=event_data["slug"], defaults=event_data
            )

            if created:
                # Add tags to the event
                event.tags.set(event_tags)
                self.stdout.write(f"Created event: {event.title}")
