Advertisement
Guest User

views

a guest
Feb 25th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 49.76 KB | None | 0 0
  1. from django.shortcuts import get_object_or_404, render
  2. from django.views import generic
  3. from django.db import connection
  4. from django.http import HttpResponseRedirect
  5. from django.urls import reverse
  6. from django.http import HttpResponse
  7. from django.contrib.auth.models import User
  8. from django.contrib.auth import authenticate, login, logout
  9. import datetime
  10.  
  11. def my_custom_sql(request):
  12. with connection.cursor() as cursor:
  13. cursor.execute("SELECT * FROM test")
  14. row = cursor.fetchall()
  15. row1 = [y for x in row for y in x]
  16. row2 = [y for y in [x for x in row]]
  17. return render(request, 'project_management/test.html',{'data':row1, 'data1':row2})
  18.  
  19. def home(request):
  20. return render(request, 'project_management/home.html')
  21.  
  22. def studentlogin(request):
  23. return render(request, 'project_management/studentlogin.html')
  24.  
  25. def employeelogin(request):
  26. return render(request, 'project_management/employeelogin.html')
  27.  
  28. def studentsignup(request):
  29. if not request.user.is_authenticated:
  30. return render(request, 'project_management/adminlogin.html', {'data':"Login again"})
  31. return render(request, 'project_management/addstudent.html')
  32.  
  33. def studentsignupranged(request):
  34. if not request.user.is_authenticated:
  35. return render(request, 'project_management/adminlogin.html', {'data':"Login again"})
  36. return render(request, 'project_management/addstudentranged.html')
  37.  
  38. def employeesignup(request):
  39. if not request.user.is_authenticated:
  40. return render(request, 'project_management/adminlogin.html', {'data':"Login again"})
  41. return render(request, 'project_management/addemployee.html')
  42.  
  43. def userlogout(request):
  44. logout(request)
  45. return render(request, 'project_management/home.html', {'data':"Logged out"})
  46.  
  47. def createstudentusers(request):
  48. if not request.user.is_authenticated:
  49. return render(request, 'project_management/adminlogin.html', {'data':"Login again"})
  50. username = request.POST['username']
  51. password = request.POST['password']
  52. with connection.cursor() as cursor:
  53. cursor.execute("select count(*) from auth_user where username = %s", [username])
  54. row = cursor.fetchall()
  55. row1 = [y for x in row for y in x]
  56. if(row1[0]==0):
  57. User.objects.create_user(username, '', password)
  58. else:
  59. return render(request, 'project_management/addstudent.html', {'data':"Username already taken."})
  60. with connection.cursor() as cursor:
  61. cursor.execute('select count(*) from student where rollno=%s;', [username])
  62. r = cursor.fetchall()
  63. print (r[0])
  64. print ("abcd")
  65. if(r[0][0]!=0):
  66. return render(request, 'project_management/addstudent.html', {'data':"Username already taken."})
  67. with connection.cursor() as cursor:
  68. cursor.execute('insert into student values(%s, "Anonymous New User", "0.0", NULL, 0, aes_encrypt(%s, "cryptography"), "Computer Science and Engineering", NULL, 0, 40, NULL)', [username, password])
  69. return render(request, 'project_management/admin.html', {'data':"New User Created"})
  70.  
  71. def createemployeeusers(request):
  72. if not request.user.is_authenticated:
  73. return render(request, 'project_management/adminlogin.html', {'data':"Login again"})
  74. username = request.POST['username']
  75. password = request.POST['password']
  76. with connection.cursor() as cursor:
  77. cursor.execute("select count(*) from auth_user where username = %s", [username])
  78. row = cursor.fetchall()
  79. row1 = [y for x in row for y in x]
  80. if(row1[0]==0):
  81. User.objects.create_user(username, '', password)
  82. else:
  83. render(request, 'project_management/addemployee.html', {'data':"Username already taken."})
  84. with connection.cursor() as cursor:
  85. cursor.execute('select count(*) from guide where id=%s;', [username])
  86. r = cursor.fetchall()
  87. if(r[0][0]!=0):
  88. return render(request, 'project_management/addemployee.html', {'data':"Username already taken."})
  89. with connection.cursor() as cursor:
  90. cursor.execute('insert into guide values(%s, "Anonymous New User", 4,aes_encrypt(%s, "cryptography"), "Computer Science and Engineering")', [username, password])
  91. return render(request, 'project_management/admin.html', {'data':"User Created"})
  92.  
  93. def createstudentusersranged(request):
  94. if not request.user.is_authenticated:
  95. return render(request, 'project_management/adminlogin.html', {'data':"Login again"})
  96. begin = request.POST['start']
  97. end = request.POST['end']
  98. for i in range(int(begin), int(end)+1):
  99. with connection.cursor() as cursor:
  100. cursor.execute("select count(*) from auth_user where username = %s", [i])
  101. row = cursor.fetchall()
  102. row1 = [y for x in row for y in x]
  103. if(row1[0]==0):
  104. User.objects.create_user(i, '', str(i)+"123xyz")
  105. else:
  106. return render(request, 'project_management/addstudentranged.html', {'data':"Username already taken."})
  107. with connection.cursor() as cursor:
  108. cursor.execute('select count(*) from student where rollno=%s;', [i])
  109. r = cursor.fetchall()
  110. if(r[0][0]!=0):
  111. return render(request, 'project_management/addstudent.html', {'data':"Username already taken."})
  112. with connection.cursor() as cursor:
  113. cursor.execute('insert into student values(%s, "Anonymous New User", 0.0, NULL, 0, aes_encrypt(%s, "cryptography"), "Computer Science and Engineering", NULL, 0, 40, NULL)', [i, str(i)+"123xyz"])
  114. return render(request, 'project_management/admin.html', {'data':"Users Created"})
  115.  
  116. def adminlogin(request):
  117. return render(request, 'project_management/adminlogin.html')
  118.  
  119. def adminverify(request):
  120. with connection.cursor() as cursor:
  121. cursor.execute('SELECT * FROM admin WHERE username = %s and password = %s;', [request.POST['username'], request.POST['password']])
  122. row = cursor.fetchall()
  123. row1 = [y for x in row for y in x]
  124. if(len(row1)>=1):
  125. user = authenticate(username=request.POST['username'], password=request.POST['password'])
  126. login(request, user)
  127. return render(request, 'project_management/admin.html')
  128. else:
  129. return render(request, 'project_management/home.html', {'data':"Enter correct credentials"})
  130. #def createemployeeusers(request):
  131.  
  132. def verifystudentloginedit(request):
  133. if request.user.is_authenticated:
  134. with connection.cursor() as cursor:
  135. cursor.execute('SELECT * FROM student WHERE rollno = %s and aes_decrypt(password, %s) = %s;', [request.user.username, "cryptography", request.POST['password']])
  136. row = cursor.fetchall()
  137. row1 = [y for x in row for y in x]
  138. if(float(request.POST['cgpa'])<0.0 or float(request.POST['cgpa'])>10.00):
  139. return render(request, 'project_management/studentdetail.html', {'data':"Enter a valid CGPA"})
  140. with connection.cursor() as cursor:
  141. cursor.execute('select count(*) from department where name=%s;', [request.POST['dept']])
  142. r = cursor.fetchall()
  143. print ("fsafa")
  144. print (r[0][0])
  145. if(r[0][0]==0):
  146. return render(request, 'project_management/studentdetail.html', {'data':"Enter a valid Department"})
  147. with connection.cursor() as cursor:
  148. # change password in auth_user as well
  149. cursor.execute('update student set name = %s, password = aes_encrypt(%s, %s), cgpa = %s, proj_topic_ideas = %s, dept_name = %s where rollno = %s;',[request.POST['name'], request.POST['password'], "cryptography", request.POST['cgpa'], request.POST['ideas'], request.POST['dept'], request.user.username])
  150. with connection.cursor() as cursor:
  151. cursor.execute('SELECT * FROM student WHERE rollno = %s and aes_decrypt(password, %s) = %s;', [request.user.username, "cryptography", request.POST['password']])
  152. row = cursor.fetchall()
  153. row1 = [y for x in row for y in x]
  154. maps = {'Roll Number':row1[0], 'Name':row1[1], 'CGPA':row1[2], 'Project Ideas':row1[3], 'Allocation Flag':row1[4], 'Department Name':row1[6], 'Project ID(if allocated)':row1[7], 'Attendance':row1[8], 'Maximum Attendance':row1[9], 'Next Meet Date':row1[10]}
  155. u = User.objects.get(username=request.user.username)
  156. u.set_password(request.POST['password'])
  157. u.save()
  158. return render(request, 'project_management/studentdetail.html', {'data':"Updated Profile", 'map':maps})
  159. else:
  160. return render(request, 'project_management/studentlogin.html', {'data':"Error updating, log in again"})
  161.  
  162. def verifystudentlogin(request):
  163. with connection.cursor() as cursor:
  164.  
  165. cursor.execute('SELECT * FROM student WHERE rollno = %s and aes_decrypt(password, %s) = %s;', [request.POST['username'], "cryptography", request.POST['password']])
  166. row = cursor.fetchall()
  167. row1 = [y for x in row for y in x]
  168. if(len(row1)>=1):
  169. user = authenticate(username=request.POST['username'], password=request.POST['password'])
  170. login(request, user)
  171. maps = {'Roll Number':row1[0], 'Name':row1[1], 'CGPA':row1[2], 'Project Ideas':row1[3], 'Allocation Flag':row1[4], 'Department Name':row1[6], 'Project ID(if allocated)':row1[7], 'Attendance':row1[8], 'Maximum Attendance':row1[9], 'Next Meet Date':row1[10]}
  172. return render(request, 'project_management/studentdetail.html',{'data1':row1,'map':maps})
  173. else:
  174. return render(request, 'project_management/studentlogin.html', {'data':"Enter correct details"})
  175.  
  176. def verifyemployeelogin(request):
  177. with connection.cursor() as cursor:
  178. cursor.execute('SELECT * FROM guide WHERE id = %s and aes_decrypt(password, %s) = %s;', [request.POST['username'], "cryptography", request.POST['password']])
  179. row = cursor.fetchall()
  180. row1 = [y for x in row for y in x]
  181. if(len(row1)>=1):
  182. user = authenticate(username=request.POST['username'], password=request.POST['password'])
  183. login(request, user)
  184. maps = {'Guide ID':row1[0], 'Name':row1[1], 'Seats Left':row1[2], 'Department':row1[4]}
  185. return render(request, 'project_management/employeedetail.html',{'data1':row1,'map':maps})
  186. else:
  187. return render(request, 'project_management/employeelogin.html', {'data':"Enter correct details"})
  188.  
  189. def verifyemployeeloginedit(request):
  190. if request.user.is_authenticated:
  191. with connection.cursor() as cursor:
  192. cursor.execute('select count(*) from department where name=%s;', [request.POST['dept']])
  193. r = cursor.fetchall()
  194. if(r[0][0]==0):
  195. return render(request, 'project_management/employeedetail.html', {'data':"Enter a valid Department"})
  196. with connection.cursor() as cursor:
  197. # change password in auth_user as well
  198. cursor.execute('update guide set name = %s, password = aes_encrypt(%s, %s), seats_left = 4, dept_name = %s where id = %s;',[request.POST['name'], request.POST['password'], "cryptography", request.POST['dept'], request.user.username])
  199. with connection.cursor() as cursor:
  200. cursor.execute('SELECT * FROM guide WHERE id = %s and aes_decrypt(password, %s) = %s;', [request.user.username, "cryptography", request.POST['password']])
  201. row = cursor.fetchall()
  202. row1 = [y for x in row for y in x]
  203. maps = {'Guide ID':row1[0], 'Name':row1[1], 'Seats Left':row1[2], 'Department':row1[4]}
  204. u = User.objects.get(username=request.user.username)
  205. u.set_password(request.POST['password'])
  206. u.save()
  207. return render(request, 'project_management/employeedetail.html', {'data':"Updated Profile", 'map':maps})
  208. else:
  209. return render(request, 'project_management/employeelogin.html', {'data':"Error updating, log in again"})
  210.  
  211. def fillpreference(request):
  212. if not request.user.is_authenticated:
  213. return render(request, 'project_management/studentlogin.html', {'data':"Login again"})
  214. with connection.cursor() as cursor:
  215. cursor.execute('select id, name from guide')
  216. row = cursor.fetchall()
  217. row2 = [y for y in[x for x in row]]
  218. row3 = [{'Professor Name':row2[i][1], 'Professor ID':row2[i][0]} for i in range(len(row2))]
  219. with connection.cursor() as cursor:
  220. cursor.execute('select count(*) from preferences where student_roll=%s', [request.user.username])
  221. row = cursor.fetchall()
  222. row12 = [y for x in row for y in x]
  223. if(row12[0]!=0):
  224. with connection.cursor() as cursor:
  225. cursor.execute('select name from preferences, guide where student_roll=%s and guide.id = guide_id', [request.user.username])
  226. row13 = cursor.fetchall()
  227. row11 = [y for x in row13 for y in x]
  228. maps={'Preference1':row11[0], 'Preference2':row11[1], 'Preference3':row11[2], 'Preference4':row11[3]}
  229. return render(request, 'project_management/showpreference.html', {'map':maps})
  230. return render(request, 'project_management/fillpreference.html', {'data2':row3})
  231.  
  232. def addpreference(request):
  233. if not request.user.is_authenticated:
  234. return render(request, 'project_management/studentlogin.html', {'data':"Login again"})
  235. with connection.cursor() as cursor:
  236. cursor.execute('select count(*) from guide where id=%s or id=%s or id=%s or id=%s;', [request.POST['username1'], request.POST['username2'], request.POST['username3'], request.POST['username4']])
  237. r=cursor.fetchall()
  238. if(r[0][0]!=4):
  239. with connection.cursor() as cursor:
  240. cursor.execute('select id, name from guide')
  241. row = cursor.fetchall()
  242. row2 = [y for y in[x for x in row]]
  243. row3 = [{'Professor Name':row2[i][1], 'Professor ID':row2[i][0]} for i in range(len(row2))]
  244. return render(request, 'project_management/fillpreference.html', {'data':"Enter valid preferences", 'data2':row3})
  245. with connection.cursor() as cursor:
  246. cursor.execute('insert into preferences values(1, %s, %s)', [request.POST['username1'], request.user.username])
  247. cursor.execute('insert into preferences values(2, %s, %s)', [request.POST['username2'], request.user.username])
  248. cursor.execute('insert into preferences values(3, %s, %s)', [request.POST['username3'], request.user.username])
  249. cursor.execute('insert into preferences values(4, %s, %s)', [request.POST['username4'], request.user.username])
  250. with connection.cursor() as cursor:
  251. cursor.execute('SELECT * FROM student WHERE rollno = %s;', [request.user.username])
  252. row = cursor.fetchall()
  253. row1 = [y for x in row for y in x]
  254. maps = {'Roll Number':row1[0], 'Name':row1[1], 'CGPA':row1[2], 'Project Ideas':row1[3], 'Allocation Flag':row1[4], 'Department Name':row1[6], 'Project ID(if allocated)':row1[7], 'Attendance':row1[8], 'Maximum Attendance':row1[9], 'Next Meet Date':row1[10]}
  255. return render(request, 'project_management/studentdetail.html', {'data':"Added the preferences", 'map':maps})
  256.  
  257. def showprofessordetails(request):
  258. if not request.user.is_authenticated:
  259. return render(request, 'project_management/studentlogin.html', {'data':"Login again"})
  260. with connection.cursor() as cursor:
  261. cursor.execute('select name, seats_left, publication, interest_area from guide, guide_pub, guide_interest where id = guide_pub.guide_id and id = guide_interest.guide_id;')
  262. row = cursor.fetchall()
  263. row2 = [y for y in[x for x in row]]
  264. row3 = [{'Professor Name':row2[i][0], 'Seats Left':row2[i][1], 'Publication':row2[i][2], 'Interest Area':row2[i][3]} for i in range(len(row2))]
  265. return render(request, 'project_management/showprofessordetails.html', {'data1':row3})
  266.  
  267. def prefinfo(request):
  268. if not request.user.is_authenticated:
  269. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  270. with connection.cursor() as cursor:
  271. cursor.execute('select pref_number, student.name, allocated_flag from guide, preferences, student where id = preferences.guide_id and rollno = preferences.student_roll and id=%s', [request.user.username])
  272. row = cursor.fetchall()
  273. row2 = [y for y in[x for x in row]]
  274. row3 = [{'Student Name':row2[i][1], 'Preference Number':row2[i][0], 'Allocation Flag':row2[i][2]} for i in range(len(row2))]
  275. return render(request, 'project_management/prefinfo.html', {'data1':row3})
  276.  
  277. def showstudentinfo(request):
  278. if not request.user.is_authenticated:
  279. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  280. with connection.cursor() as cursor:
  281. cursor.execute('select rollno, student.name, cgpa, proj_topic_ideas, allocated_flag, student.dept_name, interest_area, project_topic from guide, preferences, student, stud_interest, past_projects where rollno=stud_interest.student_roll and rollno=past_projects.student_roll and id = preferences.guide_id and rollno = preferences.student_roll and id=%s;', [request.user.username])
  282. row11 = cursor.fetchall()
  283. with connection.cursor() as cursor:
  284. cursor.execute('select rollno from student, guide, preferences where id = preferences.guide_id and rollno = preferences.student_roll and id=%s and allocated_flag=0;', [request.user.username])
  285. row21 = cursor.fetchall()
  286. row2 = [y for y in[x for x in row11]]
  287. row3 = [y for y in[x for x in row21]]
  288. row41 = [{'Student Name':row2[i][1], 'Roll Number':row2[i][0], 'CGPA':row2[i][2], 'Ideas':row2[i][3], 'Allocation Flag':row2[i][4], 'Department':row2[i][5], 'Interest':row2[i][6], 'Past Project Topic':row2[i][7]} for i in range(len(row2))]
  289. row31 = [{'Roll Number':row3[i][0]} for i in range(len(row3))]
  290. return render(request, 'project_management/showstudentinfo.html', {'data1':row31, 'data2':row41})
  291.  
  292.  
  293. def changeallocation(request):
  294. if not request.user.is_authenticated:
  295. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  296. with connection.cursor() as cursor:
  297. cursor.execute('select rollno from student, guide, preferences where id = preferences.guide_id and rollno = preferences.student_roll and id=%s and allocated_flag=0;', [request.user.username])
  298. row2 = cursor.fetchall()
  299. row3 = [y for x in row2 for y in x]
  300. with connection.cursor() as cursor:
  301. cursor.execute('select seats_left from guide where id = %s;',[request.user.username])
  302. row = cursor.fetchall()
  303. row1 = [y for x in row for y in x]
  304. count=0
  305. for i in row3:
  306. a = request.POST.get('choice'+i)
  307. print (a)
  308. print (i)
  309. if(a != "Lock" and a != "Wait" and a != "Free"):
  310. print ("out")
  311. return render(request, 'project_management/employeelogin.html', {'data':"Unchanged Allocation"})
  312. if(a == "Lock"):
  313. count = count + 1
  314. if(a=='Wait'):
  315. with connection.cursor() as cursor:
  316. cursor.execute('update student set allocated_flag=1 where rollno=%s;',[i])
  317. if(a=='Free'):
  318. with connection.cursor() as cursor:
  319. cursor.execute('update student set allocated_flag=0 where rollno=%s;',[i])
  320. print (count)
  321.  
  322. if(count>int(row1[0])):
  323. with connection.cursor() as cursor:
  324. cursor.execute('select rollno, student.name, cgpa, proj_topic_ideas, allocated_flag, student.dept_name, interest_area, project_topic from guide, preferences, student, stud_interest, past_projects where rollno=stud_interest.student_roll and rollno=past_projects.student_roll and id = preferences.guide_id and rollno = preferences.student_roll and id=%s;', [request.user.username])
  325. row11 = cursor.fetchall()
  326. with connection.cursor() as cursor:
  327. cursor.execute('select rollno from student, guide, preferences where id = preferences.guide_id and rollno = preferences.student_roll and id=%s and allocated_flag=0;', [request.user.username])
  328. row21 = cursor.fetchall()
  329. row22 = [y for y in[x for x in row11]]
  330. row33 = [y for y in[x for x in row21]]
  331. row41 = [{'Student Name':row22[i][1], 'Roll Number':row22[i][0], 'CGPA':row22[i][2], 'Ideas':row22[i][3], 'Allocation Flag':row22[i][4], 'Department':row22[i][5], 'Interest':row22[i][6], 'Past Project Topic':row22[i][7]} for i in range(len(row22))]
  332. row31 = [{'Roll Number':row33[i][0]} for i in range(len(row33))]
  333. return render(request, 'project_management/showstudentinfo.html', {'data':"Select less choices",'data1':row31, 'data2':row41})
  334.  
  335. for i in row3:
  336. a = request.POST.get('choice'+i)
  337. if(a=="Lock"):
  338. with connection.cursor() as cursor:
  339. cursor.execute('update student set allocated_flag=2 where rollno=%s;',[i])
  340. cursor.execute('insert into supervisor values(%s, %s, "F");',[request.user.username, i])
  341. with connection.cursor() as cursor:
  342. cursor.execute('update guide set seats_left=%s where id=%s;',[int(row1[0])-count,request.user.username])
  343. return render(request, 'project_management/employeelogin.html', {'data':"Changed Allocation"})
  344.  
  345. def assignproject(request):
  346. if not request.user.is_authenticated:
  347. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  348. with connection.cursor() as cursor:
  349. cursor.execute('select student_roll from supervisor where guide_id=%s', [request.user.username])
  350. row = cursor.fetchall()
  351. row2 = [y for x in row for y in x]
  352. return render(request, 'project_management/assignproject.html', {'data1':row2})
  353.  
  354. def assignedproject(request):
  355. if not request.user.is_authenticated:
  356. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  357. with connection.cursor() as cursor:
  358. cursor.execute('select count(*) from supervisor where guide_id=%s and student_roll=%s;', [request.user.username, request.POST['roll']])
  359. r=cursor.fetchall()
  360. if(r[0][0]==0):
  361. with connection.cursor() as cursor:
  362. cursor.execute('select student_roll from supervisor where guide_id=%s', [request.user.username])
  363. row = cursor.fetchall()
  364. row2 = [y for x in row for y in x]
  365. return render(request, 'project_management/assignproject.html', {'data':"Select correct students", 'data1':row2})
  366.  
  367. with connection.cursor() as cursor:
  368. cursor.execute('insert into project(topic, credits) values(%s, %s);', [request.POST['topic'], request.POST['credits']])
  369. with connection.cursor() as cursor:
  370. cursor.execute('select max(id) from project;')
  371. r1=cursor.fetchall()
  372. r2=[y for y in[x for x in r1]]
  373. pid=int(r2[0][0])
  374. with connection.cursor() as cursor:
  375. cursor.execute('update student set proj_id=%s where rollno=%s;',[pid, request.POST['roll']])
  376. with connection.cursor() as cursor:
  377. cursor.execute('select student_roll from supervisor where guide_id=%s', [request.user.username])
  378. row = cursor.fetchall()
  379. row2 = [y for x in row for y in x]
  380. return render(request, 'project_management/assignproject.html', {'data':"Assigned the Project", 'data1':row2})
  381.  
  382. def fillproject(request):
  383. if not request.user.is_authenticated:
  384. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  385. with connection.cursor() as cursor:
  386. cursor.execute('select proj_id from supervisor, student, project where project.id=proj_id and guide_id=%s and student_roll=rollno', [request.user.username])
  387. row = cursor.fetchall()
  388. row2 = [y for x in row for y in x]
  389. print (datetime.date.today())
  390. print ("faf")
  391. print (datetime.datetime.now().date())
  392. return render(request, 'project_management/fillproject.html', {'data1':row2, 'd':str(datetime.date.today())})
  393.  
  394. def filledproject(request):
  395. if not request.user.is_authenticated:
  396. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  397. with connection.cursor() as cursor:
  398. cursor.execute('select count(*) from supervisor, student where student_roll = rollno and guide_id=%s and proj_id=%s', [request.user.username, request.POST['project_id']])
  399. r=cursor.fetchall()
  400. if(r[0][0]==0):
  401. with connection.cursor() as cursor:
  402. cursor.execute('select proj_id from supervisor, student, project where project.id=proj_id and guide_id=%s and student_roll=rollno', [request.user.username])
  403. row = cursor.fetchall()
  404. row2 = [y for x in row for y in x]
  405. return render(request, 'project_management/fillproject.html', {'data':"Enter supervising project IDs only", 'data1':row2, 'd':str(datetime.date.today())})
  406. with connection.cursor() as cursor:
  407. cursor.execute('select count(*) from proj_guide where guide_id=%s and project_id=%s;',[request.user.username, request.POST['project_id']])
  408. r=cursor.fetchall()
  409. if(r[0][0]!=0):
  410. with connection.cursor() as cursor:
  411. cursor.execute('update proj_guide set guide_id=%s, checkpoint=%s, deadline=%s where project_id=%s;', [request.user.username, request.POST['checkpoint'], request.POST['deadline'], request.POST['project_id']])
  412. with connection.cursor() as cursor:
  413. cursor.execute('select proj_id from supervisor, student, project where project.id=proj_id and guide_id=%s and student_roll=rollno', [request.user.username])
  414. row = cursor.fetchall()
  415. print (datetime.date.today())
  416. row2 = [y for x in row for y in x]
  417. return render(request, 'project_management/fillproject.html', {'data':"Updated the Project", 'data1':row2, 'd':str(datetime.date.today())})
  418. with connection.cursor() as cursor:
  419. cursor.execute('insert into proj_guide values(%s, %s, %s, %s);', [request.user.username, request.POST['project_id'], request.POST['checkpoint'], request.POST['deadline']])
  420. with connection.cursor() as cursor:
  421. cursor.execute('select proj_id from supervisor, student where guide_id=%s and student_roll=rollno', [request.user.username])
  422. row = cursor.fetchall()
  423. print (datetime.date.today())
  424. row2 = [y for x in row for y in x]
  425. return render(request, 'project_management/fillproject.html', {'data':"Filled the Project", 'data1':row2, 'd':str(datetime.date.today())})
  426.  
  427. def assigngrades(request):
  428. if not request.user.is_authenticated:
  429. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  430. with connection.cursor() as cursor:
  431. cursor.execute('select rollno from supervisor, student where guide_id=%s and student_roll=rollno', [request.user.username])
  432. row = cursor.fetchall()
  433. row2 = [y for x in row for y in x]
  434. return render(request, 'project_management/assigngrades.html', {'data1':row2})
  435.  
  436. def assignedgrades(request):
  437. if not request.user.is_authenticated:
  438. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  439. with connection.cursor() as cursor:
  440. cursor.execute('select count(*) from supervisor, student where guide_id=%s and student_roll=rollno and rollno=%s;', [request.user.username, request.POST['roll']])
  441. r=cursor.fetchall()
  442. if(r[0][0]==0):
  443. with connection.cursor() as cursor:
  444. cursor.execute('select rollno from supervisor, student where guide_id=%s and student_roll=rollno', [request.user.username])
  445. row = cursor.fetchall()
  446. row2 = [y for x in row for y in x]
  447. return render(request, 'project_management/assigngrades.html', {'data':"Only select correct students", 'data1':row2})
  448. with connection.cursor() as cursor:
  449. cursor.execute('update supervisor set grade=%s where guide_id=%s and student_roll=%s;', [request.POST['grade'], request.user.username, request.POST['roll']])
  450. with connection.cursor() as cursor:
  451. cursor.execute('select rollno from supervisor, student where guide_id=%s and student_roll=rollno', [request.user.username])
  452. row = cursor.fetchall()
  453. row2 = [y for x in row for y in x]
  454. return render(request, 'project_management/assigngrades.html', {'data':"Assigned the grades", 'data1':row2})
  455.  
  456. def attend(request):
  457. if not request.user.is_authenticated:
  458. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  459. with connection.cursor() as cursor:
  460. cursor.execute('select rollno from supervisor, student where guide_id=%s and student_roll=rollno', [request.user.username])
  461. row = cursor.fetchall()
  462. row2 = [y for x in row for y in x]
  463. return render(request, 'project_management/attend.html', {'data1':row2, 'd':str(datetime.date.today())})
  464.  
  465. def attenddone(request):
  466. if not request.user.is_authenticated:
  467. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  468. with connection.cursor() as cursor:
  469. cursor.execute('select count(*) from supervisor where guide_id=%s and student_roll=%s;', [request.user.username, request.POST['roll']])
  470. r=cursor.fetchall()
  471. if(r[0][0]==0):
  472. with connection.cursor() as cursor:
  473. cursor.execute('select rollno from supervisor, student where guide_id=%s and student_roll=rollno', [request.user.username])
  474. row = cursor.fetchall()
  475. row2 = [y for x in row for y in x]
  476. return render(request, 'project_management/attend.html', {'data':"Enter correct students", 'data1':row2, 'd':str(datetime.date.today())})
  477. with connection.cursor() as cursor:
  478. cursor.execute('select attendance from student, supervisor where student_roll=%s;',[request.POST['roll']])
  479. row11 = cursor.fetchall()
  480. row21 = [y for x in row11 for y in x]
  481. with connection.cursor() as cursor:
  482. cursor.execute('update student set attendance=%s, next_meet=%s where rollno=%s;', [row21[0]+int(request.POST['attendance']), request.POST['meet'], request.POST['roll']])
  483. with connection.cursor() as cursor:
  484. cursor.execute('select rollno from supervisor, student where guide_id=%s and student_roll=rollno', [request.user.username])
  485. row = cursor.fetchall()
  486. row2 = [y for x in row for y in x]
  487. return render(request, 'project_management/attend.html', {'data':"Done", 'data1':row2, 'd':str(datetime.date.today())})
  488.  
  489. def panelsignup(request):
  490. if not request.user.is_authenticated:
  491. return render(request, 'project_management/adminlogin.html', {'data':"Login again"})
  492. return render(request, 'project_management/addpanel.html')
  493.  
  494. def createpanel(request):
  495. if not request.user.is_authenticated:
  496. return render(request, 'project_management/adminlogin.html', {'data':"Login again"})
  497. count = 0
  498. for i in range(7):
  499. if(len(request.POST['m'+str(i+1)])>0):
  500. count = count + 1
  501. with connection.cursor() as cursor:
  502. cursor.execute('insert into panel(cardinality, stage, password) values(%s, %s, "abc")', [count, request.POST['stage']])
  503. with connection.cursor() as cursor:
  504. cursor.execute('select max(id) from panel;');
  505. r=cursor.fetchall()
  506. r2=[y for y in[x for x in r]]
  507. pid=int(r2[0][0])
  508. print (pid)
  509. for i in range(7):
  510. if(len(request.POST['m'+str(i+1)])>0):
  511. with connection.cursor() as cursor:
  512. cursor.execute('insert into member values(%s, %s)', [request.POST['m'+str(i+1)], pid])
  513. return render(request, 'project_management/admin.html', {'data':"Created Panel"})
  514.  
  515. def adddoc(request):
  516. if not request.user.is_authenticated:
  517. return render(request, 'project_management/studentlogin.html', {'data':"Login again"})
  518. with connection.cursor() as cursor:
  519. cursor.execute('select proj_id from student where rollno=%s;', [request.user.username])
  520. row = cursor.fetchall()
  521. row2 = [y for x in row for y in x]
  522. return render(request, 'project_management/adddoc.html', {'data1':row2})
  523.  
  524. def addeddoc(request):
  525. if not request.user.is_authenticated:
  526. return render(request, 'project_management/studentlogin.html', {'data':"Login again"})
  527. with connection.cursor() as cursor:
  528. cursor.execute('select count(*) from project where id=%s;', [request.POST['pid']])
  529. r=cursor.fetchall()
  530. if r[0][0]==0:
  531. return render(request, 'project_management/adddoc.html', {'data':"Enter existing project ID"})
  532. with connection.cursor() as cursor:
  533. cursor.execute('select count(*) from student where rollno=%s and proj_id=%s;', [request.user.username, request.POST['pid']])
  534. r=cursor.fetchall()
  535. if r[0][0]==0:
  536. return render(request, 'project_management/adddoc.html', {'data':"Enter assigned project ID"})
  537. with connection.cursor() as cursor:
  538. cursor.execute('insert into documents(location, type, proj_id, student_roll) values(%s, %s, %s, %s);', [request.POST['location'], request.POST['type'], request.POST['pid'], request.user.username])
  539. with connection.cursor() as cursor:
  540. cursor.execute('select proj_id from student where rollno=%s;', [request.user.username])
  541. row = cursor.fetchall()
  542. row2 = [y for x in row for y in x]
  543. return render(request, 'project_management/adddoc.html', {'data':"Added document details successfully", 'data1':row2})
  544.  
  545. def seesen(request):
  546. if not request.user.is_authenticated:
  547. return render(request, 'project_management/studentlogin.html', {'data':"Login again"})
  548. with connection.cursor() as cursor:
  549. userlike = request.user.username[0:2]+"%"
  550. cursor.execute('select student.name, topic, location, guide.name from student, supervisor, project, guide, documents where rollno not like %s and rollno=supervisor.student_roll and student.proj_id=project.id and documents.proj_id=project.id and guide.id=supervisor.guide_id;', [userlike])
  551. row = cursor.fetchall()
  552. row2 = [y for y in[x for x in row]]
  553. print (row2[0][0])
  554. print (type(row2))
  555. row3 = [{'Student Name':row2[i][0], 'Project Topic':row2[i][1], 'Document Location':row2[i][2], 'Guide Name':row2[i][3]} for i in range(len(row2))]
  556. return render(request, 'project_management/showseniors.html', {'data1':row3})
  557.  
  558. def assignpanel(request):
  559. if not request.user.is_authenticated:
  560. return render(request, 'project_management/adminlogin.html', {'data':"Login again"})
  561. with connection.cursor() as cursor:
  562. cursor.execute('select name, guide_id, panel_id from member, guide where guide_id=id;')
  563. row=cursor.fetchall()
  564. row2 = [y for y in[x for x in row]]
  565. row3 = [{'Guide Name':row2[i][0], 'Guide ID':row2[i][1], 'Panel ID':row2[i][2]} for i in range(len(row2))]
  566. with connection.cursor() as cursor:
  567. cursor.execute('select id from panel;')
  568. row=cursor.fetchall()
  569. row2 = [y for y in[x for x in row]]
  570. row4 = [{'Panel ID':row2[i][0]} for i in range(len(row2))]
  571. with connection.cursor() as cursor:
  572. cursor.execute('select id from project;')
  573. row=cursor.fetchall()
  574. row2 = [y for y in[x for x in row]]
  575. row5 = [{'Project ID':row2[i][0]} for i in range(len(row2))]
  576. return render(request, 'project_management/assignpanel.html', {'data2':row4, 'data3':row3, 'data4':row5})
  577.  
  578.  
  579. def assignedpanel(request):
  580. if not request.user.is_authenticated:
  581. return render(request, 'project_management/adminlogin.html', {'data':"Login again"})
  582. with connection.cursor() as cursor:
  583. cursor.execute('select count(*) from panel, project where panel.id=%s and project.id=%s;', [request.POST['pid'], request.POST['prid']])
  584. r = cursor.fetchall()
  585. if(r[0][0]==0):
  586. with connection.cursor() as cursor:
  587. cursor.execute('select name, guide_id, panel_id from member, guide where guide_id=id;')
  588. row=cursor.fetchall()
  589. row2 = [y for y in[x for x in row]]
  590. row3 = [{'Guide Name':row2[i][0], 'Guide ID':row2[i][1], 'Panel ID':row2[i][2]} for i in range(len(row2))]
  591. with connection.cursor() as cursor:
  592. cursor.execute('select id from panel;')
  593. row=cursor.fetchall()
  594. row2 = [y for y in[x for x in row]]
  595. row4 = [{'Panel ID':row2[i][0]} for i in range(len(row2))]
  596. with connection.cursor() as cursor:
  597. cursor.execute('select id from project;')
  598. row=cursor.fetchall()
  599. row2 = [y for y in[x for x in row]]
  600. row5 = [{'Project ID':row2[i][0]} for i in range(len(row2))]
  601. return render(request, 'project_management/assignpanel.html', {'data':"Panel or Project does not exist", 'data2':row4, 'data3':row3, 'data4':row5})
  602. with connection.cursor() as cursor:
  603. cursor.execute('select count(*) from panel_proj where project_id=%s and panel_id=%s;',[request.POST['prid'], request.POST['pid']])
  604. r = cursor.fetchall()
  605. if(r[0][0]!=0):
  606. with connection.cursor() as cursor:
  607. cursor.execute('select name, guide_id, panel_id from member, guide where guide_id=id;')
  608. row=cursor.fetchall()
  609. row2 = [y for y in[x for x in row]]
  610. row3 = [{'Guide Name':row2[i][0], 'Guide ID':row2[i][1], 'Panel ID':row2[i][2]} for i in range(len(row2))]
  611. with connection.cursor() as cursor:
  612. cursor.execute('select id from panel;')
  613. row=cursor.fetchall()
  614. row2 = [y for y in[x for x in row]]
  615. row4 = [{'Panel ID':row2[i][0]} for i in range(len(row2))]
  616. with connection.cursor() as cursor:
  617. cursor.execute('select id from project;')
  618. row=cursor.fetchall()
  619. row2 = [y for y in[x for x in row]]
  620. row5 = [{'Project ID':row2[i][0]} for i in range(len(row2))]
  621. return render(request, 'project_management/assignpanel.html', {'data':"Panel already assigned", 'data2':row4, 'data3':row3, 'data4':row5})
  622. with connection.cursor() as cursor:
  623. cursor.execute('insert into panel_proj values(%s, %s, "F");',[request.POST['prid'], request.POST['pid']])
  624. return render(request, 'project_management/admin.html', {'data':"Assigned the panel"})
  625.  
  626. def assignedpanelgrades(request):
  627. if not request.user.is_authenticated:
  628. return render(request, 'project_management/adminlogin.html', {'data':"Login again"})
  629. with connection.cursor() as cursor:
  630. cursor.execute('update panel_proj set grade = %s where panel_id=%s and project_id=%s;',[request.POST['grade'], request.POST['pid'], request.POST['prid']])
  631. return render(request, 'project_management/admin.html', {'data':"Assigned the grades"})
  632.  
  633. def markcheckpoint(request):
  634. if not request.user.is_authenticated:
  635. return render(request, 'project_management/studentlogin.html', {'data':"Login again"})
  636. return render(request, 'project_management/markcheckpoint.html')
  637.  
  638. def markedcheckpoint(request):
  639. if not request.user.is_authenticated:
  640. return render(request, 'project_management/studentlogin.html', {'data':"Login again"})
  641. a = request.POST.get('cp')
  642. with connection.cursor() as cursor:
  643. cursor.execute('update proj_guide set checkpoint=%s where project_id in (select id from project, student where id = proj_id and rollno=%s);', [a, request.user.username])
  644. return render(request, 'project_management/markcheckpoint.html', {'data':"Updated the checkpoint"})
  645.  
  646. def changecheckpoint(request):
  647. if not request.user.is_authenticated:
  648. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  649. with connection.cursor() as cursor:
  650. cursor.execute('select project_id from proj_guide where guide_id=%s;', [request.user.username])
  651. row = cursor.fetchall()
  652. row1 = [y for x in row for y in x]
  653. return render(request, 'project_management/changecheckpoint.html', {'data1':row1})
  654.  
  655. def changedcheckpoint(request):
  656. if not request.user.is_authenticated:
  657. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  658. with connection.cursor() as cursor:
  659. cursor.execute('select count(*) from proj_guide where guide_id=%s and project_id=%s;', [request.user.username, request.POST['pid']])
  660. r=cursor.fetchall()
  661. if(r[0][0]==0):
  662. with connection.cursor() as cursor:
  663. cursor.execute('select project_id from proj_guide where guide_id=%s;', [request.user.username])
  664. row = cursor.fetchall()
  665. row1 = [y for x in row for y in x]
  666. return render(request, 'project_management/changecheckpoint.html', {'data':"Enter supervising project IDs only", 'data1':row1})
  667. a = request.POST.get('cp')
  668. with connection.cursor() as cursor:
  669. cursor.execute('update proj_guide set checkpoint=%s where guide_id=%s and project_id=%s;', [a, request.user.username, request.POST['pid']])
  670. with connection.cursor() as cursor:
  671. cursor.execute('select project_id from proj_guide where guide_id=%s;', [request.user.username])
  672. row = cursor.fetchall()
  673. row1 = [y for x in row for y in x]
  674. return render(request, 'project_management/changecheckpoint.html', {'data':"Changed the checkpoint", 'data1':row1})
  675.  
  676. def seeprojectdetails(request):
  677. if not request.user.is_authenticated:
  678. return render(request, 'project_management/studentlogin.html', {'data':"Login again"})
  679. with connection.cursor() as cursor:
  680. cursor.execute('select guide.name, guide.id, attendance, next_meet, topic, credits, checkpoint, deadline, student.proj_id from supervisor, guide, student, project, proj_guide where student.proj_id = project.id and proj_guide.guide_id=guide.id and proj_guide.project_id=project.id and rollno=%s and supervisor.student_roll=rollno and guide.id = supervisor.guide_id;',[request.user.username])
  681. row = cursor.fetchall()
  682. row2 = [y for y in[x for x in row]]
  683. row3 = [{'Professor Name':row2[i][0], 'Professor ID':row2[i][1], 'Attendance':row2[i][2], 'Next Meet':row2[i][3], 'Project Topic':row2[i][4], 'Credits':row2[i][5], 'Checkpoint':row2[i][6], 'Deadline':row2[i][7], 'Project ID':row2[i][8]} for i in range(len(row2))]
  684. with connection.cursor() as cursor:
  685. cursor.execute('select student.proj_id, type, location, documents.id from student, documents where student.proj_id = documents.proj_id and rollno=%s;',[request.user.username])
  686. row = cursor.fetchall()
  687. row2 = [y for y in[x for x in row]]
  688. row4 = [{'Project ID':row2[i][0], 'Type':row2[i][1], 'Location':row2[i][2], 'Document ID':row2[i][3]} for i in range(len(row2))]
  689. return render(request, 'project_management/showprojectinfo.html', {'data1':row3, 'data2':row4})
  690.  
  691. def projectdetailsemployee(request):
  692. if not request.user.is_authenticated:
  693. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  694. with connection.cursor() as cursor:
  695. cursor.execute('select student.name, rollno, attendance, next_meet, topic, credits, checkpoint, deadline, grade, project.id from supervisor, guide, student, project, proj_guide where student.proj_id = project.id and proj_guide.guide_id=guide.id and proj_guide.project_id=project.id and guide.id=%s and supervisor.student_roll=rollno and guide.id = supervisor.guide_id;',[request.user.username])
  696. row = cursor.fetchall()
  697. row2 = [y for y in[x for x in row]]
  698. row3 = [{'Student Name':row2[i][0], 'Student Roll Number':row2[i][1], 'Attendance':row2[i][2], 'Next Meet':row2[i][3], 'Project Topic':row2[i][4], 'Credits':row2[i][5], 'Checkpoint':row2[i][6], 'Deadline':row2[i][7], 'Grade':row2[i][8], 'Project ID':row2[i][9]} for i in range(len(row2))]
  699. with connection.cursor() as cursor:
  700. cursor.execute('select student.name, rollno, student.proj_id, type, location, documents.id from supervisor, student, documents where student.proj_id = documents.proj_id and supervisor.guide_id=%s and supervisor.student_roll=rollno;',[request.user.username])
  701. row = cursor.fetchall()
  702. row2 = [y for y in[x for x in row]]
  703. row4 = [{'Student Name':row2[i][0], 'Student Roll Number':row2[i][1], 'Project ID':row2[i][2], 'Type':row2[i][3], 'Location':row2[i][4], 'Document ID':row2[i][5]} for i in range(len(row2))]
  704. return render(request, 'project_management/showprojectinfoemployee.html', {'data1':row3, 'data2':row4})
  705.  
  706. def finalgradesstudent(request):
  707. if not request.user.is_authenticated:
  708. return render(request, 'project_management/studentlogin.html', {'data':"Login again"})
  709. with connection.cursor() as cursor:
  710. cursor.execute('select grade from supervisor, student where rollno=supervisor.student_roll and rollno=%s;', [request.user.username])
  711. row = cursor.fetchall()
  712. row1 = [y for x in row for y in x]
  713. with connection.cursor() as cursor:
  714. cursor.execute('select grade from panel_proj, student where proj_id=project_id and rollno=%s;', [request.user.username])
  715. row2 = cursor.fetchall()
  716. row3 = [y for x in row2 for y in x]
  717. d = {'A':10, 'A-':9, 'B':8, 'B-':7, 'C':6, 'C-':5, 'D':4, 'D-':3, 'E':2, 'E-':1, 'F':0}
  718. print (row1)
  719. print (row3)
  720. for i in range(len(row3)):
  721. print (int(d[row3[i]])!=0 or int(d[row1[0]])!=0)
  722. if(abs(d[row3[i]]-d[row1[0]])<=2 and (int(d[row3[i]])!=0 or int(d[row1[0]])!=0)):
  723. ans = (d[row3[i]]+d[row1[0]])/2
  724. print (d[row3[i]])
  725. print (d[row1[0]])
  726. print (ans)
  727. return render(request, 'project_management/showfinalgradesstudent.html', {'data1':ans})
  728. return render(request, 'project_management/showfinalgradesstudent.html', {'data1':"Not yet finalized"})
  729.  
  730. def updateprojects(request):
  731. if not request.user.is_authenticated:
  732. return render(request, 'project_management/studentlogin.html', {'data':"Login again"})
  733. with connection.cursor() as cursor:
  734. cursor.execute('select project_topic from past_projects, student where rollno=%s and rollno=student_roll;', [request.user.username])
  735. row = cursor.fetchall()
  736. row2 = [y for x in row for y in x]
  737. return render(request, 'project_management/updatepastprojects.html', {'data1':row2})
  738.  
  739. def updateinterests(request):
  740. if not request.user.is_authenticated:
  741. return render(request, 'project_management/studentlogin.html', {'data':"Login again"})
  742. with connection.cursor() as cursor:
  743. cursor.execute('select interest_area from stud_interest, student where rollno=%s and rollno=student_roll;', [request.user.username])
  744. row = cursor.fetchall()
  745. row2 = [y for x in row for y in x]
  746. return render(request, 'project_management/updateinterests.html', {'data1':row2})
  747.  
  748. def updatedprojects(request):
  749. if not request.user.is_authenticated:
  750. return render(request, 'project_management/studentlogin.html', {'data':"Login again"})
  751. with connection.cursor() as cursor:
  752. cursor.execute('insert into past_projects values(%s, %s);', [request.user.username, request.POST['project']])
  753. with connection.cursor() as cursor:
  754. cursor.execute('select project_topic from past_projects, student where rollno=%s and rollno=student_roll;', [request.user.username])
  755. row = cursor.fetchall()
  756. row2 = [y for x in row for y in x]
  757. return render(request, 'project_management/updatepastprojects.html', {'data1':row2})
  758.  
  759. def updatedinterests(request):
  760. if not request.user.is_authenticated:
  761. return render(request, 'project_management/studentlogin.html', {'data':"Login again"})
  762. with connection.cursor() as cursor:
  763. cursor.execute('insert into stud_interest values(%s, %s);', [request.user.username, request.POST['interest']])
  764. with connection.cursor() as cursor:
  765. cursor.execute('select interest_area from stud_interest, student where rollno=%s and rollno=student_roll;', [request.user.username])
  766. row = cursor.fetchall()
  767. row2 = [y for x in row for y in x]
  768. return render(request, 'project_management/updateinterests.html', {'data1':row2})
  769.  
  770. def updatepub(request):
  771. if not request.user.is_authenticated:
  772. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  773. with connection.cursor() as cursor:
  774. cursor.execute('select publication from guide_pub, guide where id=%s and id=guide_pub.guide_id;', [request.user.username])
  775. row = cursor.fetchall()
  776. row2 = [y for x in row for y in x]
  777. return render(request, 'project_management/updatepub.html', {'data1':row2})
  778.  
  779. def updateinterestsguide(request):
  780. if not request.user.is_authenticated:
  781. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  782. with connection.cursor() as cursor:
  783. cursor.execute('select interest_area from guide_interest, guide where id=%s and id=guide_interest.guide_id;', [request.user.username])
  784. row = cursor.fetchall()
  785. row2 = [y for x in row for y in x]
  786. return render(request, 'project_management/updateinterestguide.html', {'data1':row2})
  787.  
  788. def updatedpub(request):
  789. if not request.user.is_authenticated:
  790. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  791. with connection.cursor() as cursor:
  792. cursor.execute('insert into guide_pub values(%s, %s);', [request.user.username, request.POST['pub']])
  793. with connection.cursor() as cursor:
  794. cursor.execute('select publication from guide_pub, guide where id=%s and id=guide_pub.guide_id;', [request.user.username])
  795. row = cursor.fetchall()
  796. row2 = [y for x in row for y in x]
  797. return render(request, 'project_management/updatepub.html', {'data1':row2})
  798.  
  799. def updatedinterestsguide(request):
  800. if not request.user.is_authenticated:
  801. return render(request, 'project_management/employeelogin.html', {'data':"Login again"})
  802. with connection.cursor() as cursor:
  803. cursor.execute('insert into guide_interest values(%s, %s);', [request.user.username, request.POST['interest']])
  804. with connection.cursor() as cursor:
  805. cursor.execute('select interest_area from guide_interest, guide where id=%s and id=guide_interest.guide_id;', [request.user.username])
  806. row = cursor.fetchall()
  807. row2 = [y for x in row for y in x]
  808. return render(request, 'project_management/updateinterestguide.html', {'data1':row2})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement