from django.shortcuts import render,redirect,reverse
from . import forms,models
from django.db.models import Sum
from django.contrib.auth.models import Group
from django.http import HttpResponseRedirect
from django.contrib.auth.decorators import login_required,user_passes_test

def home_view(request):
    if request.user.is_authenticated:
        return HttpResponseRedirect('afterlogin')
    return render(request,'school/index.html')



#for showing signup/login button for teacher(by sumit)
def adminclick_view(request):
    if request.user.is_authenticated:
        return HttpResponseRedirect('afterlogin')
    return render(request,'school/adminclick.html')


#for showing signup/login button for teacher(by sumit)
def teacherclick_view(request):
    if request.user.is_authenticated:
        return HttpResponseRedirect('afterlogin')
    return render(request,'school/teacherclick.html')


#for showing signup/login button for student(by sumit)
def studentclick_view(request):
    if request.user.is_authenticated:
        return HttpResponseRedirect('afterlogin')
    return render(request,'school/studentclick.html')





def admin_signup_view(request):
    form=forms.AdminSigupForm()
    if request.method=='POST':
        form=forms.AdminSigupForm(request.POST)
        if form.is_valid():
            user=form.save()
            user.set_password(user.password)
            user.save()


            my_admin_group = Group.objects.get_or_create(name='ADMIN')
            my_admin_group[0].user_set.add(user)

            return HttpResponseRedirect('adminlogin')
    return render(request,'school/adminsignup.html',{'form':form})




def student_signup_view(request):
    form1=forms.StudentUserForm()
    form2=forms.StudentExtraForm()
    mydict={'form1':form1,'form2':form2}
    if request.method=='POST':
        form1=forms.StudentUserForm(request.POST)
        form2=forms.StudentExtraForm(request.POST)
        if form1.is_valid() and form2.is_valid():
            user=form1.save()
            user.set_password(user.password)
            user.save()
            f2=form2.save(commit=False)
            f2.user=user
            user2=f2.save()

            my_student_group = Group.objects.get_or_create(name='STUDENT')
            my_student_group[0].user_set.add(user)

        return HttpResponseRedirect('studentlogin')
    return render(request,'school/studentsignup.html',context=mydict)


def teacher_signup_view(request):
    form1=forms.TeacherUserForm()
    form2=forms.TeacherExtraForm()
    mydict={'form1':form1,'form2':form2}
    if request.method=='POST':
        form1=forms.TeacherUserForm(request.POST)
        form2=forms.TeacherExtraForm(request.POST)
        if form1.is_valid() and form2.is_valid():
            user=form1.save()
            user.set_password(user.password)
            user.save()
            f2=form2.save(commit=False)
            f2.user=user
            user2=f2.save()

            my_teacher_group = Group.objects.get_or_create(name='TEACHER')
            my_teacher_group[0].user_set.add(user)

        return HttpResponseRedirect('teacherlogin')
    return render(request,'school/teachersignup.html',context=mydict)






#for checking user is techer , student or admin(by sumit)
def is_admin(user):
    return user.groups.filter(name='ADMIN').exists()
def is_teacher(user):
    return user.groups.filter(name='TEACHER').exists()
def is_student(user):
    return user.groups.filter(name='STUDENT').exists()


def afterlogin_view(request):
    if is_admin(request.user):
        return redirect('admin-dashboard')
    elif is_teacher(request.user):
        accountapproval=models.TeacherExtra.objects.all().filter(user_id=request.user.id,status=True)
        if accountapproval:
            return redirect('teacher-dashboard')
        else:
            return render(request,'school/teacher_wait_for_approval.html')
    elif is_student(request.user):
        accountapproval=models.StudentExtra.objects.all().filter(user_id=request.user.id,status=True)
        if accountapproval:
            return redirect('student-dashboard')
        else:
            return render(request,'school/student_wait_for_approval.html')




#for dashboard of adminnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn(by sumit)

