-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.py
134 lines (120 loc) · 3.3 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# --coding: utf-8 --
import web
from web.contrib.template import render_jinja
from sqlalchemy.orm import scoped_session, sessionmaker
from models import *
from data_module import *
d = dict()
render = render_jinja(
'templates/site/',
encoding='utf-8',
)
def notfound():
return web.notfound(render.notfound())
def internalerror():
return web.internalerror(render.servererror())
def my_loadhook():
web.ctx.session = web.config._session
# 登录装饰器函数
def login_required(func):
def Function(*args):
if web.ctx.session.isLogin == False:
raise web.seeother('/login')
else:
return func(*args)
return Function
#加载admin模板装饰器
def adminRender():
render = render_jinja('templates/admin/', encoding='utf-8',)
return render
adminrender = adminRender()
#登录页面
class login:
def GET(self):
d['error'] = ''
return render.login(d)
def POST(self):
username=web.input().username
password=web.input().password
print username, password
t=login_password(username,password)
print t
if t == 1:
web.ctx.session.isLogin = True
web.ctx.session.userName = username
web.ctx.session.Password = password
d['username'] = web.ctx.session.userName
print d['username'] +u'登录用户'
raise web.seeother('/manger')
elif t == -1:
d['error'] = u"用户名或密码错误!"
return render.login(d)
elif t == 0:
web.ctx.session.isLogin = True
web.ctx.session.userName = username
web.ctx.session.Password = password
d['username'] = web.ctx.session.userName
print d['username'] + u'登录用户'
return adminrender.adminmanger(d)
#退出
class logout():
def GET(self):
web.ctx.session.kill()
raise web.seeother('/login')
#个人页面
class manger():
@login_required
def GET(self):
return render.manger(d)
#admin页面
class adminManger():
@login_required
def GET(self):
return adminrender.adminmanger(d)
class admin():
@login_required
def GET(self):
return render.createTask()
def POST(self):
raise web.seeother('/case')
class user():
@login_required
def GET(self):
return render.createTask()
def POST(self):
raise web.seeother('/case')
class createTask():
@login_required
def GET(self):
return render.createTask()
def POST(self):
raise web.seeother('/case')
<<<<<<< HEAD
'''
=======
class test():
@login_required
def GET(self):
return render.test()
#创建项目页面
class projectManger():
@login_required
def GET(self):
render = render_jinja('templates/admin/',encoding='utf-8',)
return render.projectmanger(d)
#创建用户页面
class userManger():
@login_required
def GET(self):
render = render_jinja('templates/admin/', encoding='utf-8',)
return render.usermanger(d)
#项目列表页面
class projectList():
@login_required
def GET(self):
return adminrender.projectlist(d)
class userList():
@login_required
def GET(self):
return adminrender.userlist(d)
>>>>>>> 20c48185164c0008fe2f0e3d261d742f9e2ac2b7