diff --git a/auth/__pycache__/settings.cpython-38.pyc b/auth/__pycache__/settings.cpython-38.pyc index c17698e..bad9302 100644 Binary files a/auth/__pycache__/settings.cpython-38.pyc and b/auth/__pycache__/settings.cpython-38.pyc differ diff --git a/auth/settings.py b/auth/settings.py index 6f63fc7..ac1deb6 100644 --- a/auth/settings.py +++ b/auth/settings.py @@ -77,6 +77,7 @@ 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], + }, }, ] diff --git a/db.sqlite3 b/db.sqlite3 index ca11a29..19692bb 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/home/__pycache__/models.cpython-38.pyc b/home/__pycache__/models.cpython-38.pyc index 8e0936e..e584f49 100644 Binary files a/home/__pycache__/models.cpython-38.pyc and b/home/__pycache__/models.cpython-38.pyc differ diff --git a/home/__pycache__/urls.cpython-38.pyc b/home/__pycache__/urls.cpython-38.pyc index 4e0183a..d8e63fc 100644 Binary files a/home/__pycache__/urls.cpython-38.pyc and b/home/__pycache__/urls.cpython-38.pyc differ diff --git a/home/__pycache__/views.cpython-38.pyc b/home/__pycache__/views.cpython-38.pyc index 8736bfc..8b0486f 100644 Binary files a/home/__pycache__/views.cpython-38.pyc and b/home/__pycache__/views.cpython-38.pyc differ diff --git a/home/migrations/0010_studentdata_letter.py b/home/migrations/0010_studentdata_letter.py new file mode 100644 index 0000000..fc3477e --- /dev/null +++ b/home/migrations/0010_studentdata_letter.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1 on 2021-08-10 17:30 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0009_auto_20210809_2008'), + ] + + operations = [ + migrations.AddField( + model_name='studentdata', + name='letter', + field=models.CharField(blank=True, max_length=20000, null=True), + ), + ] diff --git a/home/migrations/__pycache__/0010_studentdata_letter.cpython-38.pyc b/home/migrations/__pycache__/0010_studentdata_letter.cpython-38.pyc new file mode 100644 index 0000000..355d9f0 Binary files /dev/null and b/home/migrations/__pycache__/0010_studentdata_letter.cpython-38.pyc differ diff --git a/home/models.py b/home/models.py index f9984cf..a7b0b76 100644 --- a/home/models.py +++ b/home/models.py @@ -49,7 +49,7 @@ class StudentData(models.Model): paper_link = models.CharField(max_length=200,default="null") subjects= models.CharField(max_length=500, null=True, blank=True) - + letter=models.CharField(max_length=20000,null=True,blank=True) # teacher side presentation= models.CharField(max_length=15,null=True,blank=True) diff --git a/home/urls.py b/home/urls.py index 477a415..bdfd717 100644 --- a/home/urls.py +++ b/home/urls.py @@ -31,6 +31,10 @@ path('changePhone', views.changePhone, name='changePhone'), path('changeEmail', views.changeEmail, name='changeEmail'), path('getdetails', views.getdetails, name='getdetails'), + path('edit', views.edit, name='edit'), + path('testing', views.testing, name='testing'), + + diff --git a/home/views.py b/home/views.py index 8b384ac..8e55368 100644 --- a/home/views.py +++ b/home/views.py @@ -1,347 +1,419 @@ import datetime from django.db.models.fields import DateTimeField -from django.shortcuts import render , redirect,get_object_or_404 +from django.shortcuts import render, redirect, get_object_or_404 from django.contrib.auth.decorators import login_required # check old password and new password from django.contrib.auth.hashers import check_password from django.contrib.auth.models import User -from django.contrib.auth import logout , authenticate , login +from django.contrib.auth import logout, authenticate, login from django.contrib.auth.forms import AuthenticationForm from .models import * from django.contrib import messages import json + # imports from xhtml from django.http import HttpResponse from django.template.loader import get_template from xhtml2pdf import pisa -#serializers helps to convert queryset into json strings +# serializers helps to convert queryset into json strings from django.core import serializers -#sending email +# sending email from django.core.mail import send_mail -#to send mail to admin + +# to send mail to admin from django.core.mail import mail_admins -#to create random number for OTP +# to create random number for OTP from random import randint # Create your views here. + def index(request): - return render(request, 'index.html') + return render(request, "index.html") + def gallery(request): - return render(request,'gallery.html') + return render(request, "gallery.html") -### xhtml2pdf -def final(request, *args, **kwargs): - if request.method=="POST": - roll=request.POST.get('roll') - barsa= request.POST.get('yrs') - presentation= request.POST.get('presentation') - quality1 = request.POST.get('quality1') - quality2 = request.POST.get('quality2') - eca = request.POST.get('eca') - project = request.POST.get('project') - paper = request.POST.get('paper') - student = StudentData.objects.get(std__roll_number = roll) - student.years_taught=barsa - student.presentation= presentation - student.quality1 = quality1 - student.quality2 = quality2 - student.eca = eca - student.project = project - student.paper = paper - student.is_generated=True - student.save() - send_mail('Recommendation Letter', 'congratulation you recieved recommendation letter ,http://127.0.0.1:8000/loginStudent', 'christronaldo9090909@gmail.com', [student.email], fail_silently=False) +import textwrap +from fpdf import FPDF +from io import BytesIO as bio +import fs - - template_path = 'print.html' - context={'student':student } +def text_to_pdf(text,roll): + a4_width_mm = 270 + pt_to_mm = 0.35 + fontsize_pt = 11 + fontsize_mm = fontsize_pt * pt_to_mm + margin_bottom_mm = 10 + character_width_mm = 7 * pt_to_mm + width_text = (a4_width_mm / 1*character_width_mm) + pdf = FPDF(orientation="P", unit="mm", format="Letter") + pdf.set_auto_page_break(True, margin=margin_bottom_mm) + pdf.add_page() + pdf.set_font("Arial", 'B', size=fontsize_pt*1.2) + pdf.cell(0, 10,"Letter of Recommendation ",align='C') + pdf.set_y(15) + pdf.set_font(family="Arial", size=fontsize_pt) + + splitted = text.split("\n") + a=0 + for line in splitted: + lines = textwrap.wrap(line, width_text*0.95) + + if a==0: + if len(lines) == 0: + pdf.ln() + a=a+1 + continue + else: + if len(lines) == 0: + continue + + - # Create a Django response object, and specify content_type as pdf - response = HttpResponse(content_type='application/pdf') + for wrap in lines: + pdf.set_right_margin(25) - ## If Download -# response['Content-Disposition'] = 'attachment; filename="report.pdf"' - ## If view - response['Content-Disposition'] = 'filename="your_letter.pdf"' + pdf.set_x(25) + pdf.multi_cell(0, fontsize_mm, wrap) + a=a-1 + - # find the template and render it. - template = get_template(template_path) - html = template.render(context) - # create a pdf - pisa_status = pisa.CreatePDF( - html, dest=response) - # if error then show some funy view - if pisa_status.err: - return HttpResponse('We had some errors
' + html + '
') - return response + + pdf.output("media/letter/"+roll+".pdf", "F") +import re + ### xhtml2pdf -def studentfinal(request, *args, **kwargs): - if request.method=="POST": - roll=request.POST.get('roll') - student = StudentData.objects.get(std__roll_number = roll) - +def final(request, *args, **kwargs): + if request.method == "POST": + textarea1 = request.POST.get("textarea1") + roll = request.POST.get("roll") + student = StudentData.objects.get(std__roll_number=roll) + + # textarea2 = request.POST.get("textarea2") + # textarea3 = request.POST.get("textarea3") + letter=f''' + \n{textarea1} + ''' + text_to_pdf(letter,roll) + student.is_generated = True + student.save() + send_mail('Recommendation Letter', 'congratulation you recieved recommendation letter ,http://127.0.0.1:8000/loginStudent', 'christronaldo9090909@gmail.com', [student.email], fail_silently=False) + return redirect("media/letter/"+roll+".pdf") - template_path = 'print.html' - context={'student':student } - - - # Create a Django response object, and specify content_type as pdf - response = HttpResponse(content_type='application/pdf') - - ##If Download - response['Content-Disposition'] = 'attachment; filename="report.pdf"' - ## If view - #response['Content-Disposition'] = 'filename="your_letter.pdf"' - - # find the template and render it. - template = get_template(template_path) - html = template.render(context) - - # create a pdf - pisa_status = pisa.CreatePDF( - html, dest=response) - # if error then show some funy view - if pisa_status.err: - return HttpResponse('We had some errors
' + html + '
') - return response +# %% +# %% + + + +def studentfinal(request, *args, **kwargs): + if request.method == "POST": + roll = request.POST.get("roll") + print(roll) + return redirect("media/letter/"+roll+".pdf") + def loginStudent(request): - if request.method=="POST": - usern=request.POST.get('name') - roll= request.POST.get('roll') - dob= request.POST.get('dob') + if request.method == "POST": + usern = request.POST.get("name") + roll = request.POST.get("roll") + dob = request.POST.get("dob") if StudentLoginInfo.objects.filter(username__exact=usern).exists(): student = StudentLoginInfo.objects.get(roll_number__exact=roll) - if (student.username==usern and str(student.dob)==dob): - teachers = TeacherInfo.objects.filter(department = student.department) + if student.username == usern and str(student.dob) == dob: + teachers = TeacherInfo.objects.filter(department=student.department) if StudentData.objects.filter(std__roll_number=roll).exists(): stdnt = StudentData.objects.get(std__roll_number=roll) - return render(request,"student_success.html",{'naam': student.username,"roll":student.roll_number,'letter':stdnt.is_generated}) + return render( + request, + "student_success.html", + { + "naam": student.username, + "roll": student.roll_number, + "letter": stdnt.is_generated, + }, + ) else: - return render(request,'Student.html',{'naam': student.username , 'teachers':teachers,"roll":student.roll_number}) - + return render( + request, + "Student.html", + { + "naam": student.username, + "teachers": teachers, + "roll": student.roll_number, + }, + ) + else: - messages.error(request, 'Sorry! The Credentials doesnot match.') - return render(request, 'loginStudent.html') + messages.error(request, "Sorry! The Credentials doesnot match.") + return render(request, "loginStudent.html") else: - messages.error(request,'Seems Like You are not the student of Pulchowk') - return render(request, 'loginStudent.html') - return render(request, 'loginStudent.html') + messages.error(request, "Seems Like You are not the student of Pulchowk") + return render(request, "loginStudent.html") + return render(request, "loginStudent.html") -@login_required(login_url='/loginTeacher') + +@login_required(login_url="/loginTeacher") def make_letter(request): - if request.method=="POST": - roll=request.POST.get('roll') - - - teacher_id=request.COOKIES.get('unique') - teacher_model=TeacherInfo.objects.get(unique_id=teacher_id) + if request.method == "POST": + roll = request.POST.get("roll") + + teacher_id = request.COOKIES.get("unique") + teacher_model = TeacherInfo.objects.get(unique_id=teacher_id) stu = StudentLoginInfo.objects.get(roll_number=roll) student = StudentData.objects.get(name=stu.username) - teacher_name =student.professor.name - - return render(request, 'formTeacher.html',{'student':student, 'roll':roll,'teacher':teacher_name,'teacher_model':teacher_model}) + teacher_name = student.professor.name + return render( + request, + "formTeacher.html", + { + "student": student, + "roll": roll, + "teacher": teacher_name, + "teacher_model": teacher_model, + }, + ) def studentSuccess(request): - if request.method=="POST": - uuni= request.POST.get('university') - uprof= request.POST.get('prof') - uroll= request.POST.get('roll') - uemail= request.POST.get('email') - ugpa= request.POST.get('gpa') - is_project= request.POST.get('is_project') - f_project= request.POST.get('fproject') - pro1= request.POST.get('pro1') - pro2= request.POST.get('pro2') - is_paper= request.POST.get('is_paper') - paper= request.POST.get('paper') - subjects=Subject.objects.all() - bisaya=[] - i=0 + if request.method == "POST": + uuni = request.POST.get("university") + uprof = request.POST.get("prof") + uroll = request.POST.get("roll") + uemail = request.POST.get("email") + ugpa = request.POST.get("gpa") + is_project = request.POST.get("is_project") + known_year = request.POST.get("yrs") + f_project = request.POST.get("fproject") + pro1 = request.POST.get("pro1") + pro2 = request.POST.get("pro2") + is_paper = request.POST.get("is_paper") + paper = request.POST.get("paper") + subjects = Subject.objects.all() + bisaya = [] + i = 0 for subject in subjects: - if request.POST.get('subject'+str(i)) is not None: - bisaya.append(request.POST.get('subject'+str(i))) - i=i+1 - listToStr = ','.join([str(elem) for elem in bisaya]) + if request.POST.get("subject" + str(i)) is not None: + bisaya.append(request.POST.get("subject" + str(i))) + i = i + 1 + listToStr = ",".join([str(elem) for elem in bisaya]) print(listToStr) - x= uprof.split("|") - id=x[-1] - prof = TeacherInfo.objects.get(unique_id = id) - stu = StudentLoginInfo.objects.get(roll_number = uroll) - - info = StudentData(name=stu.username , uni=uuni, professor=prof ,std = stu,email=uemail , - gpa=ugpa, is_pro = is_project, final_project=f_project, project1=pro1, project2 = pro2, - paper=is_paper, paper_link = paper,subjects=listToStr) + x = uprof.split("|") + id = x[-1] + prof = TeacherInfo.objects.get(unique_id=id) + stu = StudentLoginInfo.objects.get(roll_number=uroll) + + info = StudentData( + name=stu.username, + uni=uuni, + professor=prof, + std=stu, + email=uemail, + gpa=ugpa, + is_pro=is_project, + final_project=f_project, + project1=pro1, + project2=pro2, + paper=is_paper, + paper_link=paper, + subjects=listToStr, + years_taught=known_year, + ) info.save() - return render(request,"student_success.html") + return render(request, "student_success.html",{'roll':uroll}) def loginTeacher(request): - value=0 - if request.method=="POST": - usern=request.POST.get('username') - passwo= request.POST.get('password') - # check if user is real + value = 0 + if request.method == "POST": + usern = request.POST.get("username") + passwo = request.POST.get("password") + # check if user is real if User.objects.filter(username__exact=usern).exists(): user = authenticate(username=usern, password=passwo) if user is not None: - - login(request,user) + + login(request, user) full_name = request.user.get_full_name() x = full_name.split("/") - unique=x[-1] + unique = x[-1] # name = x[0] - teacher_model=TeacherInfo.objects.get(unique_id=unique) - dataharu = StudentData.objects.filter( professor__unique_id=unique) - number=len(dataharu) - #to check if there is request or not on teachers page + teacher_model = TeacherInfo.objects.get(unique_id=unique) + dataharu = StudentData.objects.filter(professor__unique_id=unique) + number = len(dataharu) + # to check if there is request or not on teachers page for data in dataharu: if data.is_generated: - value+=1 - datakolength=len(dataharu) - if datakolength==value: - check_value=True + value += 1 + datakolength = len(dataharu) + if datakolength == value: + check_value = True else: - check_value=False + check_value = False # to convert database to json objects - std_dataharu=serializers.serialize("json",StudentData.objects.filter( professor__unique_id=unique)) - non_generated = StudentData.objects.filter(is_generated=False , professor__unique_id=unique) - - response=render(request, 'Teacher.html',{'all_students':dataharu,'student_list':non_generated,'check_value':check_value,'teacher_number':number,'std_dataharu':std_dataharu,'teacher_model':teacher_model}) - response.set_cookie('unique',unique) - response.set_cookie('username',user.username) + std_dataharu = serializers.serialize( + "json", StudentData.objects.filter(professor__unique_id=unique) + ) + non_generated = StudentData.objects.filter( + is_generated=False, professor__unique_id=unique + ) + + response = render( + request, + "Teacher.html", + { + "all_students": dataharu, + "student_list": non_generated, + "check_value": check_value, + "teacher_number": number, + "std_dataharu": std_dataharu, + "teacher_model": teacher_model, + }, + ) + response.set_cookie("unique", unique) + response.set_cookie("username", user.username) return response - # A backend authenticated the credentials + # A backend authenticated the credentials else: - # No backend authenticated the credentials - messages.error(request, 'Sorry! The Password doesnot match.') - return render(request, 'loginTeacher.html') + # No backend authenticated the credentials + messages.error(request, "Sorry! The Password doesnot match.") + return render(request, "loginTeacher.html") else: - - messages.error(request, 'You are not registered as a professor.') - return render(request, 'loginTeacher.html') - return render(request, 'loginTeacher.html') - - - - + messages.error(request, "You are not registered as a professor.") + return render(request, "loginTeacher.html") + return render(request, "loginTeacher.html") def logoutUser(request): logout(request) return redirect("/") + def forgotPassword(request): - #generating otp so that it is generated only once - OTP_value=OTP_generator(5) - response= render(request, 'forgotPassword.html') - response.set_cookie('OTP_value',OTP_value) + # generating otp so that it is generated only once + OTP_value = OTP_generator(5) + response = render(request, "forgotPassword.html") + response.set_cookie("OTP_value", OTP_value) return response + def forgotUsername(request): - #generating otp so that it is generated only once - OTP_value=OTP_generator(5) - response= render(request, 'forgotUsername.html') - response.set_cookie('OTP_value',OTP_value) + # generating otp so that it is generated only once + OTP_value = OTP_generator(5) + response = render(request, "forgotUsername.html") + response.set_cookie("OTP_value", OTP_value) return response # check email of username is valid or not def checkEmail(request): - if request.method=="POST": + if request.method == "POST": - email=request.POST.get('user_email') + email = request.POST.get("user_email") if User.objects.filter(email__exact=email).exists(): user = User.objects.get(email__exact=email) - send_mail('UserName ', 'Your username is '+user.username,'christronaldo9090909@gmail.com', [email], fail_silently=False) - messages.success(request, 'Username has been sent to your gmail.') - return redirect('loginTeacher') + send_mail( + "UserName ", + "Your username is " + user.username, + "christronaldo9090909@gmail.com", + [email], + fail_silently=False, + ) + messages.success(request, "Username has been sent to your gmail.") + return redirect("loginTeacher") else: - messages.error(request, 'Email is not registered.') - return redirect('loginTeacher') - return redirect('loginTeacher') + messages.error(request, "Email is not registered.") + return redirect("loginTeacher") + return redirect("loginTeacher") # OTP def otp(request): - - if request.method=="POST" : - Usernaam=request.POST.get('username') - if User.objects.filter(username = Usernaam).exists(): - sir= User.objects.get(username = Usernaam) + + if request.method == "POST": + Usernaam = request.POST.get("username") + if User.objects.filter(username=Usernaam).exists(): + sir = User.objects.get(username=Usernaam) full_name = sir.get_full_name() - x=full_name.split("/") - name=x[0] - id=x[-1] - + x = full_name.split("/") + name = x[0] + id = x[-1] + if TeacherInfo.objects.filter(unique_id=id).exists(): master = TeacherInfo.objects.get(unique_id=id) - - OTP_value=request.COOKIES.get('OTP_value') - - send_mail('OTP ', 'Your OTP for Recoomendation Letter is '+ str(OTP_value),'christronaldo9090909@gmail.com', [master.email], fail_silently=False) - - response= render(request, 'otp.html',{'teacherkonam':master,'OTP_value':OTP_value}) - #making cookies to store and send them to other view page - - response.set_cookie('teacher_ko_naam',master) - response.set_cookie('teacher_ko_user',Usernaam) + + OTP_value = request.COOKIES.get("OTP_value") + + send_mail( + "OTP ", + "Your OTP for Recoomendation Letter is " + str(OTP_value), + "christronaldo9090909@gmail.com", + [master.email], + fail_silently=False, + ) + + response = render( + request, + "otp.html", + {"teacherkonam": master, "OTP_value": OTP_value}, + ) + # making cookies to store and send them to other view page + + response.set_cookie("teacher_ko_naam", master) + response.set_cookie("teacher_ko_user", Usernaam) return response else: - messages.error(request, 'Sorry You are not registered as a Professor.') - return render(request, 'loginTeacher.html') - - + messages.error(request, "Sorry You are not registered as a Professor.") + return render(request, "loginTeacher.html") else: - messages.error(request, 'Sorry You are not registered as a Professor.') - return render(request, 'loginTeacher.html') - - + messages.error(request, "Sorry You are not registered as a Professor.") + return render(request, "loginTeacher.html") + + # Otp check def OTP_check(request): - if request.method=="POST": - user_OTP_value=request.POST.get('user_typed_OTP_value') - - #using cookies to obtain otp value and teacher - OTP_value=request.COOKIES.get('OTP_value') - teacher_ko_naam=request.COOKIES.get('teacher_ko_naam') + if request.method == "POST": + user_OTP_value = request.POST.get("user_typed_OTP_value") + # using cookies to obtain otp value and teacher + OTP_value = request.COOKIES.get("OTP_value") + teacher_ko_naam = request.COOKIES.get("teacher_ko_naam") - if OTP_value==user_OTP_value: - return render(request, 'validatePassword.html',{'teacher_ko_naam':teacher_ko_naam}) + if OTP_value == user_OTP_value: + return render( + request, "validatePassword.html", {"teacher_ko_naam": teacher_ko_naam} + ) else: - messages.error(request, 'Wrong OTP_value') - return render(request, 'loginTeacher.html') + messages.error(request, "Wrong OTP_value") + return render(request, "loginTeacher.html") # #to pass the username and to validate the user @@ -352,235 +424,333 @@ def OTP_check(request): # return render(request, 'validatePassword.html',{'teacher_ko_naam':teacher_ko_naam, 'OTP_value':OTP_value}) -#pwd is changed of corresponding user passed from validatePassword +# pwd is changed of corresponding user passed from validatePassword def changePassword(request): - - if request.method=="POST" : - password1=request.POST.get('password1') - password2=request.POST.get('password2') - - if password1==password2: - #Teacher ko Username using cookies from 'otp' view page - teacher_ko_user_naam=request.COOKIES.get('teacher_ko_user') - #changing Pwd + if request.method == "POST": + password1 = request.POST.get("password1") + password2 = request.POST.get("password2") + + if password1 == password2: + # Teacher ko Username using cookies from 'otp' view page + teacher_ko_user_naam = request.COOKIES.get("teacher_ko_user") + + # changing Pwd usr = User.objects.get(username=teacher_ko_user_naam) usr.set_password(password1) usr.save() - messages.success(request, 'Password has been changed successfully.') - return render(request, 'loginTeacher.html') + messages.success(request, "Password has been changed successfully.") + return render(request, "loginTeacher.html") else: - - return render(request, 'validatePassword.html') - + return render(request, "validatePassword.html") def OTP_generator(n): - range_start = 10**(n-1) - range_end = (10**n)-1 - return randint(range_start, range_end) - + range_start = 10 ** (n - 1) + range_end = (10 ** n) - 1 + return randint(range_start, range_end) -#to pass message to admin user + +# to pass message to admin user def contact(request): - - return render(request, 'contact.html') + + return render(request, "contact.html") + def about(request): - - return render(request, 'about.html') + + return render(request, "about.html") + def feedback(request): - - if request.method=="POST": - First_name =request.POST.get('first_name') - last_name =request.POST.get('last_name') - email =request.POST.get('email') - feedback =request.POST.get('feedback') - message =str(First_name)+"\n"+str(last_name)+"\n"+str(email)+"\n"+str(feedback) + if request.method == "POST": + First_name = request.POST.get("first_name") + last_name = request.POST.get("last_name") + email = request.POST.get("email") + feedback = request.POST.get("feedback") + + message = ( + str(First_name) + + "\n" + + str(last_name) + + "\n" + + str(email) + + "\n" + + str(feedback) + ) + + mail_admins( + "Feedback", message, fail_silently=False, connection=None, html_message=None + ) + send_mail( + "Reply From Recoomendation Letter Team", + "Thank you for your feedback. We will get back to you soon.", + " christronaldo9090909@gmail.com", + [email], + fail_silently=False, + ) + messages.success(request, "Your message has been sent.") + return render(request, "contact.html") - mail_admins("Feedback", message, fail_silently=False, connection=None, html_message=None) - send_mail("Reply From Recoomendation Letter Team", "Thank you for your feedback. We will get back to you soon.", " christronaldo9090909@gmail.com",[email],fail_silently=False) - messages.success(request, 'Your message has been sent.') - return render(request, 'contact.html') def userDetails(request): - unique=request.COOKIES.get('unique') - teacherkonam=TeacherInfo.objects.get(unique_id=unique) - email=teacherkonam.email - username=User.objects.get(email=email) + unique = request.COOKIES.get("unique") + teacherkonam = TeacherInfo.objects.get(unique_id=unique) + email = teacherkonam.email + username = User.objects.get(email=email) + + return render( + request, + "userDetails.html", + {"teacher_username": username, "teacher": teacherkonam}, + ) - return render(request, 'userDetails.html',{'teacher_username':username,'teacher':teacherkonam}) - - def profileUpdate(request): - unique=request.COOKIES.get('unique') - teacherkonam=TeacherInfo.objects.get(unique_id=unique) + unique = request.COOKIES.get("unique") + teacherkonam = TeacherInfo.objects.get(unique_id=unique) - return render(request, 'profileUpdate.html',{'teacher':teacherkonam}) + return render(request, "profileUpdate.html", {"teacher": teacherkonam}) def profileUpdateRequest(request): - unique=request.COOKIES.get('unique') + unique = request.COOKIES.get("unique") + + if request.method == "POST": + photo = request.FILES["file"] - if request.method=="POST": - photo=request.FILES['file'] - # TeacherInfo.objects.filter(unique_id=unique).update(images=photo) - teacherkonam=TeacherInfo.objects.get(unique_id=unique) - teacherkonam.images=photo + teacherkonam = TeacherInfo.objects.get(unique_id=unique) + teacherkonam.images = photo teacherkonam.save() - - return render(request, 'userDetails.html',{'teacher':teacherkonam}) + + return render(request, "userDetails.html", {"teacher": teacherkonam}) def changeUsername(request): - if request.method=="POST": - old_username=request.POST.get('old_username') - new_username=request.POST.get('new_username') - + if request.method == "POST": + old_username = request.POST.get("old_username") + new_username = request.POST.get("new_username") if User.objects.filter(username=old_username).exists(): if User.objects.filter(username=new_username).exists(): - messages.error(request, 'Username already exists.') + messages.error(request, "Username already exists.") return redirect(userDetails) - - user = User.objects.get(username = old_username) + + user = User.objects.get(username=old_username) user.username = new_username user.save() - messages.success(request, 'Username has been changed successfully.') + messages.success(request, "Username has been changed successfully.") return redirect(userDetails) else: - messages.error(request, 'No such username exists. ') + messages.error(request, "No such username exists. ") return redirect(userDetails) # to change the password of the corresponding user within website -@login_required(login_url='/loginTeacher') +@login_required(login_url="/loginTeacher") def userPasswordChange(request): - if request.method=="POST": - typed_password=request.POST.get('old_password') - new_password=request.POST.get('new_password') - confirm_password=request.POST.get('confirm_password') + if request.method == "POST": + typed_password = request.POST.get("old_password") + new_password = request.POST.get("new_password") + confirm_password = request.POST.get("confirm_password") # to obtain old password, - user = User.objects.get(username = request.COOKIES.get('username')) - current_password= request.user.password + user = User.objects.get(username=request.COOKIES.get("username")) + current_password = request.user.password # confirming typed old password is true or not - old_new_check=check_password(typed_password, current_password) + old_new_check = check_password(typed_password, current_password) if old_new_check: - if new_password==confirm_password: - user = User.objects.get(username = request.COOKIES.get('username')) + if new_password == confirm_password: + user = User.objects.get(username=request.COOKIES.get("username")) user.set_password(new_password) user.save() - messages.success(request, 'Password has been changed successfully.') + messages.success(request, "Password has been changed successfully.") return redirect(loginTeacher) else: - messages.error(request, 'Password does not match.') + messages.error(request, "Password does not match.") return redirect(userDetails) else: - messages.error(request, 'Old Password didnt match') + messages.error(request, "Old Password didnt match") return redirect(userDetails) - - def changeTitle(request): - if request.method=="POST": - new_title=request.POST.get('new_title') - usernaam=request.COOKIES.get('username') + if request.method == "POST": + new_title = request.POST.get("new_title") + usernaam = request.COOKIES.get("username") - user = User.objects.get(username =usernaam ) + user = User.objects.get(username=usernaam) full_name = user.get_full_name() x = full_name.split("/") - - unique=x[-1] - + + unique = x[-1] + if TeacherInfo.objects.filter(unique_id=unique).exists(): - teacher=TeacherInfo.objects.get(unique_id=unique) - teacher.title=new_title + teacher = TeacherInfo.objects.get(unique_id=unique) + teacher.title = new_title teacher.save() - - messages.success(request, 'Title has been changed successfully.') + + messages.success(request, "Title has been changed successfully.") return redirect(userDetails) else: - messages.error(request, 'No such Teacher exists. ') + messages.error(request, "No such Teacher exists. ") return redirect(userDetails) - return redirect(userDetails) def changePhone(request): - if request.method=="POST": - new_phone=request.POST.get('new_phone') - usernaam=request.COOKIES.get('username') + if request.method == "POST": + new_phone = request.POST.get("new_phone") + usernaam = request.COOKIES.get("username") - user = User.objects.get(username =usernaam ) + user = User.objects.get(username=usernaam) full_name = user.get_full_name() x = full_name.split("/") - - unique=x[-1] - + + unique = x[-1] + if TeacherInfo.objects.filter(unique_id=unique).exists(): - teacher=TeacherInfo.objects.get(unique_id=unique) - teacher.phone=new_phone + teacher = TeacherInfo.objects.get(unique_id=unique) + teacher.phone = new_phone teacher.save() - - messages.success(request, 'Phone Number has been changed successfully.') + + messages.success(request, "Phone Number has been changed successfully.") return redirect(userDetails) else: - messages.error(request, 'No such Teacher exists. ') + messages.error(request, "No such Teacher exists. ") return redirect(userDetails) - return redirect(userDetails) - def changeEmail(request): - if request.method=="POST": - new_email=request.POST.get('new_email') - usernaam=request.COOKIES.get('username') + if request.method == "POST": + new_email = request.POST.get("new_email") + usernaam = request.COOKIES.get("username") - user = User.objects.get(username =usernaam ) + user = User.objects.get(username=usernaam) full_name = user.get_full_name() x = full_name.split("/") - - unique=x[-1] - + + unique = x[-1] + if TeacherInfo.objects.filter(unique_id=unique).exists(): - teacher=TeacherInfo.objects.get(unique_id=unique) - teacher.email=new_email + teacher = TeacherInfo.objects.get(unique_id=unique) + teacher.email = new_email teacher.save() - - - user = User.objects.get(username =usernaam ) - user.email=new_email - user.save() + user = User.objects.get(username=usernaam) + user.email = new_email + user.save() - messages.success(request, 'Phone Number has been changed successfully.') + messages.success(request, "Phone Number has been changed successfully.") return redirect(userDetails) else: - messages.error(request, 'No such Teacher exists. ') + messages.error(request, "No such Teacher exists. ") return redirect(userDetails) - return redirect(userDetails) + def getdetails(request): - teacher_id = json.loads(request.GET.get('d_name')) + teacher_id = json.loads(request.GET.get("d_name")) result_set = [] - teacher=TeacherInfo.objects.get(unique_id=teacher_id) - subjects=teacher.subjects.all() + teacher = TeacherInfo.objects.get(unique_id=teacher_id) + subjects = teacher.subjects.all() for subject in subjects: - result_set.append({'subject_name': subject}) - return HttpResponse(json.dumps(result_set, indent=4, sort_keys=True, default=str), content_type='application/json') \ No newline at end of file + result_set.append({"subject_name": subject}) + return HttpResponse( + json.dumps(result_set, indent=4, sort_keys=True, default=str), + content_type="application/json", + ) + + +def edit(request): + if request.method == "POST": + roll = request.POST.get("roll") + + presentation= request.POST.get('presentation') + extra = request.POST.get('eca') + acade = request.POST.get('acad') + quality = request.POST.get('qual') + + + leaders = request.POST.get('quality1') + hardwork = request.POST.get('quality2') + social = request.POST.get('quality3') + teamwork = request.POST.get('quality4') + friendly = request.POST.get('quality5') + + deployed = request.POST.get('quality6') + publish = request.POST.get('quality7') + intern = request.POST.get('quality8') + + + student = StudentData.objects.get(std__roll_number = roll) + student.presentation= presentation + student.extracirricular= extra + student.academics= acade + student.quality= quality + + + student.leadership = True if leaders == "on" else False + student.hardwork = True if hardwork == "on" else False + student.social = True if social == "on" else False + student.teamwork = True if teamwork == "on" else False + student.friendly = True if friendly == "on" else False + + student.deployed = True if deployed == "on" else False + student.publishded = True if publish == "on" else False + student.intern = True if intern == "on" else False + + # presentation = request.POST.get("presentation") + + # quality1 = request.POST.get("quality1") + # quality2 = request.POST.get("quality2") + # quality3 = request.POST.get("quality3") + # quality4 = request.POST.get("quality4") + # eca = request.POST.get("eca") + + # student = StudentData.objects.get(std__roll_number=roll) + # student.presentation = presentation + # student.quality1 = quality1 + # student.quality2 = quality2 + # student.quality3 = quality3 + # student.quality4 = quality4 + # student.eca = eca + # student.is_generated = True + student.save() + bisaya=student.subjects + + subjec=bisaya.split(',') + subjects=subjec[:-1] + subject=subjec[-1] + + + + length=len(subjec) + print(length) + if length==1: + value=True + else: + value=False + + return render(request, "test.html", {"student": student,'subjects':subjects,'subject':subject,'value':value}) + + +def testing(request): + if request.method == "POST": + textarea = request.POST.get("textarea") + print(textarea) + return render(request, "testing.html", {"letter": textarea}) + + + diff --git a/media/images/cute_baby_1s9j8FP.gif b/media/images/cute_baby_1s9j8FP.gif deleted file mode 100644 index 329154a..0000000 Binary files a/media/images/cute_baby_1s9j8FP.gif and /dev/null differ diff --git a/media/images/cute_baby_D4Oals6.gif b/media/images/cute_baby_D4Oals6.gif deleted file mode 100644 index 329154a..0000000 Binary files a/media/images/cute_baby_D4Oals6.gif and /dev/null differ diff --git a/media/images/giphy_3_coKx4CI.gif b/media/images/giphy_3_coKx4CI.gif deleted file mode 100644 index 852ebca..0000000 Binary files a/media/images/giphy_3_coKx4CI.gif and /dev/null differ diff --git a/media/images/moneyheist.gif b/media/images/moneyheist.gif deleted file mode 100644 index 59d451e..0000000 Binary files a/media/images/moneyheist.gif and /dev/null differ diff --git a/media/images/moneyheist_7tYNGCr.gif b/media/images/moneyheist_7tYNGCr.gif deleted file mode 100644 index 59d451e..0000000 Binary files a/media/images/moneyheist_7tYNGCr.gif and /dev/null differ diff --git a/media/images/selena_4AE0Tpj.gif b/media/images/selena_4AE0Tpj.gif deleted file mode 100644 index 81496ed..0000000 Binary files a/media/images/selena_4AE0Tpj.gif and /dev/null differ diff --git a/media/images/selena_TXam9MI.gif b/media/images/selena_TXam9MI.gif deleted file mode 100644 index 81496ed..0000000 Binary files a/media/images/selena_TXam9MI.gif and /dev/null differ diff --git a/media/images/selena_dr2vXVw.gif b/media/images/selena_dr2vXVw.gif deleted file mode 100644 index 81496ed..0000000 Binary files a/media/images/selena_dr2vXVw.gif and /dev/null differ diff --git a/media/images/selena_iOGrowd.gif b/media/images/selena_iOGrowd.gif deleted file mode 100644 index 81496ed..0000000 Binary files a/media/images/selena_iOGrowd.gif and /dev/null differ diff --git a/media/images/selena_tEefd6K.gif b/media/images/selena_tEefd6K.gif deleted file mode 100644 index 81496ed..0000000 Binary files a/media/images/selena_tEefd6K.gif and /dev/null differ diff --git a/static/css/style.css b/static/css/style.css index 1347a08..7bc436e 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -350,20 +350,20 @@ nav { /* checkbox style */ .multiselect { - width: 200px; + width: 100% !important; } .selectBox { - position: relative; + position: relative !important; } .selectBox select { - width: 100%; - font-weight: bold; + width: 100% !important; + /* font-weight: bold !important; */ } .overSelect { - position: absolute; + position: absolute !important; left: 0; right: 0; top: 0; @@ -373,12 +373,31 @@ nav { #checkboxes { display: none; border: 1px #dadada solid; + } - #checkboxes label { + #checkboxes span { display: block; + flex-direction: column; + justify-content: center; + padding: 5px; + padding-left: 15px; + text-indent: -15px; + + } + + + #checkboxes input { + + width: 20px; + height: 20px; + padding: 0; + margin-right:15px; + vertical-align: bottom; + position: relative; + top: -1px; + *overflow: hidden; } - #checkboxes label:hover { - background-color: #1e90ff; - } \ No newline at end of file + + \ No newline at end of file diff --git a/templates/Student.html b/templates/Student.html index e535c0f..a5f7c54 100644 --- a/templates/Student.html +++ b/templates/Student.html @@ -29,8 +29,8 @@
- +
@@ -171,10 +154,10 @@ $("#subject").append('');//appending on the select //append new options returned - $("#one label").remove(); + $("#one span").remove(); for (var i = result.length - 1; i >= 0; i--) { - $("#one").append( '' );//appending on the select + $("#one").append( ' ' + result[i].subject_name+' ' );//appending on the select }; diff --git a/templates/formTeacher.html b/templates/formTeacher.html index 772e8ae..35b7818 100644 --- a/templates/formTeacher.html +++ b/templates/formTeacher.html @@ -1,77 +1,136 @@ -{% extends 'base2.html' %} +{% extends 'base2.html' %} {% block title %}Generate{% endblock title %} +{%block teacher %}{%endblock teacher %} + {% block body %} +
+
{{roll}} has given these informations:
+
+ Known Year: {{student.years_taught}}
+ Final year Project: {{student.final_project}} +
+ University: {{student.uni}}
+ GPA: {{student.gpa}}
+ Other projects: {{student.project1}},{{student.project2}} +
+ Paper: {{student.paper_link}}
+ Subjects: {{student.subjects}}
-{% block title %}Generate{% endblock title %} -{% block teacher %}{% endblock teacher %} +
Give Information for {{roll}}
+
+
+
+ {% csrf_token %} +
+
+ Presentation skills: + +
-{% block body %} -
-
{{roll}} has given these informations:

- Known Year: {{student.years_taught}}
- Final year Project: {{student.final_project}}
- University: {{student.uni}}
- GPA: {{student.gpa}}
- Other projects: {{student.project1}},{{student.project2}}
- Paper: {{student.paper_link}}
- Subjects: {{student.subjects}}
+
+ Extracirricular Activities + +
+
+ Academics Performance: + +
+
+ Qualitiy: + +
-
Give Information for {{roll}}

-
+ {% comment %} +
+ Project Details + +
+ {% endcomment %} - - - {% csrf_token %} -
- - -
- Presentation skills: - +
+ Personal Qualities +
+ +
- - - -
- Extracirricular Activities - +
+ + +
+
+ + +
+
+ + +
+
+ +
+
-
- Qualities -
- - -
-
- - -
-
- -
-
- -
+
+ Other +
+ + +
+
+ + +
+
+ +
- Project Details - +
- - +
+ +
+ +
+
- {% endblock body %} \ No newline at end of file diff --git a/templates/print.html b/templates/print.html index 3b1c54f..6cfdd66 100644 --- a/templates/print.html +++ b/templates/print.html @@ -26,7 +26,7 @@ -

Letter of Recommendation

+ + + + + {% autoescape off %} + {{letter1}} + {% comment %}

{{ letter3 }}

{% endcomment %} + {{letter2}} +{% endautoescape %} + \ No newline at end of file diff --git a/templates/student_success.html b/templates/student_success.html index efdc8c7..bb28c59 100644 --- a/templates/student_success.html +++ b/templates/student_success.html @@ -13,7 +13,7 @@

Here is your letter.

@@ -25,5 +25,6 @@

Here is your letter.

Your request has been successfully submitted.


You will have your letter here when professor provides it.
Don't worry you'll receive an email once done.

{% endif %} +{% comment %} {% endcomment %} {% endblock body %} \ No newline at end of file diff --git a/templates/test.html b/templates/test.html index 831c2b9..22b6bd2 100644 --- a/templates/test.html +++ b/templates/test.html @@ -1,12 +1,156 @@ - - - - - - - Document - - - {{teacher}} - - \ No newline at end of file +{% extends 'base2.html' %} + +{% block title %}Edit Letter{% endblock title %} +{% block body %} +
+

Letter of Recommendation

+ +
+
+
+ + + +
+

+ I would like to recommend {{student.name}} for admission to the graduate program at your university. + I have known {{student.name}} for about {{student.years_taught}} now as an undergraduate student + in {{student.std.program}} engineering. I have taught him courses on student.courses. + Moreover, I was the supervisor for his final year project. I taught him + {% if value %} + {{subject}}. + {%else%} + + {%for item in subjects %} {{item}}, {%endfor%} and {{subject}}. + + {%endif%} + +

+
+ +
+ +

I recall {{student.firstname}} as a sincere and hardworking student. + He maintained excellent academic performance throughout his undergraduate + ranking among the top percent students of his batch. As an instructor and his supervisor + too I had enough opportunity is observe his capabilities closely.

+ +
+ +
+ +

I was the supervisor in his project titled student/project_title . I was + quite impressed by his hardworking nature and learning capability.I could observe his keen interest + and aptitude for research while working on the project. + {{student.project}} + {%if student.paper == 'yes'%} + In fact, at the end of the project, he was also able to publish a paper.

+ {%endif%} + +

I have noted his {{student.presentation}} presentation skills while he presented his work at our department as well as in the + conference. + {%if student.quality1 and student.quality2%} + I have seen that he has good {{student.quality1}}and also has good {{student.quality2}} qualities. + {%endif%} + He is a well-spoken person with a friendly and gentle personality. He is very helpful and cooperative student. He eagerly + handed over his project work to his juniors who wanted to further continue the research on the topic along + with proper guidance and resources. I have also seen his presentation and communication skills during his + project and paper presentations.

+ + {%if student.eca == 'yes'%} +

I appreciate his technical and professional skills. Unlike, most students who limit their project to an + academic exercise, he was also active in extra-curricular activities. Besides academics, he was also + involved in several activities in and off the campus. He participated in various hackathons.

+ {%endif%} + +

I am quite confident that {{student.firstname}} skills coupled with academic capability will make him a good candidate for + your university. Thus, I would highly recommend him for the graduate program at your esteemed + university. Please feel free to contact me if further enquiry is required.

+ +

{{student.professor.name}}, PhD +
{{student.professor.title}}, +
Department of {{student.professor.department}} Engineering +
Pulchowk Campus, Institute of Engineering, Tribhuvan University +
Phone:{{student.professor.phone}} +
Mail: {{student.professor.email}} +

+ +
+ +
+ + + + + + + + + + + +
+ +
+
+ +
+
+ +{% endblock body %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/testing.html b/templates/testing.html new file mode 100644 index 0000000..66ec07d --- /dev/null +++ b/templates/testing.html @@ -0,0 +1,10 @@ +{% extends 'base2.html' %} + +{% block title %}Edit Letter{% endblock title %} +{% block body %} +
+{{letter}} +