@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def admin_dashboard_view(request):
    teachercount=models.TeacherExtra.objects.all().filter(status=True).count()
    pendingteachercount=models.TeacherExtra.objects.all().filter(status=False).count()

    studentcount=models.StudentExtra.objects.all().filter(status=True).count()
    pendingstudentcount=models.StudentExtra.objects.all().filter(status=False).count()

    teachersalary=models.TeacherExtra.objects.filter(status=True).aggregate(Sum('salary'))
    pendingteachersalary=models.TeacherExtra.objects.filter(status=False).aggregate(Sum('salary'))

    studentfee=models.StudentExtra.objects.filter(status=True).aggregate(Sum('fee',default=0))
    pendingstudentfee=models.StudentExtra.objects.filter(status=False).aggregate(Sum('fee'))

    notice=models.Notice.objects.all()

    #aggregate function return dictionary so fetch data from dictionay(by sumit)
    mydict={
        'teachercount':teachercount,
        'pendingteachercount':pendingteachercount,

        'studentcount':studentcount,
        'pendingstudentcount':pendingstudentcount,

        'teachersalary':teachersalary['salary__sum'],
        'pendingteachersalary':pendingteachersalary['salary__sum'],

        'studentfee':studentfee['fee__sum'],
        'pendingstudentfee':pendingstudentfee['fee__sum'],

        'notice':notice

    }

    return render(request,'school/admin_dashboard.html',context=mydict)







#for teacher sectionnnnnnnn by adminnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn(by sumit)

@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def admin_teacher_view(request):
    return render(request,'school/admin_teacher.html')

@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def admin_add_teacher_view(request):
    form1=forms.TeacherUserForm()
    form2=forms.TeacherExtraForm()
    mydict={'form1':form1,'form2':form2}
    if request.method=='POST':
        form1=forms.TeacherUserForm(request.POST)
        form2=forms.TeacherExtraForm(request.POST)
        if form1.is_valid() and form2.is_valid():
            user=form1.save()
            user.set_password(user.password)
            user.save()

            f2=form2.save(commit=False)
            f2.user=user
            f2.status=True
            f2.save()

            my_teacher_group = Group.objects.get_or_create(name='TEACHER')
            my_teacher_group[0].user_set.add(user)

        return HttpResponseRedirect('admin-teacher')
    return render(request,'school/admin_add_teacher.html',context=mydict)


@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def admin_view_teacher_view(request):
    teachers=models.TeacherExtra.objects.all().filter(status=True)
    return render(request,'school/admin_view_teacher.html',{'teachers':teachers})


@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def admin_approve_teacher_view(request):
    teachers=models.TeacherExtra.objects.all().filter(status=False)
    return render(request,'school/admin_approve_teacher.html',{'teachers':teachers})


@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def approve_teacher_view(request,pk):
    teacher=models.TeacherExtra.objects.get(id=pk)
    teacher.status=True
    teacher.save()
    return redirect(reverse('admin-approve-teacher'))


@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def delete_teacher_view(request,pk):
    teacher=models.TeacherExtra.objects.get(id=pk)
    user=models.User.objects.get(id=teacher.user_id)
    user.delete()
    teacher.delete()
    return redirect('admin-approve-teacher')


@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def delete_teacher_from_school_view(request,pk):
    teacher=models.TeacherExtra.objects.get(id=pk)
    user=models.User.objects.get(id=teacher.user_id)
    user.delete()
    teacher.delete()
    return redirect('admin-view-teacher')


@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def update_teacher_view(request,pk):
    teacher=models.TeacherExtra.objects.get(id=pk)
    user=models.User.objects.get(id=teacher.user_id)

    form1=forms.TeacherUserForm(instance=user)
    form2=forms.TeacherExtraForm(instance=teacher)
    mydict={'form1':form1,'form2':form2}

    if request.method=='POST':
        form1=forms.TeacherUserForm(request.POST,instance=user)
        form2=forms.TeacherExtraForm(request.POST,instance=teacher)
        print(form1)
        if form1.is_valid() and form2.is_valid():
            user=form1.save()
            user.set_password(user.password)
            user.save()
            f2=form2.save(commit=False)
            f2.status=True
            f2.save()
            return redirect('admin-view-teacher')
    return render(request,'school/admin_update_teacher.html',context=mydict)


@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def admin_view_teacher_salary_view(request):
    teachers=models.TeacherExtra.objects.all()
    return render(request,'school/admin_view_teacher_salary.html',{'teachers':teachers})






#for student by adminnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn(by sumit)

@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def admin_student_view(request):
    return render(request,'school/admin_student.html')


