forked from KasenJ/CommunityPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFinishHandler.py
More file actions
29 lines (27 loc) · 949 Bytes
/
FinishHandler.py
File metadata and controls
29 lines (27 loc) · 949 Bytes
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
import tornado.ioloop
import tornado.web
import tornado.httpserver
import json
class FinishHandler(tornado.web.RequestHandler):
def get(self):
self.write("<p>FinishHandler</p><form action='/api/finish' method='post'><input type='submit' value='submit'></form>")
def post(self):
#content =self.request.body
content = '{"username":"test1","eventid":1}'
j = json.loads(content)
uid = self.application.dbapi.getUserByUserName(j['username'])["id"]
event = self.application.dbapi.getEventByEventId(j['eventid'])
if(event is None):
self.write("{'state':1}")
print "event not exist"
return
rNamelist = self.application.dbapi.getAllRelativeNamebyUid(event["usrid"])
print rNamelist
if(uid not in rNamelist):
self.write("{'state':2}")
print "user not relative or itself,can not update sate"
return
self.application.dbapi.changeEventState(j['eventid']);
self.write("{'state':3}")
print "finsh an event"
return