-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdistrict.py
50 lines (40 loc) · 1.6 KB
/
district.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
from flask import *
from database import *
district=Blueprint('district',__name__)
@district.route('/district_home')
def district_home():
if session.get('lid'):
return render_template('district_home.html')
else:
return redirect(url_for("public.login"))
@district.route('/district_view_booth',methods=['get','post'])
def district_view_booth():
if session.get('lid'):
data={}
did=session['district_id']
q="SELECT * FROM `booth` INNER JOIN `district` USING (`district_id`) WHERE `district_id`='%s'"%(did)
res=select(q)
data['booths']=res
return render_template('district_view_booth.html',data=data)
else:
return redirect(url_for("public.login"))
@district.route('/district_view_voters',methods=['get','post'])
def district_view_voters():
if session.get('lid'):
data={}
did=session['district_id']
q="SELECT *,CONCAT(`first_name`,' ',`last_name`) AS NAME FROM `voter` INNER JOIN `booth` USING (`booth_id`) INNER JOIN `district` USING (`district_id`) INNER JOIN `election` USING(`election_id`) INNER JOIN `login` ON(`login`.`login_id`=`voter`.`login_id`) WHERE `district_id`='%s' ORDER BY FIELD(`login_type`, 'pending', 'reported', 'voter', 'reject') ASC"%(did)
res=select(q)
data['voters']=res
if 'action' in request.args:
action=request.args['action']
ids=request.args['ids']
else:
action=None
if action=='report':
q1="UPDATE `login` SET `login_type`='reported' WHERE `login_id`='%s'"%(ids)
update(q1)
return redirect(url_for('district.district_view_voters'))
return render_template('district_view_voters.html',data=data)
else:
return redirect(url_for("public.login"))