-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.py
52 lines (42 loc) · 1.27 KB
/
views.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
import webapp2 , handler, models
#Add your views here
class MainPage(handler.Handler):
def get(self):
user_id = self.get_cookie('user_id')
if user_id:
user = models.User.get_by_id(int(user_id))
self.render('home', usertype=self.user.usertype)
else:
self.render('login')
class Login(handler.Handler):
def get(self):
user_id = self.get_cookie('user_id')
if user_id:
self.redirect('/')
else:
self.render('login')
def post(self):
username = self.request.get('name')
password = self.request.get('pass')
self.login(username, password)
class Logout(handler.Handler):
def get(self):
self.logout()
class Register(handler.Handler):
def get(self):
self.render('register')
def post(self):
username = self.request.get('username')
name = self.request.get('fullname')
email = self.request.get('email')
password = self.request.get('password')
verify = self.request.get('verify')
type_of_user = self.request.get('type')
if handler.valid_register(username, password, verify, email):
self.register(username, name, password, email, type_of_user)
else:
error = 'The data order is not valid'
self.render('register', username=username, name=name, email=email, error=error)
class Classes(handler.Handler):
def get(self):
self.render('classes')