# management/commands/seed_education_data.py
from django.core.management.base import BaseCommand
from django.db import transaction
from base.models import (Guideline
)

class Command(BaseCommand):
    help = 'Seed comprehensive education platform data including guidelines, pages, and content'

    def handle(self, *args, **options):
        self.stdout.write('Seeding comprehensive education platform data...')
        
        with transaction.atomic():
            self.create_guidelines()
            
        self.stdout.write(self.style.SUCCESS('Successfully seeded all education platform data!'))

    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}'))
