
# for view.py 
from django.urls import path
from django.http import HttpResponse
from .models import Teacher, Student

def create_teacher(request):
    from django.http import HttpResponse
    from random import randint

    teachers_list = [
        ['Abul Kasem', '2565454', 'MSc in Mathematics, Phd in Mathematics', 'Senior teacher', 'Mathematics', '2015-6-29', 'Laxmipur, Rajshahi', '01853654258', 'abulkasem@gmail.com'],
        ['Md. Khairul Islam', '2565455', 'MSc in Physics, Phd in Physics', 'Senior teacher', 'Physics', '2015-6-30', 'Khulna, Khulna', '01715171521', 'khairul@gmail.com'],
        ['Muhammad Shafiqul Islam', '2565456', 'MSc in Biology, Phd in Biology', 'Senior teacher', 'Biology', '2015-6-29', 'Rangpur, Rangpur', '01853654259', 'shafiqul@gmail.com'],
        ['Mohammad Sujanul Islam', '2565457', 'MSc in Chemistry, Phd in Chemistry', 'Senior teacher', 'Chemistry', '2015-6-30', 'Kishoreganj, Kishoreganj', '01715171522', 'sujanul@gmail.com'],
        ['Mohammad Atiqur Rahman', '2565458', 'MSc in Computer Science, Phd in Computer Science', 'Senior teacher', 'Computer Science', '2015-6-30', 'Sylhet, Sylhet', '01715171523', 'atiqur@gmail.com'],
        ['Mohammad Jashim Uddin', '2565459', 'MSc in History, Phd in History', 'Senior teacher', 'History', '2015-6-29', 'Dinajpur, Dinajpur', '01853654260', 'jashim@gmail.com'],
        ['Mohammad Kamruzzaman', '2565460', 'MSc in Economics, Phd in Economics', 'Senior teacher', 'Economics', '2015-6-30', 'Barisal, Barisal', '01853654261', 'kamruzzaman@gmail.com'],
        ['Aziz Ahmed', '2565451', 'MSc in English, Phd in English', 'Senior teacher', 'English', '2015-6-30', 'Noakhali, Noakhali', '01853654257', 'aziz@gmail.com'],
        ['Md. Nazmul Islam', '2565452', 'MSc in Islamic Studies, Phd in Islamic Studies', 'Senior teacher', 'Islamic Studies', '2015-6-30', 'Barisal, Barisal', '01715171524', 'nazmul@gmail.com'],
        ['Mohammad Abed', '2565453', 'MSc in Political Science, Phd in Political Science', 'Senior teacher', 'Political Science', '2015-6-30', 'Comilla, Comilla', '01853654255', 'abed@gmail.com'],
        ['Md. Shafiqul Islam', '2565458', 'MSc in Chemistry, Phd in Chemistry', 'Senior teacher', 'Chemistry', '2015-6-30', 'Dhaka, Dhaka', '01715171525', 'shafiq@gmail.com'],
        ['Motiur Rahman', '2565461', 'MSc in Mathematics, Phd in Mathematics', 'Senior teacher', 'Mathematics', '2015-6-30', 'Khulna, Khulna', '01715171526', 'motiur@gmail.com'],
        ['Nadia Haque', '2565462', 'MSc in Computer Science, Phd in Computer Science', 'Senior teacher', 'Computer Science', '2015-6-30', 'Sylhet, Sylhet', '01715171527', 'nadia@gmail.com'],
        ['Suman Rana', '2565451', 'MSc in English, Phd in English', 'Senior teacher', 'English', '2015-6-30', 'Noakhali, Noakhali', '01853654257', 'suman@gmail.com'],
        ['Fadia Ahmed', '2565452', 'MSc in Nursing, Phd in Nursing', 'Senior teacher', 'Nursing', '2015-6-30', 'Khulna, Khulna', '01715171524', 'fadia@gmail.com'],
        ['Aminul Islam', '2565453', 'MSc in Education, Phd in Education', 'Senior teacher', 'Education', '2015-6-30', 'Comilla, Comilla', '01853654255', 'aminul@gmail.com'],
        ['Rafiqul Islam', '2565458', 'MSc in Chemistry, Phd in Chemistry', 'Senior teacher', 'Chemistry', '2015-6-30', 'Dhaka, Dhaka', '01715171525', 'rafiq@gmail.com'],
        ['Rubi Akhtar', '2565461', 'MSc in Mathematics, Phd in Mathematics', 'Senior teacher', 'Mathematics', '2015-6-30', 'Khulna, Khulna', '01715171526', 'rubi@gmail.com'],
        ['Abdul Kerim', '2565462', 'MSc in Computer Science, Phd in Computer Science', 'Senior teacher', 'Computer Science', '2015-6-30', 'Sylhet, Sylhet', '01715171527', 'abdul@gmail.com'],
    ]

    i = 100000
    for teacher in teachers_list:
        try:
            Teacher.objects.create(
                name=teacher[0],
                employee_id= i,
                academic_qualification=teacher[2],
                designation=teacher[3],
                teaching_subject=teacher[4],
                joining_date=teacher[5],
                address=teacher[6],
                phone=teacher[7],
                email=teacher[8]
            )
            i += 1
        except Exception as e:
            print('error', e)
    
    return HttpResponse('Teachers created successfully!')


