-
Notifications
You must be signed in to change notification settings - Fork 0
/
student_activate.py
46 lines (42 loc) · 1.02 KB
/
student_activate.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from google.appengine.dist import use_library
use_library('django', '1.2')
import wsgiref.handlers
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from db_scheme import *
from logged import *
class MainHandler(webapp.RequestHandler):
def get(self):
id = self.request.get('id')
if not id:
#Zle wolanie
msg = 1
else:
try:
student = db.get(db.Key(id))
if student.active:
#Juz aktywny
msg = 3
else:
if self.request.get('del'):
#Usuniecie
student.delete()
msg = 4
else:
#Aktywacja
student.active = True
student.put()
msg = 5
except:
#Brak rekordu
msg = 2
values = {'msg': msg}
values.update(logged())
self.response.out.write(template.render('student_activate.html', values))
def main():
application = webapp.WSGIApplication([(r'.*', MainHandler)], debug=True)
wsgiref.handlers.CGIHandler().run(application)
if __name__ == '__main__':
main()