-
Notifications
You must be signed in to change notification settings - Fork 2
/
handler_user.py
49 lines (35 loc) · 1.24 KB
/
handler_user.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
from dbapi.user import User
import template
def user(response, username):
user = User.find('username', username)[0]
if response.get_secure_cookie('username') is not None:
current_user = User.find('username', str(response.get_secure_cookie('username'), 'utf-8'))[0]
else:
current_user = None
context = {
'user':user,
'current_user': current_user,
'requested_user': username
}
html = template.render_file('templates/profile.html', context)
response.write(html)
def profiles(response):
users = User.find('all')
if response.get_secure_cookie('username') is not None:
current_user = User.find('username', str(response.get_secure_cookie('username'), 'utf-8'))[0]
else:
current_user = None
context = {
'users':users,
'current_user':current_user
}
html = template.render_file('templates/profilelist.html', context)
response.write(html)
def check_username(response, username):
import json
json_response = {
"status":0, "username_available":True
}
if User.find('username', username):
json_response["username_available"] = False
response.write(json.dumps(json_response))