-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
executable file
·513 lines (468 loc) · 24.5 KB
/
app.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
from flask import Flask,flash, request, render_template, redirect, url_for, session, json, jsonify
from models import *
from authentication import *
from department import *
from books import *
from staff import *
from periodicals import *
from transactions import *
import datetime
app = Flask("__name__")
app.config.from_object('settings')
# app.config.from_pyfile('config.cfg')
# db.init_app(app)
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'login'
allDepts = Department.query.all()
allUsers = User.query.all()
allSubj = Subject.query.all()
allAuthors = Author.query.all()
allPubs = Publisher.query.all()
allBooks = Book.query.all()
allPeriodicals = Periodicals.query.all()
allTransactions = Transaction.query.all()
currentYear = str(datetime.datetime.today().year)
@login_manager.user_loader
def load_user(username):
return User.query.get(int(username))
def admin_required(f):
@wraps(f)
def is_admin(*args, **kwargs):
if not current_user.is_authenticated or not current_user.admin:
logout_user()
session['adminerror'] = "UNAUTHORIZED ACTION. LOG IN AGAIN"
return redirect(url_for('login'))
else:
return f(*args, **kwargs)
return is_admin
@app.route('/logout')
@login_required
def logout():
logout_user()
return render_template('index.html', currentYear=currentYear, allDepts=allDepts)
@app.route('/')
def homepage():
return render_template('home.html', currentYear=currentYear, allDepts=allDepts)
@app.route('/library-rules')
def rules():
return render_template('rules.html', currentYear=currentYear, allDepts=allDepts)
@app.route('/login', methods=['GET','POST'])
def login():
logout_user()
admin_error_msg = session.get('adminerror', None)
if (request.method=='POST'):
status, staff = signin_user()
if status:
login_user(staff)
if staff.admin:
return redirect(url_for('admin'))
else:
return redirect(url_for('view_books'))
# return render_template('admin.html', allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
else:
errorM = "One of given fields is Incorrect. Try Again."
return render_template('login.html', errorM=errorM, allDepts=allDepts, currentYear=currentYear)
return render_template('login.html', allDepts=allDepts, currentYear=currentYear, admin_error_msg=admin_error_msg)
@app.route('/admin', methods=['GET','POST'])
@login_required
@admin_required
def admin():
email = current_user.user_mail
return render_template('admin.html', email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
@app.route('/user/<id>', methods=['POST'])
@login_required
@admin_required
def post_single_user(id):
# return "POST"
status, found_user, e = update_user(id)
if not status:
db.session.rollback()
msg_error = ""
if e:
msg_error = e
else:
msg_error = "An Error Occured"
return render_template('user.html', found_user=found_user, msg_error=msg_error, currentYear=currentYear, allDepts=allDepts, allUsers=allUsers)
else:
msg_success = "User Details Updated"
return render_template('user.html', found_user=found_user, msg_success=msg_success, currentYear=currentYear, allDepts=allDepts, allUsers=allUsers)
@app.route('/user/<id>', methods=['GET'])
@login_required
@admin_required
def single_user(id):
status, found_user = get_single_user(id)
if status:
return render_template('user.html', found_user=found_user, currentYear=currentYear, allDepts=allDepts, allUsers=allUsers)
else:
msg_error=found_user
return render_template('users.html', msg_error=msg_error, currentYear=currentYear, allDepts=allDepts, allUsers=allUsers)
@app.route('/users', methods=['GET','POST'])
@login_required
@admin_required
def users_info():
if request.method == "POST":
status, option, result = filter_user()
if status:
if option == "Number":
return redirect(url_for('single_user', id=result.user_phone_number))
else:
filterResults = result
return render_template('users.html', filterResults=filterResults, currentYear=currentYear, allDepts=allDepts, allUsers=allUsers)
else:
if option == "Number":
msg_error="User NOt Found. Try Again."
else:
msg_error = "An Error Occurred. Try Again."
return render_template('users.html', msg_error=msg_error, currentYear=currentYear, allDepts=allDepts, allUsers=allUsers)
return render_template('users.html', currentYear=currentYear, allDepts=allDepts, allUsers=allUsers)
@app.route('/adddept', methods=['GET','POST'])
@login_required
@admin_required
def addDept():
if (request.method=='POST'):
email = current_user.user_mail
status, result = add_dept()
msg_success = ""
msg_error = ""
allDepts = Department.query.all()
if status:
# true
msg_success = "Department Successfully Added"
else:
#repeat
msg_error = "Department Name Already Exists"
return render_template('admin.html', email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks, msg_success=msg_success, msg_error=msg_error)
return redirect(url_for('admin'))
@app.route('/addsubj', methods=['GET','POST'])
@login_required
@admin_required
def addSubj():
if (request.method=='POST'):
email = current_user.user_mail
status = add_subj()
msg_success = ""
msg_error = ""
allSubj = Subject.query.all()
if status:
# true
msg_success = "Subject Successfully Added"
else:
#repeat
msg_error = "Subject Name Already Exists"
return render_template('admin.html', email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks, msg_error=msg_error, msg_success=msg_success)
return redirect(url_for('admin'))
@app.route('/addpub', methods=['GET','POST'])
@login_required
@admin_required
def addPub():
if (request.method=='POST'):
email = current_user.user_mail
status = new_publisher()
msg_success = ""
msg_error = ""
allPubs = Publisher.query.all()
if status:
# true
msg_success = "Publisher Successfully Added"
else:
#repeat
msg_error = "Publisher's Details Already Exists"
return render_template('admin.html', email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks, msg_error=msg_error, msg_success=msg_success)
return redirect(url_for('admin'))
@app.route('/addauthor', methods=['GET','POST'])
@login_required
@admin_required
def addAuthor():
if (request.method=='POST'):
email = current_user.user_mail
status = new_author()
msg_success = ""
msg_error = ""
allAuthors = Author.query.all()
if status:
# true
msg_success = "Author Successfully Added"
else:
#repeat
msg_error = "Author's Name Already Exists"
return render_template('admin.html', email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks, msg_error=msg_error, msg_success=msg_success)
return redirect(url_for('admin'))
@app.route('/getdept')
@login_required
def getdept():
return render_template('index.html')
@app.route('/viewbooks', methods=['GET'])
@login_required
def view_books():
return render_template('allbooks.html', allBooks=allBooks, allPubs=allPubs, currentYear=currentYear, allTransactions=allTransactions, allUsers=allUsers, allAuthors=allAuthors, allSubj=allSubj, allDepts=allDepts, allPeriodicals=allPeriodicals)
@app.route('/transactions/all', methods=['GET','POST'])
@login_required
@admin_required
def all_trans():
foundTrans = allTransactions
return render_template('alltrans.html', foundTrans=foundTrans, currentYear=currentYear, allUsers=allUsers)
@app.route('/transactions/<id>', methods=['GET','POST'])
@login_required
@admin_required
def user_trans(id):
found_trans, found_user = trans_list_user(id)
foundTrans = found_trans[1]
lstatus = found_trans[0]
return render_template('usertrans.html', lstatus=lstatus, foundTrans=foundTrans, found_user=found_user, allUsers=allUsers, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
@app.route('/reserve/<id>', methods=['GET','POST'])
@login_required
def reserve(id):
if not current_user.is_authenticated:
return redirect(url_for('login'))
name = current_user.user_name
status = reserve_book(id, name)
if status:
msg_success = "Book Reserved. Please Visit The Library to Complete Transaction."
return render_template('allbooks.html', msg_success=msg_success, allBooks=allBooks, allPubs=allPubs, currentYear=currentYear, allTransactions=allTransactions, allUsers=allUsers, allAuthors=allAuthors, allSubj=allSubj, allDepts=allDepts, allPeriodicals=allPeriodicals)
else:
msg_error = "Cannot Reserve Book. Visit the University Library for More Information."
return render_template('allbooks.html',msg_error=msg_error, msg_success=msg_success, allBooks=allBooks, allPubs=allPubs, currentYear=currentYear, allTransactions=allTransactions, allUsers=allUsers, allAuthors=allAuthors, allSubj=allSubj, allDepts=allDepts, allPeriodicals=allPeriodicals)
@app.route('/myreserves', methods=['GET'])
@login_required
def resve():
if not current_user.is_authenticated:
return redirect(url_for('login'))
username = current_user.user_name
status = ""
foundTrans = Reservations.query.filter_by(reserve_name=username).all()
if foundTrans:
status = True
else:
status = False
return render_template('myreserves.html', status=status, foundTrans=foundTrans, allAuthors=allAuthors, currentYear=currentYear, allBooks=allBooks, allDepts=allDepts, allSubj=allSubj, allPubs=allPubs)
@app.route('/reservations', methods=['GET','POST'])
@login_required
@admin_required
def adm_rese():
foundTrans = Reservations.query.all()
status = ""
if foundTrans:
status = True
else:
status = False
return render_template('myreserves.html', status=status, foundTrans=foundTrans, allAuthors=allAuthors, currentYear=currentYear, allBooks=allBooks, allDepts=allDepts, allSubj=allSubj, allPubs=allPubs)
@app.route('/transactions', methods=['GET','POST'])
@login_required
@admin_required
def trans():
session.pop('searched_user', None)
session.pop('searched_book', None)
if (request.method=='POST'):
email = current_user.user_mail
msg_error = ""
status, found_user = user_info()
if status:
session['searched_user'] = found_user.user_id
lstatus, ltrans = trans_list(found_user.user_id)
session['searched_status'] = lstatus
return render_template('transaction.html', found_user=found_user, lstatus=lstatus, ltrans=ltrans, email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
else:
msg_error = found_user
return render_template('transaction.html', msg_error=msg_error, email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
return render_template('transaction.html', allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
@app.route('/bookTrans', methods=['GET','POST'])
@login_required
@admin_required
def book_trans():
userid = session.get('searched_user', None)
found_user = User.query.filter_by(user_id=userid).first()
lstatus, ltrans = trans_list(found_user.user_id)
session.pop('searched_trans', None)
email = current_user.user_mail
# categoryexists = session.get('added_category', None)
if request.method == 'POST':
msg_error = ""
status, book, authors, subjects = book_info()
if status:
session['searched_book'] = book.book_id
return render_template('transaction.html', authors=authors, book=book, subjects=subjects, found_user=found_user, lstatus=lstatus, ltrans=ltrans, email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
else:
msg_error = "Book Not Found"
return render_template('transaction.html', msg_error=msg_error, found_user=found_user, lstatus=lstatus, ltrans=ltrans, email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
return render_template('transaction.html', found_user=found_user, lstatus=lstatus, ltrans=ltrans, email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
@app.route('/confirmborrow', methods=['GET','POST'])
@login_required
@admin_required
def confirm_borrow():
# if request.method == 'POST':
# return "BORROWS"
status = borrow()
msg_error=""
msg_success=""
if status:
msg_success = "Book Borrow Process Successful"
return render_template('transaction.html', msg_success=msg_success, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
else:
msg_error = "Error Occurred. Process Cancelled. There Could be No Copies Left to Borrow"
return render_template('transaction.html', msg_error=msg_error, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
# return redirect(url_for('trans'))
@app.route('/confirmreturn/<tid>', methods=['GET','POST'])
@login_required
@admin_required
def confirm_return(tid):
# if request.method == 'POST':
status = return_books(tid)
msg_error=""
msg_success=""
if status:
msg_success = "Book Return Process Successful"
return render_template('transaction.html', msg_success=msg_success, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
else:
msg_error = "Error Occurred. Process Cancelled."
return render_template('transaction.html', msg_error=msg_error, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
# return redirect(url_for('trans'))
@app.route('/books', methods=['GET','POST'])
@login_required
@admin_required
def addBook():
email = current_user.user_mail
allSubj = Subject.query.all()
if (request.method =='POST'):
status = new_book()
msg_success = ""
msg_error = ""
if status:
# true
msg_success = "New Arrival Successfully Added"
else:
#repeat
msg_error = "Arrival Already Registered, Please Update Instead"
return render_template('books.html', email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks, msg_error=msg_error, msg_success=msg_success, newArrivals=newArrivals)
return render_template('books.html', email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks, newArrivals=newArrivals)
@app.route('/getbook', methods=['GET','POST'])
@login_required
@admin_required
def getBook():
if (request.method =='POST'):
email = current_user.user_mail
allSubj = Subject.query.all()
status, book, bookauthor, booksubj, mainAuth, supAuth, bookSubjList = select_book()
msg_success = ""
msg_error = ""
if status:
# book found
return render_template('editbooks.html', bookauthor=bookauthor, bookSubjList=bookSubjList, booksubj=booksubj, mainAuth=mainAuth, supAuth=supAuth, email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks, msg_error=msg_error, msg_success=msg_success, newArrivals=newArrivals, book=book)
else:
#not found
msg_error = "Book Not Found"
return render_template('books.html', email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks, msg_error=msg_error, msg_success=msg_success, newArrivals=newArrivals)
return redirect(url_for('addBook'))
@app.route('/books/<book_id>', methods=['GET','POST'])
@login_required
def user_books_list(book_id):
status, book, bookauthor, booksubj, mainAuth, supAuth, bookSubjList = select_book(book_id)
msg_success = ""
msg_error = ""
if status:
return render_template('editbooks.html', bookauthor=bookauthor, bookSubjList=bookSubjList, booksubj=booksubj, mainAuth=mainAuth, supAuth=supAuth, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks, msg_error=msg_error, msg_success=msg_success, newArrivals=newArrivals, book=book)
else:
msg_error = "Book Not Found"
if request.method == "POST":
status, book, bookauthor, booksubj, mainAuth, supAuth, bookSubjList = update_book(book_id)
msg_success = ""
msg_error = ""
if status:
#final
msg_success = "Book Updated Successfully"
return render_template('editbooks.html', bookauthor=bookauthor, bookSubjList=bookSubjList, booksubj=booksubj, mainAuth=mainAuth, supAuth=supAuth, email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks, msg_error=msg_error, msg_success=msg_success, newArrivals=newArrivals, book=book)
else:
msg_error = "Error"
return render_template('editbooks.html', bookauthor=bookauthor, bookSubjList=bookSubjList, booksubj=booksubj, mainAuth=mainAuth, supAuth=supAuth, email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks, msg_error=msg_error, msg_success=msg_success, newArrivals=newArrivals, book=book)
return render_template('allbooks.html', msg_error=msg_error, allBooks=allBooks, currentYear=currentYear)
@app.route('/editbook/<book_id>', methods=['GET','POST'])
@login_required
@admin_required
def updateBook(book_id):
if (request.method=='POST'):
email = current_user.user_mail
allSubj = Subject.query.all()
status, book, bookauthor, booksubj, mainAuth, supAuth, bookSubjList = update_book(book_id)
msg_success = ""
msg_error = ""
if status:
#final
msg_success = "Book Updated Successfully"
return render_template('editbooks.html', bookauthor=bookauthor, bookSubjList=bookSubjList, booksubj=booksubj, mainAuth=mainAuth, supAuth=supAuth, email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks, msg_error=msg_error, msg_success=msg_success, newArrivals=newArrivals, book=book)
else:
msg_error = "Error"
return render_template('editbooks.html', bookauthor=bookauthor, bookSubjList=bookSubjList, booksubj=booksubj, mainAuth=mainAuth, supAuth=supAuth, email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks, msg_error=msg_error, msg_success=msg_success, newArrivals=newArrivals, book=book)
return redirect(url_for('addBook'))
@app.route('/details', methods=['GET','POST'])
@login_required
@admin_required
def details():
email = current_user.user_mail
allSubj = Subject.query.all()
return render_template('details.html', email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
@app.route('/viewperiodicals', methods=['GET','POST'])
@login_required
def mytrans():
return render_template('periodicals.html', allPeriodicals=allPeriodicals, lMonth=lMonth, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
@app.route('/viewperiodicals/<id>', methods=['GET'])
@login_required
def mytransc(id):
period = get_period(id)
msg_error = ''
if period is None:
msg_error = "Periodical Not Found"
return render_template('periodicals.html', allPeriodicals=allPeriodicals, msg_error=msg_error, lMonth=lMonth, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
return render_template('periodicalTwo.html', period=period, allPeriodicals=allPeriodicals, lMonth=lMonth, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
@app.route('/mytrans', methods=['GET'])
@login_required
def mytransct():
status, foundTrans = trans_list(current_user.user_id)
return render_template('mytrans.html', status=status, foundTrans=foundTrans, allAuthors=allAuthors, currentYear=currentYear, allBooks=allBooks, allDepts=allDepts, allSubj=allSubj, allPubs=allPubs)
@app.route('/periodicals', methods=['GET','POST'])
@login_required
@admin_required
def periodicals():
email = current_user.user_mail
allSubj = Subject.query.all()
if (request.method == "POST"):
msg_success = ''
status = add_period()
if status:
msg_success = "Periodical Added Successfully"
else:
msg_success = "AN Error Occurred"
return render_template('periodicals.html', allPeriodicals=allPeriodicals, msg_success=msg_success, lMonth=lMonth, email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
return render_template('periodicals.html', allPeriodicals=allPeriodicals, lMonth=lMonth, email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
@app.route('/periodicals/<id>', methods=['GET','POST'])
@login_required
@admin_required
def get_periodicals(id):
email = current_user.user_mail
allSubj = Subject.query.all()
period = get_period(id)
msg_error = ''
msg_success = ''
if period is None:
msg_error = "Periodical Not Found"
return render_template('periodicals.html', allPeriodicals=allPeriodicals, msg_error=msg_error, lMonth=lMonth, email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
if (request.method == "POST"):
status, period = update_period(id)
if status:
msg_success = "Update Successful"
return render_template('periodicalDetails.html', period=period, msg_error=msg_error, msg_success=msg_success, lMonth=lMonth, email=email, currentYear=currentYear)
else:
msg_error = "Periodical Not Found"
return render_template('periodicals.html', allPeriodicals=allPeriodicals, msg_success=msg_success, lMonth=lMonth, email=email, allDepts=allDepts, currentYear=currentYear, allSubj=allSubj, allAuthors=allAuthors, allPubs=allPubs, allBooks=allBooks)
return render_template('periodicalDetails.html', period=period, msg_error=msg_error, msg_success=msg_success, lMonth=lMonth, email=email, currentYear=currentYear)
return render_template('periodicalDetails.html', period=period, msg_error=msg_error, msg_success=msg_success, lMonth=lMonth, email=email, currentYear=currentYear)
@app.route('/register', methods=['POST'])
def register():
status = register_user()
if status is True:
success = "Pre-Registration Successful. Please Visit the Library to Complete Your Registration."
return render_template('login.html', allDepts=allDepts, success=success)
else:
error = "Registration Error. Your ID Number, Phone Number And/Or Email Address Have Been Previously Registered. Please Log In Or Visit the Library to Complete Registration."
return render_template('login.html', allDepts=allDepts, error=error)
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)