@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def admin_add_student_view(request):
    form1=forms.StudentUserForm()
    form2=forms.StudentExtraForm()
    mydict={'form1':form1,'form2':form2}
    if request.method=='POST':
        form1=forms.StudentUserForm(request.POST)
        form2=forms.StudentExtraForm(request.POST)
        if form1.is_valid() and form2.is_valid():
            print("form is valid")
            user=form1.save()
            user.set_password(user.password)
            user.save()

            f2=form2.save(commit=False)
            f2.user=user
            f2.status=True
            f2.save()

            my_student_group = Group.objects.get_or_create(name='STUDENT')
            my_student_group[0].user_set.add(user)
        else:
            print("form is invalid")
        return HttpResponseRedirect('admin-student')
    return render(request,'school/admin_add_student.html',context=mydict)


@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def admin_view_student_view(request):
    students=models.StudentExtra.objects.all().filter(status=True)
    return render(request,'school/admin_view_student.html',{'students':students})


@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def delete_student_from_school_view(request,pk):
    student=models.StudentExtra.objects.get(id=pk)
    user=models.User.objects.get(id=student.user_id)
    user.delete()
    student.delete()
    return redirect('admin-view-student')


@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def delete_student_view(request,pk):
    student=models.StudentExtra.objects.get(id=pk)
    user=models.User.objects.get(id=student.user_id)
    user.delete()
    student.delete()
    return redirect('admin-approve-student')


@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def update_student_view(request,pk):
    student=models.StudentExtra.objects.get(id=pk)
    user=models.User.objects.get(id=student.user_id)
    form1=forms.StudentUserForm(instance=user)
    form2=forms.StudentExtraForm(instance=student)
    mydict={'form1':form1,'form2':form2}
    if request.method=='POST':
        form1=forms.StudentUserForm(request.POST,instance=user)
        form2=forms.StudentExtraForm(request.POST,instance=student)
        print(form1)
        if form1.is_valid() and form2.is_valid():
            user=form1.save()
            user.set_password(user.password)
            user.save()
            f2=form2.save(commit=False)
            f2.status=True
            f2.save()
            return redirect('admin-view-student')
    return render(request,'school/admin_update_student.html',context=mydict)



@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def admin_approve_student_view(request):
    students=models.StudentExtra.objects.all().filter(status=False)
    return render(request,'school/admin_approve_student.html',{'students':students})


@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def approve_student_view(request,pk):
    students=models.StudentExtra.objects.get(id=pk)
    students.status=True
    students.save()
    return redirect(reverse('admin-approve-student'))


@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def admin_view_student_fee_view(request):
    students=models.StudentExtra.objects.all()
    return render(request,'school/admin_view_student_fee.html',{'students':students})






#attendance related viewwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww(by sumit)
@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def admin_attendance_view(request):
    return render(request,'school/admin_attendance.html')


@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def admin_take_attendance_view(request,cl):
    students=models.StudentExtra.objects.all().filter(cl=cl)
    print(students)
    aform=forms.AttendanceForm()
    if request.method=='POST':
        form=forms.AttendanceForm(request.POST)
        if form.is_valid():
            Attendances=request.POST.getlist('present_status')
            date=form.cleaned_data['date']
            for i in range(len(Attendances)):
                AttendanceModel=models.Attendance()
                AttendanceModel.cl=cl
                AttendanceModel.date=date
                AttendanceModel.present_status=Attendances[i]
                AttendanceModel.roll=students[i].roll
                AttendanceModel.save()
            return redirect('admin-attendance')
        else:
            print('form invalid')
    return render(request,'school/admin_take_attendance.html',{'students':students,'aform':aform})



@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def admin_view_attendance_view(request,cl):
    form=forms.AskDateForm()
    if request.method=='POST':
        form=forms.AskDateForm(request.POST)
        if form.is_valid():
            date=form.cleaned_data['date']
            attendancedata=models.Attendance.objects.all().filter(date=date,cl=cl)
            studentdata=models.StudentExtra.objects.all().filter(cl=cl)
            mylist=zip(attendancedata,studentdata)
            return render(request,'school/admin_view_attendance_page.html',{'cl':cl,'mylist':mylist,'date':date})
        else:
            print('form invalid')
    return render(request,'school/admin_view_attendance_ask_date.html',{'cl':cl,'form':form})