def add_photo_teacher(request):
    from django.http import HttpResponse


    teachers = Teacher.objects.all()

    for teacher in teachers:
        if teacher.id > 10:
            teacher.photo = ''
            teacher.save()
    
    return HttpResponse('Teachers photo added successfully!')


# for urls.py




def create_students(request):

    students = [
        ['Roopa Kumar', 'Morning', '8', 'C', 2, 'Female'],
        ['Kumar Krishna', 'Morning', '10', 'B', 1, 'Male'],
        ['Komal Kumari', 'Morning', '8', 'A', 1, 'Female'],
        ['Pratik Patel', 'Morning', '8', 'A', 2, 'Male'],
        ['Sandeep Singh', 'Morning', '8', 'A', 2, 'Male'],
        ['Dipika Choudhary', 'Morning', '8', 'A', 1, 'Female'],
        ['Neelam Sharma', 'Morning', '10', 'B', 1, 'Female'],
        ['Ajay Kumar', 'Morning', '8', 'A', 2, 'Male'],
        ['Aarti Sharma', 'Morning', '8', 'A', 1, 'Female'],
        ['Ritesh Kumar', 'Morning', '10', 'B', 1, 'Male'],
        ['Nilofer Jahan', 'Morning', '2', 'A', 1, 'Female'],
        ['Faridul Islam', 'Morning', '2', 'A', 1, 'Male'],
        ['Sabrina Akther', 'Morning', '2', 'A', 1, 'Female'],
        ['Shafiul Mondal', 'Morning', '2', 'A', 1, 'Male'],
        ['Kamrul Hasan', 'Morning', '2', 'A', 1, 'Male'],
        ['Shabnam Khatun', 'Morning', '2', 'A', 1, 'Female'],
        ['Sufia Akther', 'Morning', '2', 'A', 1, 'Female'],
        ['Nusrat Jahan', 'Morning', '2', 'A', 1, 'Female'],
        ['Monirul Hoque', 'Morning', '2', 'A', 1, 'Male'],
        ['Rabeya Akhter', 'Morning', '2', 'A', 1, 'Female'],
        ['Shyamal Saha', 'Morning', '2', 'C', 2, 'Male'],
        ['Roni Begum', 'Morning', '2', 'C', 2, 'Female'],
        ['Mithun Saha', 'Morning', '2', 'C', 2, 'Male'],
        ['Samira Khan', 'Morning', '2', 'C', 2, 'Female'],
        ['Nazmul Haque', 'Morning', '2', 'C', 2, 'Male'],
        ['Farhana Akhter', 'Morning', '2', 'C', 2, 'Female'],
        ['Subarna Saha', 'Morning', '2', 'C', 2, 'Female'],
        ['Joni Akter', 'Morning', '2', 'C', 2, 'Female'],
        ['Nusrat Khanom', 'Morning', '2', 'C', 2, 'Female'],
        ['Subrata Saha', 'Morning', '2', 'C', 2, 'Male'],
    ]
    index = 10
    for i in students:
        Student.objects.create(
            name=i[0],
            shift=i[1],
            enrolled_class=i[2],
            section=i[3],
            roll=index+3,
            gender=i[5]
        )
        index += 1


    return HttpResponse('Students created successfully!')


urlpatterns = [
    path('create-teacher/', create_teacher, name="create_teacher"),
    path('add-photo/', add_photo_teacher, name="add_photo_teacher"),
    path('create-students/', create_students, name="create_students"),
]

# + [
#     path('create-teacher/', db_seed.create_teacher, name="create_teacher"),
#     path('add-photo/', db_seed.add_photo_teacher, name="add_photo_teacher"),
#     path('create-students/', db_seed.create_students, name="create_students"),
# ]