import os
from django.core.management.base import BaseCommand
from django.core.files.base import ContentFile
from django.utils.text import slugify
import requests
from io import BytesIO
from django.conf import settings

from courses.models import (
    Course, CourseEligibility, CourseFee, FeeDetail, HostelFee,
    Semester, Subject, CareerProspect, AdmissionStep, DirectAdmission,
    Recruiter, WhyJoin, CourseHighlight, CourseImage, Testimonial
)

class Command(BaseCommand):
    help = 'Creates comprehensive content for all Smart Computing courses'

    def handle(self, *args, **options):
        self.stdout.write(self.style.SUCCESS('Starting to create content for Smart Computing courses'))
        
        # Get all courses (excluding the original B.Tech CSE which already has content)
        courses = Course.objects.exclude(slug='btech-computer-science-engineering').order_by('id')
        
        for course in courses:
            self.stdout.write(f"\n--- Creating content for: {course.title} ---")
            
            # Create semesters and subjects
            self._create_semesters_and_subjects(course)
            
            # Create career prospects
            self._create_career_prospects(course)
            
            # Create admission steps
            self._create_admission_steps(course)
            
            # Create direct admission info
            self._create_direct_admission(course)
            
            # Create fee details
            self._create_fee_details(course)
            
            # Create hostel fee
            self._create_hostel_fee(course)
            
            # Create recruiters
            self._create_recruiters(course)
            
            # Create why join reasons
            self._create_why_join(course)
            
            # Create testimonials
            self._create_testimonials(course)
            
            self.stdout.write(self.style.SUCCESS(f"✓ Completed content for {course.title}"))
        
        self.stdout.write(self.style.SUCCESS('\n🎉 Successfully created content for all Smart Computing courses!'))

    def _create_semesters_and_subjects(self, course):
        """Create semesters and subjects based on course type"""
        # Determine number of semesters based on duration
        if '4 Years' in course.duration:
            num_semesters = 8
        elif '3 Years' in course.duration:
            num_semesters = 6
        elif '2 Years' in course.duration:
            num_semesters = 4
        else:
            num_semesters = 6  # Default
        
        # Create semesters
        for sem_num in range(1, num_semesters + 1):
            semester, created = Semester.objects.get_or_create(
                course=course,
                number=sem_num,
                defaults={'name': f'Semester {sem_num}'}
            )
            
            # Create subjects for each semester
            subjects = self._get_subjects_for_semester(course, sem_num)
            for subject_data in subjects:
                Subject.objects.get_or_create(
                    semester=semester,
                    code=subject_data['code'],
                    defaults={
                        'name': subject_data['name'],
                        'credits': subject_data['credits'],
                        'description': subject_data['description']
                    }
                )
    
    def _get_subjects_for_semester(self, course, semester_num):
        """Get subjects based on course type and semester"""
        base_subjects = {
            1: [
                {'code': 'MA101', 'name': 'Engineering Mathematics I', 'credits': 4, 'description': 'Calculus, differential equations, linear algebra fundamentals.'},
                {'code': 'PH101', 'name': 'Engineering Physics', 'credits': 3, 'description': 'Mechanics, thermodynamics, waves, and modern physics.'},
                {'code': 'CH101', 'name': 'Engineering Chemistry', 'credits': 3, 'description': 'Chemical bonding, thermodynamics, and materials science.'},
                {'code': 'HU101', 'name': 'Communication Skills', 'credits': 2, 'description': 'English proficiency, technical writing, and presentation skills.'},
                {'code': 'ME101', 'name': 'Engineering Drawing', 'credits': 3, 'description': 'Technical drawing, CAD basics, and geometric constructions.'},
            ],
            2: [
                {'code': 'MA102', 'name': 'Engineering Mathematics II', 'credits': 4, 'description': 'Advanced calculus, statistics, and numerical methods.'},
                {'code': 'EC101', 'name': 'Digital Electronics', 'credits': 3, 'description': 'Logic gates, combinational circuits, and digital systems.'},
                {'code': 'CS102', 'name': 'Data Structures', 'credits': 4, 'description': 'Arrays, linked lists, stacks, queues, trees, and graphs.'},
                {'code': 'HU102', 'name': 'Professional Ethics', 'credits': 2, 'description': 'Engineering ethics, professional responsibility, and social impact.'},
            ]
        }
        
        # Specialized subjects based on course type
        if 'AI & ML' in course.title:
            ai_subjects = {
                3: [
                    {'code': 'AI201', 'name': 'Introduction to Artificial Intelligence', 'credits': 4, 'description': 'AI fundamentals, search algorithms, and knowledge representation.'},
                    {'code': 'ML201', 'name': 'Machine Learning Fundamentals', 'credits': 4, 'description': 'Supervised and unsupervised learning algorithms.'},
                    {'code': 'CS201', 'name': 'Algorithm Design', 'credits': 3, 'description': 'Advanced algorithms and complexity analysis.'},
                ],
                4: [
                    {'code': 'AI202', 'name': 'Deep Learning', 'credits': 4, 'description': 'Neural networks, backpropagation, and deep architectures.'},
                    {'code': 'ML202', 'name': 'Pattern Recognition', 'credits': 3, 'description': 'Feature extraction, classification, and clustering techniques.'},
                    {'code': 'CS202', 'name': 'Database Management Systems', 'credits': 4, 'description': 'Relational databases, SQL, and database design.'},
                ]
            }
            base_subjects.update(ai_subjects)
        
        elif 'Cyber Security' in course.title or 'IOT' in course.title:
            security_subjects = {
                3: [
                    {'code': 'CS301', 'name': 'Network Security', 'credits': 4, 'description': 'Cryptography, network protocols, and security mechanisms.'},
                    {'code': 'CS302', 'name': 'Internet of Things', 'credits': 4, 'description': 'IoT architecture, sensors, and connectivity protocols.'},
                    {'code': 'CS303', 'name': 'Blockchain Technology', 'credits': 3, 'description': 'Distributed ledger, cryptocurrency, and smart contracts.'},
                ],
                4: [
                    {'code': 'CS304', 'name': 'Ethical Hacking', 'credits': 4, 'description': 'Penetration testing, vulnerability assessment, and security auditing.'},
                    {'code': 'CS305', 'name': 'Digital Forensics', 'credits': 3, 'description': 'Evidence collection, analysis, and forensic procedures.'},
                    {'code': 'CS306', 'name': 'Cloud Security', 'credits': 4, 'description': 'Cloud computing security, compliance, and risk management.'},
                ]
            }
            base_subjects.update(security_subjects)
        
        elif 'Animation' in course.title:
            animation_subjects = {
                3: [
                    {'code': 'AN301', 'name': '2D Animation', 'credits': 4, 'description': 'Traditional animation principles, keyframing, and digital 2D animation.'},
                    {'code': 'AN302', 'name': '3D Modeling', 'credits': 4, 'description': '3D modeling techniques, texturing, and rendering.'},
                    {'code': 'AN303', 'name': 'Graphic Design', 'credits': 3, 'description': 'Design principles, typography, and visual communication.'},
                ],
                4: [
                    {'code': 'AN304', 'name': '3D Animation', 'credits': 4, 'description': 'Character animation, rigging, and motion capture.'},
                    {'code': 'AN305', 'name': 'Visual Effects', 'credits': 3, 'description': 'Compositing, particle systems, and special effects.'},
                    {'code': 'AN306', 'name': 'Game Design', 'credits': 4, 'description': 'Game mechanics, level design, and interactive media.'},
                ]
            }
            base_subjects.update(animation_subjects)
        
        else:  # General CS subjects
            cs_subjects = {
                3: [
                    {'code': 'CS201', 'name': 'Object-Oriented Programming', 'credits': 4, 'description': 'OOP concepts, design patterns, and software engineering.'},
                    {'code': 'CS202', 'name': 'Computer Networks', 'credits': 4, 'description': 'Network protocols, OSI model, and network programming.'},
                    {'code': 'CS203', 'name': 'Operating Systems', 'credits': 3, 'description': 'Process management, memory management, and file systems.'},
                ],
                4: [
                    {'code': 'CS204', 'name': 'Database Management Systems', 'credits': 4, 'description': 'Relational databases, SQL, and database design.'},
                    {'code': 'CS205', 'name': 'Software Engineering', 'credits': 3, 'description': 'SDLC, testing, and project management.'},
                    {'code': 'CS206', 'name': 'Web Technologies', 'credits': 4, 'description': 'HTML, CSS, JavaScript, and web frameworks.'},
                ]
            }
            base_subjects.update(cs_subjects)
        
        return base_subjects.get(semester_num, [])

    def _create_career_prospects(self, course):
        """Create career prospects based on course type"""
        if 'AI & ML' in course.title:
            prospects = [
                {'title': 'Machine Learning Engineer', 'salary_range': '₹8-25 LPA', 'description': 'Design and implement ML algorithms for various applications.'},
                {'title': 'Data Scientist', 'salary_range': '₹6-20 LPA', 'description': 'Analyze complex data to extract insights and drive business decisions.'},
                {'title': 'AI Research Scientist', 'salary_range': '₹12-35 LPA', 'description': 'Conduct research in AI and develop innovative solutions.'},
                {'title': 'Deep Learning Specialist', 'salary_range': '₹10-30 LPA', 'description': 'Develop neural networks and deep learning models.'},
            ]
        elif 'Cyber Security' in course.title or 'IOT' in course.title:
            prospects = [
                {'title': 'Cybersecurity Analyst', 'salary_range': '₹5-18 LPA', 'description': 'Monitor and protect organizations from cyber threats.'},
                {'title': 'IoT Solutions Architect', 'salary_range': '₹8-25 LPA', 'description': 'Design and implement IoT systems and solutions.'},
                {'title': 'Blockchain Developer', 'salary_range': '₹6-22 LPA', 'description': 'Develop blockchain applications and smart contracts.'},
                {'title': 'Information Security Manager', 'salary_range': '₹10-30 LPA', 'description': 'Lead security initiatives and manage security teams.'},
            ]
        elif 'Animation' in course.title:
            prospects = [
                {'title': '3D Animator', 'salary_range': '₹4-15 LPA', 'description': 'Create animated content for films, games, and media.'},
                {'title': 'VFX Artist', 'salary_range': '₹5-18 LPA', 'description': 'Develop visual effects for movies and advertising.'},
                {'title': 'Game Designer', 'salary_range': '₹4-16 LPA', 'description': 'Design game mechanics and interactive experiences.'},
                {'title': 'Multimedia Specialist', 'salary_range': '₹3-12 LPA', 'description': 'Create multimedia content for various platforms.'},
            ]
        else:  # General CS careers
            prospects = [
                {'title': 'Software Developer', 'salary_range': '₹4-18 LPA', 'description': 'Develop software applications and systems.'},
                {'title': 'Full Stack Developer', 'salary_range': '₹5-20 LPA', 'description': 'Work on both frontend and backend development.'},
                {'title': 'System Administrator', 'salary_range': '₹3-15 LPA', 'description': 'Manage and maintain computer systems and networks.'},
                {'title': 'Technical Consultant', 'salary_range': '₹6-22 LPA', 'description': 'Provide technical expertise and solutions to clients.'},
            ]
        
        for prospect_data in prospects:
            CareerProspect.objects.get_or_create(
                course=course,
                title=prospect_data['title'],
                defaults={
                    'salary_range': prospect_data['salary_range'],
                    'description': prospect_data['description']
                }
            )

    def _create_admission_steps(self, course):
        """Create admission steps for the course"""
        if 'LE' in course.title:  # Lateral Entry
            steps = [
                {'title': 'Eligibility Check', 'description': 'Ensure you have completed diploma in relevant field with minimum required marks.', 'order': 1},
                {'title': 'Application Submission', 'description': 'Submit online application with required documents and application fee.', 'order': 2},
                {'title': 'Lateral Entry Test', 'description': 'Appear for lateral entry entrance examination or merit-based selection.', 'order': 3},
                {'title': 'Counseling Process', 'description': 'Participate in counseling based on entrance test results or merit.', 'order': 4},
                {'title': 'Document Verification', 'description': 'Submit original documents for verification and complete admission formalities.', 'order': 5},
            ]
        elif 'M.Tech' in course.title or 'M.Sc' in course.title or 'MCA' in course.title:
            steps = [
                {'title': 'Eligibility Verification', 'description': 'Check graduation requirements and minimum marks criteria.', 'order': 1},
                {'title': 'Entrance Examination', 'description': 'Qualify GATE/NET or university entrance test for admission.', 'order': 2},
                {'title': 'Application Process', 'description': 'Complete online application with academic transcripts and certificates.', 'order': 3},
                {'title': 'Interview Round', 'description': 'Attend personal interview and technical assessment if required.', 'order': 4},
                {'title': 'Final Admission', 'description': 'Complete admission formalities including fee payment and document submission.', 'order': 5},
            ]
        else:  # Undergraduate courses
            steps = [
                {'title': 'Application Form', 'description': 'Fill out the online application form with personal and academic details.', 'order': 1},
                {'title': 'Document Upload', 'description': 'Upload scanned copies of required documents including 10+2 certificates.', 'order': 2},
                {'title': 'Entrance Test', 'description': 'Appear for entrance examination or provide JEE/state entrance scores.', 'order': 3},
                {'title': 'Merit List', 'description': 'Check merit list based on entrance test performance and academic records.', 'order': 4},
                {'title': 'Counseling & Admission', 'description': 'Attend counseling session and complete admission with fee payment.', 'order': 5},
            ]
        
        for step_data in steps:
            AdmissionStep.objects.get_or_create(
                course=course,
                title=step_data['title'],
                order=step_data['order'],
                defaults={'description': step_data['description']}
            )

    def _create_direct_admission(self, course):
        """Create direct admission information"""
        if 'Hons' in course.title:
            description = "Direct admission available for meritorious students with exceptional academic performance in 10+2 or equivalent examinations. Students with JEE Main scores above 85 percentile are eligible for direct admission without entrance test."
            is_available = True
        elif 'Diploma' in course.title:
            description = "Direct admission available based on 10th standard marks. Students with 80% or above in 10th standard can apply for direct admission."
            is_available = True
        else:
            description = "Direct admission available for students meeting minimum eligibility criteria and cut-off marks. Merit-based selection process ensures quality admissions."
            is_available = True
        
        DirectAdmission.objects.get_or_create(
            course=course,
            defaults={
                'description': description,
                'is_available': is_available
            }
        )

    def _create_fee_details(self, course):
        """Create detailed fee structure"""
        try:
            course_fee = course.fees
            
            # Determine fee structure based on course type
            if 'M.Tech' in course.title or 'M.Sc' in course.title:
                fee_details = [
                    {'fee_head': 'Tuition Fee', 'first_year': '₹1,50,000', 'second_year': '₹1,50,000', 'third_year': '₹0', 'fourth_year': '₹0', 'is_one_time': False},
                    {'fee_head': 'Registration Fee', 'first_year': '₹5,000', 'second_year': '₹0', 'third_year': '₹0', 'fourth_year': '₹0', 'is_one_time': True},
                    {'fee_head': 'Laboratory Fee', 'first_year': '₹15,000', 'second_year': '₹15,000', 'third_year': '₹0', 'fourth_year': '₹0', 'is_one_time': False},
                    {'fee_head': 'Library Fee', 'first_year': '₹5,000', 'second_year': '₹5,000', 'third_year': '₹0', 'fourth_year': '₹0', 'is_one_time': False},
                    {'fee_head': 'Examination Fee', 'first_year': '₹5,000', 'second_year': '₹5,000', 'third_year': '₹0', 'fourth_year': '₹0', 'is_one_time': False},
                ]
            elif 'MCA' in course.title:
                fee_details = [
                    {'fee_head': 'Tuition Fee', 'first_year': '₹1,30,000', 'second_year': '₹1,30,000', 'third_year': '₹0', 'fourth_year': '₹0', 'is_one_time': False},
                    {'fee_head': 'Registration Fee', 'first_year': '₹5,000', 'second_year': '₹0', 'third_year': '₹0', 'fourth_year': '₹0', 'is_one_time': True},
                    {'fee_head': 'Computer Lab Fee', 'first_year': '₹20,000', 'second_year': '₹20,000', 'third_year': '₹0', 'fourth_year': '₹0', 'is_one_time': False},
                    {'fee_head': 'Library Fee', 'first_year': '₹3,000', 'second_year': '₹3,000', 'third_year': '₹0', 'fourth_year': '₹0', 'is_one_time': False},
                    {'fee_head': 'Examination Fee', 'first_year': '₹2,000', 'second_year': '₹2,000', 'third_year': '₹0', 'fourth_year': '₹0', 'is_one_time': False},
                ]
            elif 'B.Tech' in course.title:
                fee_details = [
                    {'fee_head': 'Tuition Fee', 'first_year': '₹1,40,000', 'second_year': '₹1,40,000', 'third_year': '₹1,40,000', 'fourth_year': '₹1,40,000', 'is_one_time': False},
                    {'fee_head': 'Registration Fee', 'first_year': '₹10,000', 'second_year': '₹0', 'third_year': '₹0', 'fourth_year': '₹0', 'is_one_time': True},
                    {'fee_head': 'Laboratory Fee', 'first_year': '₹15,000', 'second_year': '₹15,000', 'third_year': '₹20,000', 'fourth_year': '₹20,000', 'is_one_time': False},
                    {'fee_head': 'Library Fee', 'first_year': '₹5,000', 'second_year': '₹5,000', 'third_year': '₹5,000', 'fourth_year': '₹5,000', 'is_one_time': False},
                    {'fee_head': 'Development Fee', 'first_year': '₹10,000', 'second_year': '₹10,000', 'third_year': '₹10,000', 'fourth_year': '₹10,000', 'is_one_time': False},
                    {'fee_head': 'Examination Fee', 'first_year': '₹5,000', 'second_year': '₹5,000', 'third_year': '₹5,000', 'fourth_year': '₹5,000', 'is_one_time': False},
                ]
            elif 'BCA' in course.title or 'B.Sc' in course.title:
                fee_details = [
                    {'fee_head': 'Tuition Fee', 'first_year': '₹90,000', 'second_year': '₹90,000', 'third_year': '₹90,000', 'fourth_year': '₹0', 'is_one_time': False},
                    {'fee_head': 'Registration Fee', 'first_year': '₹5,000', 'second_year': '₹0', 'third_year': '₹0', 'fourth_year': '₹0', 'is_one_time': True},
                    {'fee_head': 'Computer Lab Fee', 'first_year': '₹15,000', 'second_year': '₹15,000', 'third_year': '₹15,000', 'fourth_year': '₹0', 'is_one_time': False},
                    {'fee_head': 'Library Fee', 'first_year': '₹5,000', 'second_year': '₹5,000', 'third_year': '₹5,000', 'fourth_year': '₹0', 'is_one_time': False},
                    {'fee_head': 'Examination Fee', 'first_year': '₹5,000', 'second_year': '₹5,000', 'third_year': '₹5,000', 'fourth_year': '₹0', 'is_one_time': False},
                ]
            else:  # Diploma
                fee_details = [
                    {'fee_head': 'Tuition Fee', 'first_year': '₹60,000', 'second_year': '₹60,000', 'third_year': '₹60,000', 'fourth_year': '₹0', 'is_one_time': False},
                    {'fee_head': 'Registration Fee', 'first_year': '₹3,000', 'second_year': '₹0', 'third_year': '₹0', 'fourth_year': '₹0', 'is_one_time': True},
                    {'fee_head': 'Laboratory Fee', 'first_year': '₹10,000', 'second_year': '₹10,000', 'third_year': '₹10,000', 'fourth_year': '₹0', 'is_one_time': False},
                    {'fee_head': 'Library Fee', 'first_year': '₹2,000', 'second_year': '₹2,000', 'third_year': '₹2,000', 'fourth_year': '₹0', 'is_one_time': False},
                    {'fee_head': 'Examination Fee', 'first_year': '₹5,000', 'second_year': '₹5,000', 'third_year': '₹5,000', 'fourth_year': '₹0', 'is_one_time': False},
                ]
            
            for fee_data in fee_details:
                FeeDetail.objects.get_or_create(
                    course_fee=course_fee,
                    fee_head=fee_data['fee_head'],
                    defaults={
                        'first_year': fee_data['first_year'],
                        'second_year': fee_data['second_year'],
                        'third_year': fee_data['third_year'],
                        'fourth_year': fee_data['fourth_year'],
                        'is_one_time': fee_data['is_one_time']
                    }
                )
        except Exception as e:
            self.stdout.write(self.style.WARNING(f"Could not create fee details for {course.title}: {str(e)}"))

    def _create_hostel_fee(self, course):
        """Create hostel fee information"""
        HostelFee.objects.get_or_create(
            course=course,
            defaults={
                'fee_per_year': '₹80,000',
                'ac_room_additional': '₹20,000',
                'security_deposit': '₹15,000',
                'notes': 'Hostel fees include accommodation, meals, laundry, and basic amenities. AC rooms are available with additional charges. Security deposit is refundable at the time of leaving the hostel.'
            }
        )

    def _create_recruiters(self, course):
        """Create recruiter information"""
        if 'AI & ML' in course.title:
            recruiters = ['Google', 'Microsoft', 'Amazon', 'IBM', 'NVIDIA', 'Intel', 'Adobe', 'Flipkart', 'Zomato', 'Paytm']
        elif 'Cyber Security' in course.title or 'IOT' in course.title:
            recruiters = ['Cisco', 'IBM', 'Accenture', 'Deloitte', 'EY', 'KPMG', 'Wipro', 'TCS', 'Infosys', 'HCL']
        elif 'Animation' in course.title:
            recruiters = ['Disney', 'Pixar', 'DreamWorks', 'Technicolor', 'Prime Focus', 'Red Chillies VFX', 'Toonz', 'Reliance Animation', 'Maya Entertainment', 'Digitoonz']
        else:
            recruiters = ['TCS', 'Infosys', 'Wipro', 'Cognizant', 'Accenture', 'IBM', 'Microsoft', 'Amazon', 'Google', 'Flipkart']
        
        for recruiter_name in recruiters:
            Recruiter.objects.get_or_create(
                course=course,
                name=recruiter_name,
                defaults={'logo': f'courses/recruiters/{recruiter_name.lower()}.png'}
            )

    def _create_why_join(self, course):
        """Create why join reasons"""
        if 'AI & ML' in course.title:
            reasons = [
                {'title': 'Cutting-edge Curriculum', 'description': 'Learn the latest AI and ML technologies with hands-on projects and industry-relevant skills.'},
                {'title': 'Research Opportunities', 'description': 'Engage in groundbreaking research with faculty and contribute to AI advancement.'},
                {'title': 'Industry Partnerships', 'description': 'Access to leading tech companies and startups for internships and placements.'},
                {'title': 'State-of-the-art Labs', 'description': 'Work with high-performance computing resources and latest AI development tools.'},
            ]
        elif 'Cyber Security' in course.title or 'IOT' in course.title:
            reasons = [
                {'title': 'High Demand Field', 'description': 'Cybersecurity and IoT are among the fastest-growing technology sectors globally.'},
                {'title': 'Practical Training', 'description': 'Hands-on experience with real-world security challenges and IoT implementations.'},
                {'title': 'Industry Certifications', 'description': 'Opportunity to earn recognized certifications from leading security organizations.'},
                {'title': 'Career Security', 'description': 'Strong job security and growth prospects in the cybersecurity industry.'},
            ]
        elif 'Animation' in course.title:
            reasons = [
                {'title': 'Creative Industry Focus', 'description': 'Join the booming animation and multimedia industry with creative career opportunities.'},
                {'title': 'Portfolio Development', 'description': 'Build a strong professional portfolio with guidance from industry experts.'},
                {'title': 'Latest Software Training', 'description': 'Master industry-standard software and tools used by leading animation studios.'},
                {'title': 'Global Opportunities', 'description': 'Access to international animation and gaming industry opportunities.'},
            ]
        else:
            reasons = [
                {'title': 'Industry-Ready Skills', 'description': 'Develop practical skills that are directly applicable in the technology industry.'},
                {'title': 'Strong Foundation', 'description': 'Build a solid foundation in computer science principles and programming.'},
                {'title': 'Career Flexibility', 'description': 'Multiple career paths available in software development, consulting, and management.'},
                {'title': 'Continuous Learning', 'description': 'Stay updated with latest technologies and industry trends throughout the program.'},
            ]
        
        for reason_data in reasons:
            WhyJoin.objects.get_or_create(
                course=course,
                title=reason_data['title'],
                defaults={'description': reason_data['description']}
            )

    def _create_testimonials(self, course):
        """Create student testimonials"""
        testimonials = [
            {
                'name': 'Priya Sharma',
                'position': 'Software Engineer',
                'company': 'Microsoft',
                'content': f'The {course.title} program provided me with excellent technical skills and industry exposure. The faculty support and practical approach helped me secure a great position at Microsoft.',
                'photo': 'courses/testimonials/priya.jpg'
            },
            {
                'name': 'Rahul Kumar',
                'position': 'Technical Lead',
                'company': 'Amazon',
                'content': f'I am grateful for the comprehensive curriculum and hands-on learning experience in {course.title}. The program prepared me well for my career in technology.',
                'photo': 'courses/testimonials/rahul.jpg'
            },
            {
                'name': 'Sneha Patel',
                'position': 'Data Scientist',
                'company': 'Google',
                'content': f'The {course.title} program exceeded my expectations. The blend of theoretical knowledge and practical projects gave me a competitive edge in the job market.',
                'photo': 'courses/testimonials/sneha.jpg'
            }
        ]
        
        for testimonial_data in testimonials:
            Testimonial.objects.get_or_create(
                course=course,
                name=testimonial_data['name'],
                position=testimonial_data['position'],
                company=testimonial_data['company'],
                defaults={
                    'content': testimonial_data['content'],
                    'photo': testimonial_data['photo']
                }
            )