#fee related view by adminnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn(by sumit)
@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def admin_fee_view(request):
    return render(request,'school/admin_fee.html')


@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def admin_view_fee_view(request,cl):
    feedetails=models.StudentExtra.objects.all().filter(cl=cl)
    return render(request,'school/admin_view_fee.html',{'feedetails':feedetails,'cl':cl})








#notice related viewsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss(by sumit)
@login_required(login_url='adminlogin')
@user_passes_test(is_admin)
def admin_notice_view(request):
    form=forms.NoticeForm()
    if request.method=='POST':
        form=forms.NoticeForm(request.POST)
        if form.is_valid():
            form=form.save(commit=False)
            form.by=request.user.first_name
            form.save()
            return redirect('admin-dashboard')
    return render(request,'school/admin_notice.html',{'form':form})








#for TEACHER  LOGIN    SECTIONNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN(by sumit)
@login_required(login_url='teacherlogin')
@user_passes_test(is_teacher)
def teacher_dashboard_view(request):
    teacherdata=models.TeacherExtra.objects.all().filter(status=True,user_id=request.user.id)
    notice=models.Notice.objects.all()
    mydict={
        'salary':teacherdata[0].salary,
        'mobile':teacherdata[0].mobile,
        'date':teacherdata[0].joindate,
        'notice':notice
    }
    return render(request,'school/teacher_dashboard.html',context=mydict)



@login_required(login_url='teacherlogin')
@user_passes_test(is_teacher)
def teacher_attendance_view(request):
    return render(request,'school/teacher_attendance.html')


@login_required(login_url='teacherlogin')
@user_passes_test(is_teacher)
def teacher_take_attendance_view(request,cl):
    students=models.StudentExtra.objects.all().filter(cl=cl)
    aform=forms.AttendanceForm()
    if request.method=='POST':
        form=forms.AttendanceForm(request.POST)
        if form.is_valid():
            Attendances=request.POST.getlist('present_status')
            date=form.cleaned_data['date']
            for i in range(len(Attendances)):
                AttendanceModel=models.Attendance()
                AttendanceModel.cl=cl
                AttendanceModel.date=date
                AttendanceModel.present_status=Attendances[i]
                AttendanceModel.roll=students[i].roll
                AttendanceModel.save()
            return redirect('teacher-attendance')
        else:
            print('form invalid')
    return render(request,'school/teacher_take_attendance.html',{'students':students,'aform':aform})



@login_required(login_url='teacherlogin')
@user_passes_test(is_teacher)
def teacher_view_attendance_view(request,cl):
    form=forms.AskDateForm()
    if request.method=='POST':
        form=forms.AskDateForm(request.POST)
        if form.is_valid():
            date=form.cleaned_data['date']
            attendancedata=models.Attendance.objects.all().filter(date=date,cl=cl)
            studentdata=models.StudentExtra.objects.all().filter(cl=cl)
            mylist=zip(attendancedata,studentdata)
            return render(request,'school/teacher_view_attendance_page.html',{'cl':cl,'mylist':mylist,'date':date})
        else:
            print('form invalid')
    return render(request,'school/teacher_view_attendance_ask_date.html',{'cl':cl,'form':form})



@login_required(login_url='teacherlogin')
@user_passes_test(is_teacher)
def teacher_notice_view(request):
    form=forms.NoticeForm()
    if request.method=='POST':
        form=forms.NoticeForm(request.POST)
        if form.is_valid():
            form=form.save(commit=False)
            form.by=request.user.first_name
            form.save()
            return redirect('teacher-dashboard')
        else:
            print('form invalid')
    return render(request,'school/teacher_notice.html',{'form':form})







#FOR STUDENT AFTER THEIR Loginnnnnnnnnnnnnnnnnnnnn(by sumit)
@login_required(login_url='studentlogin')
@user_passes_test(is_student)
def student_dashboard_view(request):
    studentdata=models.StudentExtra.objects.all().filter(status=True,user_id=request.user.id)
    notice=models.Notice.objects.all()
    mydict={
        'roll':studentdata[0].roll,
        'mobile':studentdata[0].mobile,
        'fee':studentdata[0].fee,
        'notice':notice
    }
    return render(request,'school/student_dashboard.html',context=mydict)



