-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·880 lines (562 loc) · 25.2 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
from flask import Flask, render_template, request, redirect, flash,url_for
from model import *
from flask_login import LoginManager, login_required, login_user, logout_user, current_user
from flask_mail import Mail, Message
from itsdangerous import URLSafeTimedSerializer
import datetime
import random
from jinja2 import Environment, FileSystemLoader
from weasyprint import HTML
app = Flask(__name__)
app.secret_key = 'MKhJHJH798798kjhkjhkjGHh'
app.config.from_pyfile('config.cfg')
mail = Mail(app)
s = URLSafeTimedSerializer('MKhJHJH798798kjhkjhkjGHh')
@app.route("/",methods=["GET"])
def index():
if 'username' in session:
return render_template("home.html",logged_in=True,username=session['username'],access=access)
else:
return render_template("home.html",logged_in=False,username=None,access=access)
@app.route('/login',methods=['POST','GET'])
def login():
print "aaaaaa"
print access
print "aaaaaa"
if request.method == 'GET':
if 'username' in session:
return render_template("result.html",message="Already logged in!!!",logged_in=True,username=session['username'],access=access)
#return render_template("login.html",logged_in=True,username=session['username'])
else:
return render_template("login.html",logged_in=False,username=None,access=access)
if request.method == 'POST':
next = request.values.get('next')
if(authenticate(request)==False):
return render_template("result.html",message="Login failed",logged_in=False,username=None,access=access)
#flash("Incorrect Credentials.", "danger")
#return render_template("login.html")
if(authenticate(request)==True):
print "hello"
if not next:
global access
access = 1
return render_template("result.html",message=session['username']+" is logged in successfully",logged_in=True,username=session['username'],access=access)
else:
return redirect(next)
@app.route('/loginstudent',methods = ['POST','GET'])
def loginstudent():
print "aaaaaa"
print access
print "aaaaaa"
if request.method == 'GET':
if 'username' in session:
return render_template("result.html",message="Already logged in!!!",logged_in=True,username=session['username'],access=access)
else:
return render_template("loginst.html",logged_in=False,username=None,access=access)
if request.method == 'POST':
if(authenticatest(request)==False):
return render_template("result.html",message="Login Failed",logged_in=False,username=None,access=access)
if(authenticatest(request)==True):
global access
access = 2
return render_template("result.html",message=session['username']+" is logged in successfully",logged_in=True,username=session['username'],access=access)
@app.route('/logout',methods=['GET'])
#@login_required
def logout():
if 'username' in session:
name = session.pop('username')
global access
access = 0
return render_template("result.html",message=name+" has logged out",access=access)
else:
return render_template("result.html",message="Not logged in",access=access)
@app.route("/signup",methods=["GET","POST"])
def signup():
if 'username' in session:
return render_template("signup.html",logged_in=True,username=session['username'],access=access)
else:
return render_template("signup.html",logged_in=False,username=None,access=access)
#return render_template("signup.html")
@app.route("/signedup",methods=["POST"])
def signedup():
#if 'username' in session:
# return render_template("result.html",message=session['username']+" has to log out first :-(",logged_in=True,username=session['username'],access=access)
#else:
username = request.form['username']
password = request.form['password']
phone = request.form.get('phone')
email = request.form.get('email')
selected = request.form.get('abcd')
print selected
if str(selected) == "email":
token = s.dumps(email, salt='email-confirm')
msg = Message('Confirm Email',sender='batragaurav@gmail.com',recipients=[email])
link = url_for('confirm_email',token=token,_external=True)
msg.body = "Your link is {}. you can also login with otp".format(link)
mail.send(msg)
session['field1']=username
session['field2']=phone
session['field3']=password
session['field4']=email
return render_template("result.html",logged_in=True,username=session['username'],message="send for verification",access=access)
elif str(selected) == "otp":
print "hello"
token = s.dumps(email, salt='email-confirm')
msg = Message('Confirm OTP', sender='batragaurav2616@gmail.com',recipients=[email])
link =url_for('confirm_otp',token=token,_external=True)
otp = random.randint(1000000,9999999)
msg.body = "your otp is {}".format(otp)
mail.send(msg)
session['field1']=username
session['field2']=phone
session['field3']=password
session['field4']=email
session['field5']=otp
return render_template("homepage.html",access=access,logged_in=True,username=session['username'])
else:
print "ggkk"
@app.route('/confirm_email/<token>')
def confirm_email(token):
try:
email = s.loads(token, salt='email-confirm',max_age=300)
insert_admin(session['field1'],session['field2'],session['field3'],session['field4'])
session.pop('field1')
session.pop('field2')
session.pop('field3')
session.pop('field4')
return render_template("result.html",message="successfully verified",logged_in=True,username=session['username'],access=access)
except Exception as e:
return render_template("result.html",message=e,logged_in=True,username=session['username'],access=access)
# return render_template("result.html",message="token works")
@app.route('/confirm_otp',methods=['POST','GET'])
def confirm_otp():
try:
if request.method == "POST":
print request.form
value = request.form.get('otp')
print value
print session['field5']
#email = s.loads(token, salt='email-confirm',max_age=300)
if(str(session['field5'])==str(value)):
insert_admin(session['field1'],session['field2'],session['field3'],session['field4'])
session.pop('field1')
session.pop('field2')
session.pop('field3')
session.pop('field4')
session.pop('field5')
return render_template("result.html",message="verified",logged_in=True,username=session['username'],access=access)
elif(str(session['field5']) != str(value)):
return render_template("homepage.html",access=access,logged_in=True,username=session['username'])
session.pop('field1')
session.pop('field2')
session.pop('field3')
session.pop('field4')
else:
return render_template("result.html",logged_in=True,username=session['username'],access=access)
except Exception as e:
return render_template("result.html",message=e,access=access)
#def verifyotp(otp):
# if otp ==
@app.route('/issuesresolution',methods=['GET'])
def resolution():
try:
if request.method == "GET":
data = queryissues()
print data
fees=calcLateFees(data[0][4].encode('ascii','ignore'),datetime.datetime.today().strftime("%d-%m-%Y"))
print fees
print datetime.datetime.today().strftime("%d-%m-%Y")
studentdetails = queryst(data)
print studentdetails
bookdetails = querybk(data)
print bookdetails
email = []
for i in range(0,len(data)):
email.append(queryemail(data[i][2]))
print email[0][0][0].encode('ascii','ignore')
print len(email)
a=len(bookdetails)
a=[bookdetails,studentdetails,a]
flag=1
#return render_template("showissues.html",logged_in=True,username=session['username'],access=access,a=a,flag=flag)
for i in range(0,len(email)):
print "hello"
env = Environment(loader=FileSystemLoader('.'))
template = env.get_template("./templates/issueresolution.html")
template_vars = {
"transactionid": data[i][0],
"bookid" : data[i][1],
"studentid" : data[i][2],
"studentname" : studentdetails[i][2],
"adminid" : data[i][3],
"dateofissue" : data[i][4],
"latefees" : calcLateFees(data[i][4].encode('ascii','ignore'),datetime.datetime.today().strftime("%d-%m-%Y")),
"bookname" : bookdetails[i][0],
"bookauthor" : bookdetails[i][2]
}
print template_vars
html_out = template.render(template_vars)
HTML(string=html_out).write_pdf("issuesresolution.pdf")
#token=s.dumps(list(emails[0][0])[0],salt='email-confirm')
msg= Message('Pending dues',sender='batragaurav2616@gmail.com',recipients=[email[i][0][0].encode('ascii','ignore')])
msg.body = "The following books are Overdue.Please return/renew them as soon as possible to avoid increasing fines"
with app.open_resource("issuesresolution.pdf") as file:
msg.attach("issuesresolution.pdf","issuesresolution/pdf",file.read())
mail.send(msg)
return render_template("mail.html",logged_in=True,username=session['username'],access=access,studentdetails=studentdetails,bookdetails=bookdetails)
#msg = M
except Exception as e:
return render_template("showissues.html",logged_in=True,username=session['username'],access=access,a=a,flag=flag)
@app.route('/showall', methods=["GET"])
def showall():
rows = getAll()
#return render_template('showall.html',rows=rows,message="LIST OF BOOKS")
if 'username' in session:
return render_template("showall.html",logged_in=True,username=session['username'],rows=rows,message="LIST OF BOOKS",access=access)
else:
return render_template("showall.html",logged_in=False,username=None,rows=rows,message="LIST OF BOOKS",access=access)
@app.route('/contact')
def contact():
#return render_template('contact.html')
if 'username' in session:
return render_template("contact.html",logged_in=True,username=session['username'],access=access)
else:
return render_template("contact.html",logged_in=False,username=None,access=access)
@app.route('/addbooks')
def addbooks():
if 'username' in session and access == 1:
return render_template("addbooks.html",logged_in=True,username=session['username'],access=access)
elif 'username' in session and access == 2:
return render_template("result.html",message="Only ADMINS can add books",logged_in=True,username=session['username'],access=access)
else:
return render_template("result.html",message="Only ADMINS can add books",logged_in=False,username=None,access=access)
#return render_template("addbooks.html",logged_in=False,username=None)
#return render_template('addbooks.html')
@app.route('/added',methods=["POST"])
def added():
name = request.form['name']
author = request.form['author']
category = request.form.get('category')
#if not session.get("logged_in"):
insert_books(name,author,category)
if 'username' in session and access == 1:
return render_template("added.html",logged_in=True,username=session['username'],access=access)
elif 'username' in session and access == 2:
return render_template("added.html",logged_in=True,username=session['username'],access=access)
else:
return render_template("added.html",logged_in=False,username=None,access=access)
#return render_template("added.html",name=name)
@app.route('/searchbook', methods=["POST"])
def searchBook():
if request.method == "POST":
book = {
"name": request.form.get('name'),
"author": request.form.get('author'),
"category": request.form.get('category')
}
books = querybook(book)
x=len(books)
if 'username' in session:
return render_template("searchbook.html",logged_in=True,username=session['username'],payload={"books":books},x=x,access=access)
else:
return render_template("searchbook.html",logged_in=False,username=None,payload={"books":books},x=x,access=access)
@app.route("/apply", methods=["POST", "GET"])
def studentApply():
if request.method == "GET":
if 'username' in session:
return render_template("apply.html",logged_in=True,username=session['username'],access=access)
else:
return render_template("apply.html",logged_in=False,username=None,access=access)
if request.method == "POST":
pass
student_form = {
"name" : request.form.get('name'),
"dob" : request.form.get('dob'),
"address" : request.form.get('address'),
"phone" : request.form.get('phone'),
"password" : request.form.get('password'),
"email" : request.form.get('email')
}
print student_form['password']
student_status = insertstudent_reg(student_form)
if student_status == False:
flash("error in data entered","danger")
return redirect("/apply")
else:
flash("Application sent for approval")
#return redirect("/")
if 'username' in session:
return render_template("result.html",message="Application sent for approval",logged_in=True,username=session['username'],access=access)
else:
return render_template("result.html",message="Application sent for approval",logged_in=False,username=None,access=access)
@app.route("/applications")
def studentapplications():
if 'username' in session and access == 1:
applications = querystudentreg()
count=0
for items in applications:
print len(items)/6
count+=len(items)/6
print count
return render_template("applications.html",payload={"applications":applications},logged_in=True,username=session['username'],count=count,access=access)
elif 'username' in session and access == 2:
print "hello"
return render_template("result.html",message="ADMIN ACCESS ALLOWED",logged_in=True,username=session['username'],access=access)
else:
return render_template("result.html",message="ADMIN ACCESS ALLOWED",logged_in=False,username=None,access=access)
@app.route("/reject/<int:regID>")
def rejectapplications(regID):
if 'username' in session and access == 1:
flag = deletestudentreg(regID)
if flag is False:
flash("error in rejecting. ","danger")
return redirect("/applications")
else:
return render_template("result.html",message="ADMIN ACCESS ALLOWED",logged_in=False,username=None,access=access)
@app.route("/accept/<int:regID>")
def acceptapplication(regID):
if 'username' in session and access == 1:
req_student = querysinglestudentreg(regID)
if req_student is not None:
student = {
"cardnum" : generate(),
"doj" : datetime.datetime.today().strftime("%d-%m-%Y"),
"borrowlimit" : 2,
"name" : req_student[1],
"dob" : req_student[2],
"address" : req_student[3],
"phone" : req_student[4],
"password" : req_student[5],
"email" : req_student[6]
}
print student["password"]
flag = insertStudent(student)
deletestudentreg(regID)
if flag is False:
return render_template("result.html",message="IS UNABLE TO LOGIN",logged_in=False,username=None,access=access)
return render_template("reg.html",message="SUCCESSFULLY REGISTERED",logged_in=False,username=None,access=access)
else:
return render_template("result.html",message="ADMIN ACCESS ALLOWED",logged_in=False,username=None,access=access)
@app.route("/issuereturn", methods=["GET"])
def issuereturn():
if 'username' in session:
#print session['username'].id
return render_template("issuereturn.html",logged_in=True,username=session['username'],access=access)
else:
return render_template("result.html",logged_in=False,username=None,message="NOT LOGGED IN",access=access)
@app.route("/issue",methods=["POST"])
def issuebook():
if request.method == "POST":
issueRequest = {
"bookID" : request.form.get('bookID'),
"studentid":request.form.get('studentid'),
"adminid":request.form.get('adminid'),
"issueDate" : datetime.datetime.today().strftime("%d-%m-%Y")
}
print issueRequest["adminid"]
book_exists = existence_book(issueRequest.get("bookID"))
print book_exists
student_exists = existence_student(issueRequest.get("studentid"))
print student_exists
if book_exists is True:
if student_exists is True:
book_status = getbookstatus(issueRequest.get("bookID"))
print book_status
borrowlimit_check = existence_borrowlimit(issueRequest.get("studentid"))
print borrowlimit_check
if book_status is True:
if borrowlimit_check is True:
insert_status = insertIssue(issueRequest)
print insert_status
if insert_status is False:
print "error is issueing. "
return render_template("result.html",message="Error in issueing",logged_in=True,username=session['username'],access=access)
else:
print "Cannot borrow more"
return render_template("result.html",message="Cannot borrow more",logged_in=True,username=session['username'],access=access)
else:
print "Book is issued"
return render_template("result.html",message="Book is issued",logged_in=True,username=session['username'],access=access)
else:
print "student doesnot exists"
return render_template("result.html",message="Student does not exist",logged_in=True,username=session['username'],access=access)
else:
print "book does not exist"
return render_template("result.html",message="Book does not exist",logged_in=True,username=session['username'],access=access)
return render_template("result.html",message="Successfull",logged_in=True,username=session['username'],access=access)
@app.route("/return",methods=["POST"])
def returnBook():
if 'username' in session:
if request.method == "POST":
return_book = {
"bookid" : request.form.get("bookID"),
#"returnedtoID" : request.form.get("adminid")
}
issue = queryissuebybook(return_book.get("bookid"))
if issue is not None:
return_book["transid"]=issue[0]
return_book["studentid"]=issue[2]
return_book["issuedbyid"]=issue[3]
return_book["issueDate"]=issue[4]
return_book["returnDate"]=datetime.datetime.today().strftime("%d-%m-%Y")
return_book["lateFees"] = calcLateFees(return_book["issueDate"],return_book["returnDate"])
print return_book["lateFees"]
flag = insertissuehistory(return_book)
if flag is False:
return render_template("result.html",message="Error in returning",logged_in=True,username=session['username'],access=access)
else:
deleteissue(return_book["transid"])
if return_book["lateFees"] > 0:
return render_template("result.html",message="you have to pay rs {} as fine".format(return_book["lateFees"]),logged_in=True,username=session['username'],access=access)
else:
return render_template("result.html",message="Book returned successfully",logged_in=True,username=session['username'],access=access)
else:
return render_template("result.html",message="Book is not issued yet",logged_in=True,username=session['username'],access=access)
return redirect("/issuereturn")
else:
return render_template("result.html",message="log in first",logged_in=True,username=session['username'],access=access)
@app.route("/searchstudent", methods=["POST","GET"])
def searchstudent():
if 'username' in session and access == 1:
if request.method == "GET":
return render_template("searchstudent.html", payload={"type":"student"},logged_in=True,username=session['username'],access=access)
if request.method == "POST":
student = {
"id" : request.form.get('id'),
"name" : request.form.get('name'),
"cardnum": request.form.get('cardnum')
}
for items in student:
print student[items]
students = querystudent(student)
return render_template("searchstudent.html", payload={"students": students},access=access,logged_in=True,username=session['username'])
elif 'username' in session and access == 2:
return render_template("result.html", message="ADMIN ACCESS ALLOWED",logged_in=True,username=session['username'],access=access)
else:
return render_template("result.html", message="ADMIN ACCESS ALLOWED",logged_in=False,username=None,access=access)
@app.route('/allbooks')
def allbooks():
rows = getAll()
if 'username' in session:
return render_template("allbooks.html",logged_in=True,username=session['username'],rows=rows,message="LIST OF BOOKS",access=access)
else:
return render_template("allbooks.html",logged_in=False,username=None,rows=rows,message="LIST OF BOOKS",access=access)
@app.route('/allbooks1')
def allbooks1():
rows = getAll()
if 'username' in session:
return render_template("allbooks1.html",logged_in=True,username=session['username'],rows=rows,message="LIST OF BOOKS",access=access)
else:
return render_template("allbooks1.html",logged_in=False,username=None,rows=rows,message="LIST OF BOOKS",access=access)
@app.route('/allbooks2')
def allbooks2():
rows = getAll()
if 'username' in session:
return render_template("allbooks2.html",logged_in=True,username=session['username'],rows=rows,message="LIST OF BOOKS",access=access)
else:
return render_template("allbooks2.html",logged_in=False,username=None,rows=rows,message="LIST OF BOOKS",access=access)
@app.route('/allbooks3')
def allbooks3():
rows = getAll()
if 'username' in session:
return render_template("allbooks3.html",logged_in=True,username=session['username'],rows=rows,message="LIST OF BOOKS",access=access)
else:
return render_template("allbooks3.html",logged_in=False,username=None,rows=rows,message="LIST OF BOOKS",access=access)
@app.route('/allbooks4')
def allbooks4():
rows = getAll()
if 'username' in session:
return render_template("allbooks4.html",logged_in=True,username=session['username'],rows=rows,message="LIST OF BOOKS",access=access)
else:
return render_template("allbooks4.html",logged_in=False,username=None,rows=rows,message="LIST OF BOOKS",access=access)
@app.route('/allbooks5')
def allbooks5():
rows = getAll()
if 'username' in session:
return render_template("allbooks5.html",logged_in=True,username=session['username'],rows=rows,message="LIST OF BOOKS",access=access)
else:
return render_template("allbooks5.html",logged_in=False,username=None,rows=rows,message="LIST OF BOOKS",access=access)
@app.route('/allbooks6')
def allbooks6():
rows = getAll()
if 'username' in session:
return render_template("allbooks6.html",logged_in=True,username=session['username'],rows=rows,message="LIST OF BOOKS",access=access)
else:
return render_template("allbooks6.html",logged_in=False,username=None,rows=rows,message="LIST OF BOOKS",access=access)
@app.route('/allbooks7')
def allbooks7():
rows = getAll()
if 'username' in session:
return render_template("allbooks7.html",logged_in=True,username=session['username'],rows=rows,message="LIST OF BOOKS",access=access)
else:
return render_template("allbooks7.html",logged_in=False,username=None,rows=rows,message="LIST OF BOOKS",access=access)
@app.route('/allbooks8')
def allbooks8():
rows = getAll()
if 'username' in session:
return render_template("allbooks8.html",logged_in=True,username=session['username'],rows=rows,message="LIST OF BOOKS",access=access)
else:
return render_template("allbooks8.html",logged_in=False,username=None,rows=rows,message="LIST OF BOOKS",access=access)
@app.route('/allbooks9')
def allbooks9():
rows = getAll()
if 'username' in session:
return render_template("allbooks9.html",logged_in=True,username=session['username'],rows=rows,message="LIST OF BOOKS",access=access)
else:
return render_template("allbooks9.html",logged_in=False,username=None,rows=rows,message="LIST OF BOOKS",access=access)
@app.route('/allbooks10')
def allbooks10():
rows = getAll()
if 'username' in session:
return render_template("allbooks10.html",logged_in=True,username=session['username'],rows=rows,message="LIST OF BOOKS",access=access)
else:
return render_template("allbooks10.html",logged_in=False,username=None,rows=rows,message="LIST OF BOOKS",access=access)
@app.route('/adminrights')
def adminrights():
#return render_template('contact.html')
print access
if 'username' in session and access == 1:
return render_template("adminrights.html",logged_in=True,username=session['username'],access=access)
elif 'username' in session and access == 2:
return render_template("result.html",message="log in first",logged_in=True,username=session['username'],access=access)
else:
return render_template("result.html",message="log in first",logged_in=False,username=None,access=access)
@app.route('/studentinfo')
def studentinfo():
if 'username' in session and access == 2:
print session['username']
info=getinfo(session['username'])
books=findbooks(session['username'])
x=0
if books != None:
x=1
return render_template("studentinfo.html",logged_in=True,books=books,info=info,username=session['username'],access=access,x=x)
else:
return render_template("studentinfo.html",logged_in=True,books=[],info=info,username=session['username'],access=access,x=x)
elif 'username' in session and access == 1:
return render_template("result.html",message='LOGIN as student FIRST',logged_in=True,username=session['username'],access=access)
else:
return render_template("result.html",message='LOGIN FIRST',logged_in=False,username=None,access=access)
@app.route('/viewadmins')
def viewadmins():
if 'username' in session and access == 1:
x=viewadmins1()
return render_template("viewadmins.html",logged_in=True,username=session['username'],x=x,access=access)
elif 'username' in session and access == 2:
return render_template("result.html",message="log in first",logged_in=True,username=session['username'],access=access)
else:
return render_template("result.html",message="log in first",logged_in=False,username=None,access=access)
@app.route('/showissues')
def showissue():
data = showissued()
print data
bookdetails = querybk(data)
print bookdetails
studentdetails = queryst(data)
print studentdetails
a=len(bookdetails)
a=[bookdetails,studentdetails,a]
flag=0
return render_template("showissues.html",a=a,flag=flag,logged_in=True,username=session['username'],access=access)
access = 0
app.run(debug=True)