@login_required(login_url='studentlogin')
@user_passes_test(is_student)
def student_attendance_view(request):
    form=forms.AskDateForm()
    if request.method=='POST':
        form=forms.AskDateForm(request.POST)
        if form.is_valid():
            date=form.cleaned_data['date']
            studentdata=models.StudentExtra.objects.all().filter(user_id=request.user.id,status=True)
            attendancedata=models.Attendance.objects.all().filter(date=date,cl=studentdata[0].cl,roll=studentdata[0].roll)
            mylist=zip(attendancedata,studentdata)
            return render(request,'school/student_view_attendance_page.html',{'mylist':mylist,'date':date})
        else:
            print('form invalid')
    return render(request,'school/student_view_attendance_ask_date.html',{'form':form})









# for aboutus and contact ussssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss (by sumit)
def aboutus_view(request):
    return render(request,'school/aboutus.html')

def contactus_view(request):
    sub = forms.ContactusForm()
    if request.method == 'POST':
        sub = forms.ContactusForm(request.POST)
        if sub.is_valid():
            email = sub.cleaned_data['Email']
            name=sub.cleaned_data['Name']
            message = sub.cleaned_data['Message']
            send_mail(str(name)+' || '+str(email),message, EMAIL_HOST_USER, ['wapka1503@gmail.com'], fail_silently = False)
            return render(request, 'school/contactussuccess.html')
    return render(request, 'school/contactus.html', {'form':sub})

[(136, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (137, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (181, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (182, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (186, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (187, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (212, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (213, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (219, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (220, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (226, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (227, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (235, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (236, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (245, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (246, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (255, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (256, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (280, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (281, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (293, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (294, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (299, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (300, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (327, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (328, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (334, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (335, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (344, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (345, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (354, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (355, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (378, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (379, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (385, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (386, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (394, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (395, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (406, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (407, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (412, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (413, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (437, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (438, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (462, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (463, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (468, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (469, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (482, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""adminlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (483, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_admin'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (503, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""teacherlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (504, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_teacher'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (518, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""teacherlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (519, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_teacher'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (524, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""teacherlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (525, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_teacher'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (548, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""teacherlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (549, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_teacher'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (566, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""teacherlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (567, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_teacher'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (588, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""studentlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (589, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_student'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (603, 'django.contrib.auth.decorators.login_required', 'login_required', ([], {'login_url': '"""studentlogin"""'}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (604, 'django.contrib.auth.decorators.user_passes_test', 'user_passes_test', (['is_student'], {}), False, 'from django.contrib.auth.decorators import login_required, user_passes_test\n'), (11, 'django.shortcuts.render', 'render', (['request', '"""school/index.html"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (19, 'django.shortcuts.render', 'render', (['request', '"""school/adminclick.html"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (26, 'django.shortcuts.render', 'render', (['request', '"""school/teacherclick.html"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (33, 'django.shortcuts.render', 'render', (['request', '"""school/studentclick.html"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (53, 'django.shortcuts.render', 'render', (['request', '"""school/adminsignup.html"""', "{'form': form}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (77, 'django.shortcuts.render', 'render', (['request', '"""school/studentsignup.html"""'], {'context': 'mydict'}), False, 'from django.shortcuts import render, redirect, reverse\n'), (99, 'django.shortcuts.render', 'render', (['request', '"""school/teachersignup.html"""'], {'context': 'mydict'}), False, 'from django.shortcuts import render, redirect, reverse\n'), (171, 'django.shortcuts.render', 'render', (['request', '"""school/admin_dashboard.html"""'], {'context': 'mydict'}), False, 'from django.shortcuts import render, redirect, reverse\n'), (184, 'django.shortcuts.render', 'render', (['request', '"""school/admin_teacher.html"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (209, 'django.shortcuts.render', 'render', (['request', '"""school/admin_add_teacher.html"""'], {'context': 'mydict'}), False, 'from django.shortcuts import render, redirect, reverse\n'), (216, 'django.shortcuts.render', 'render', (['request', '"""school/admin_view_teacher.html"""', "{'teachers': teachers}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (223, 'django.shortcuts.render', 'render', (['request', '"""school/admin_approve_teacher.html"""', "{'teachers': teachers}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (242, 'django.shortcuts.redirect', 'redirect', (['"""admin-approve-teacher"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (252, 'django.shortcuts.redirect', 'redirect', (['"""admin-view-teacher"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (277, 'django.shortcuts.render', 'render', (['request', '"""school/admin_update_teacher.html"""'], {'context': 'mydict'}), False, 'from django.shortcuts import render, redirect, reverse\n'), (284, 'django.shortcuts.render', 'render', (['request', '"""school/admin_view_teacher_salary.html"""', "{'teachers': teachers}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (296, 'django.shortcuts.render', 'render', (['request', '"""school/admin_student.html"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (324, 'django.shortcuts.render', 'render', (['request', '"""school/admin_add_student.html"""'], {'context': 'mydict'}), False, 'from django.shortcuts import render, redirect, reverse\n'), (331, 'django.shortcuts.render', 'render', (['request', '"""school/admin_view_student.html"""', "{'students': students}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (341, 'django.shortcuts.redirect', 'redirect', (['"""admin-view-student"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (351, 'django.shortcuts.redirect', 'redirect', (['"""admin-approve-student"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (374, 'django.shortcuts.render', 'render', (['request', '"""school/admin_update_student.html"""'], {'context': 'mydict'}), False, 'from django.shortcuts import render, redirect, reverse\n'), (382, 'django.shortcuts.render', 'render', (['request', '"""school/admin_approve_student.html"""', "{'students': students}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (398, 'django.shortcuts.render', 'render', (['request', '"""school/admin_view_student_fee.html"""', "{'students': students}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (409, 'django.shortcuts.render', 'render', (['request', '"""school/admin_attendance.html"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (433, 'django.shortcuts.render', 'render', (['request', '"""school/admin_take_attendance.html"""', "{'students': students, 'aform': aform}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (451, 'django.shortcuts.render', 'render', (['request', '"""school/admin_view_attendance_ask_date.html"""', "{'cl': cl, 'form': form}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (465, 'django.shortcuts.render', 'render', (['request', '"""school/admin_fee.html"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (472, 'django.shortcuts.render', 'render', (['request', '"""school/admin_view_fee.html"""', "{'feedetails': feedetails, 'cl': cl}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (493, 'django.shortcuts.render', 'render', (['request', '"""school/admin_notice.html"""', "{'form': form}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (514, 'django.shortcuts.render', 'render', (['request', '"""school/teacher_dashboard.html"""'], {'context': 'mydict'}), False, 'from django.shortcuts import render, redirect, reverse\n'), (521, 'django.shortcuts.render', 'render', (['request', '"""school/teacher_attendance.html"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (544, 'django.shortcuts.render', 'render', (['request', '"""school/teacher_take_attendance.html"""', "{'students': students, 'aform': aform}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (562, 'django.shortcuts.render', 'render', (['request', '"""school/teacher_view_attendance_ask_date.html"""', "{'cl': cl, 'form': form}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (579, 'django.shortcuts.render', 'render', (['request', '"""school/teacher_notice.html"""', "{'form': form}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (599, 'django.shortcuts.render', 'render', (['request', '"""school/student_dashboard.html"""'], {'context': 'mydict'}), False, 'from django.shortcuts import render, redirect, reverse\n'), (617, 'django.shortcuts.render', 'render', (['request', '"""school/student_view_attendance_ask_date.html"""', "{'form': form}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (629, 'django.shortcuts.render', 'render', (['request', '"""school/aboutus.html"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (641, 'django.shortcuts.render', 'render', (['request', '"""school/contactus.html"""', "{'form': sub}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (10, 'django.http.HttpResponseRedirect', 'HttpResponseRedirect', (['"""afterlogin"""'], {}), False, 'from django.http import HttpResponseRedirect\n'), (18, 'django.http.HttpResponseRedirect', 'HttpResponseRedirect', (['"""afterlogin"""'], {}), False, 'from django.http import HttpResponseRedirect\n'), (25, 'django.http.HttpResponseRedirect', 'HttpResponseRedirect', (['"""afterlogin"""'], {}), False, 'from django.http import HttpResponseRedirect\n'), (32, 'django.http.HttpResponseRedirect', 'HttpResponseRedirect', (['"""afterlogin"""'], {}), False, 'from django.http import HttpResponseRedirect\n'), (76, 'django.http.HttpResponseRedirect', 'HttpResponseRedirect', (['"""studentlogin"""'], {}), False, 'from django.http import HttpResponseRedirect\n'), (98, 'django.http.HttpResponseRedirect', 'HttpResponseRedirect', (['"""teacherlogin"""'], {}), False, 'from django.http import HttpResponseRedirect\n'), (117, 'django.shortcuts.redirect', 'redirect', (['"""admin-dashboard"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (145, 'django.db.models.Sum', 'Sum', (['"""salary"""'], {}), False, 'from django.db.models import Sum\n'), (146, 'django.db.models.Sum', 'Sum', (['"""salary"""'], {}), False, 'from django.db.models import Sum\n'), (148, 'django.db.models.Sum', 'Sum', (['"""fee"""'], {'default': '(0)'}), False, 'from django.db.models import Sum\n'), (149, 'django.db.models.Sum', 'Sum', (['"""fee"""'], {}), False, 'from django.db.models import Sum\n'), (208, 'django.http.HttpResponseRedirect', 'HttpResponseRedirect', (['"""admin-teacher"""'], {}), False, 'from django.http import HttpResponseRedirect\n'), (232, 'django.shortcuts.reverse', 'reverse', (['"""admin-approve-teacher"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (323, 'django.http.HttpResponseRedirect', 'HttpResponseRedirect', (['"""admin-student"""'], {}), False, 'from django.http import HttpResponseRedirect\n'), (391, 'django.shortcuts.reverse', 'reverse', (['"""admin-approve-student"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (49, 'django.contrib.auth.models.Group.objects.get_or_create', 'Group.objects.get_or_create', ([], {'name': '"""ADMIN"""'}), False, 'from django.contrib.auth.models import Group\n'), (52, 'django.http.HttpResponseRedirect', 'HttpResponseRedirect', (['"""adminlogin"""'], {}), False, 'from django.http import HttpResponseRedirect\n'), (73, 'django.contrib.auth.models.Group.objects.get_or_create', 'Group.objects.get_or_create', ([], {'name': '"""STUDENT"""'}), False, 'from django.contrib.auth.models import Group\n'), (95, 'django.contrib.auth.models.Group.objects.get_or_create', 'Group.objects.get_or_create', ([], {'name': '"""TEACHER"""'}), False, 'from django.contrib.auth.models import Group\n'), (205, 'django.contrib.auth.models.Group.objects.get_or_create', 'Group.objects.get_or_create', ([], {'name': '"""TEACHER"""'}), False, 'from django.contrib.auth.models import Group\n'), (276, 'django.shortcuts.redirect', 'redirect', (['"""admin-view-teacher"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (319, 'django.contrib.auth.models.Group.objects.get_or_create', 'Group.objects.get_or_create', ([], {'name': '"""STUDENT"""'}), False, 'from django.contrib.auth.models import Group\n'), (373, 'django.shortcuts.redirect', 'redirect', (['"""admin-view-student"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (430, 'django.shortcuts.redirect', 'redirect', (['"""admin-attendance"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (448, 'django.shortcuts.render', 'render', (['request', '"""school/admin_view_attendance_page.html"""', "{'cl': cl, 'mylist': mylist, 'date': date}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (492, 'django.shortcuts.redirect', 'redirect', (['"""admin-dashboard"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (541, 'django.shortcuts.redirect', 'redirect', (['"""teacher-attendance"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (559, 'django.shortcuts.render', 'render', (['request', '"""school/teacher_view_attendance_page.html"""', "{'cl': cl, 'mylist': mylist, 'date': date}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (576, 'django.shortcuts.redirect', 'redirect', (['"""teacher-dashboard"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (614, 'django.shortcuts.render', 'render', (['request', '"""school/student_view_attendance_page.html"""', "{'mylist': mylist, 'date': date}"], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (640, 'django.shortcuts.render', 'render', (['request', '"""school/contactussuccess.html"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (121, 'django.shortcuts.redirect', 'redirect', (['"""teacher-dashboard"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (123, 'django.shortcuts.render', 'render', (['request', '"""school/teacher_wait_for_approval.html"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (127, 'django.shortcuts.redirect', 'redirect', (['"""student-dashboard"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n'), (129, 'django.shortcuts.render', 'render', (['request', '"""school/student_wait_for_approval.html"""'], {}), False, 'from django.shortcuts import render, redirect, reverse\n')]