Show More
@@ -0,0 +1,50 | |||||
|
1 | <%inherit file="base/base.html"/> | |||
|
2 | <%def name="title()"> | |||
|
3 | ${_('User')} - ${_('add new')} | |||
|
4 | </%def> | |||
|
5 | <%def name="breadcrumbs()"> | |||
|
6 | ${h.link_to(u'Home',h.url('/'))} | |||
|
7 | / | |||
|
8 | ${h.link_to(u'Admin',h.url('admin_home'))} | |||
|
9 | / | |||
|
10 | ${h.link_to(u'Users',h.url('users'))} | |||
|
11 | </%def> | |||
|
12 | <%def name="page_nav()"> | |||
|
13 | <li>${h.link_to(u'Home',h.url('/'))}</li> | |||
|
14 | <li class="current">${_('Admin')}</li> | |||
|
15 | </%def> | |||
|
16 | <%def name="main()"> | |||
|
17 | <ul class="submenu"> | |||
|
18 | <li> | |||
|
19 | ${h.link_to(u'Repos',h.url('repos'))} | |||
|
20 | </li> | |||
|
21 | <li class="current_submenu"> | |||
|
22 | ${h.link_to(u'Users',h.url('users'))} | |||
|
23 | </li> | |||
|
24 | </ul> | |||
|
25 | <div> | |||
|
26 | <h2>${_('User')} - ${_('add new')}</h2> | |||
|
27 | ${h.form(url('users'))} | |||
|
28 | <table> | |||
|
29 | <tr> | |||
|
30 | <td>${_('Username')}</td> | |||
|
31 | <td>${h.text('username')}</td> | |||
|
32 | </tr> | |||
|
33 | <tr> | |||
|
34 | <td>${_('password')}</td> | |||
|
35 | <td>${h.text('password')}</td> | |||
|
36 | </tr> | |||
|
37 | <tr> | |||
|
38 | <td>${_('Active')}</td> | |||
|
39 | <td>${h.checkbox('active')}</td> | |||
|
40 | </tr> | |||
|
41 | <tr> | |||
|
42 | <td></td> | |||
|
43 | <td>${h.submit('add','add')}</td> | |||
|
44 | </tr> | |||
|
45 | ||||
|
46 | </table> | |||
|
47 | ||||
|
48 | ${h.end_form()} | |||
|
49 | </div> | |||
|
50 | </%def> No newline at end of file |
@@ -7,6 +7,7 from pylons_app.lib.base import BaseCont | |||||
7 | from formencode import htmlfill |
|
7 | from formencode import htmlfill | |
8 | from pylons_app.model import meta |
|
8 | from pylons_app.model import meta | |
9 | from pylons_app.model.db import Users, UserLogs |
|
9 | from pylons_app.model.db import Users, UserLogs | |
|
10 | import crypt | |||
10 | log = logging.getLogger(__name__) |
|
11 | log = logging.getLogger(__name__) | |
11 |
|
12 | |||
12 | class UsersController(BaseController): |
|
13 | class UsersController(BaseController): | |
@@ -14,6 +15,7 class UsersController(BaseController): | |||||
14 | # To properly map this controller, ensure your config/routing.py |
|
15 | # To properly map this controller, ensure your config/routing.py | |
15 | # file has a resource setup: |
|
16 | # file has a resource setup: | |
16 | # map.resource('user', 'users') |
|
17 | # map.resource('user', 'users') | |
|
18 | ||||
17 | def __before__(self): |
|
19 | def __before__(self): | |
18 | c.staticurl = g.statics |
|
20 | c.staticurl = g.statics | |
19 | c.admin_user = session.get('admin_user') |
|
21 | c.admin_user = session.get('admin_user') | |
@@ -30,10 +32,26 class UsersController(BaseController): | |||||
30 | def create(self): |
|
32 | def create(self): | |
31 | """POST /users: Create a new item""" |
|
33 | """POST /users: Create a new item""" | |
32 | # url('users') |
|
34 | # url('users') | |
|
35 | params = dict(request.params) | |||
33 |
|
36 | |||
|
37 | try: | |||
|
38 | new_user = Users() | |||
|
39 | new_user.active = params.get('active', False) | |||
|
40 | new_user.username = params.get('username') | |||
|
41 | new_user.password = crypt.crypt(params.get('password'), '6a') | |||
|
42 | new_user.admin = False | |||
|
43 | self.sa.add(new_user) | |||
|
44 | self.sa.commit() | |||
|
45 | except: | |||
|
46 | self.sa.rollback() | |||
|
47 | raise | |||
|
48 | ||||
|
49 | return redirect(url('users')) | |||
|
50 | ||||
34 | def new(self, format='html'): |
|
51 | def new(self, format='html'): | |
35 | """GET /users/new: Form to create a new item""" |
|
52 | """GET /users/new: Form to create a new item""" | |
36 | # url('new_user') |
|
53 | # url('new_user') | |
|
54 | return render('/user_add.html') | |||
37 |
|
55 | |||
38 | def update(self, id): |
|
56 | def update(self, id): | |
39 | """PUT /users/id: Update an existing item""" |
|
57 | """PUT /users/id: Update an existing item""" | |
@@ -43,7 +61,23 class UsersController(BaseController): | |||||
43 | # h.form(url('user', id=ID), |
|
61 | # h.form(url('user', id=ID), | |
44 | # method='put') |
|
62 | # method='put') | |
45 | # url('user', id=ID) |
|
63 | # url('user', id=ID) | |
|
64 | params = dict(request.params) | |||
46 |
|
65 | |||
|
66 | try: | |||
|
67 | new_user = self.sa.query(Users).get(id) | |||
|
68 | new_user.active = params.get('active') | |||
|
69 | new_user.username = params.get('username') | |||
|
70 | print params | |||
|
71 | if params.get('new_password'): | |||
|
72 | new_user.password = crypt.crypt(params.get('new_password'), '6a') | |||
|
73 | self.sa.add(new_user) | |||
|
74 | self.sa.commit() | |||
|
75 | except: | |||
|
76 | self.sa.rollback() | |||
|
77 | raise | |||
|
78 | ||||
|
79 | return redirect(url('users')) | |||
|
80 | ||||
47 | def delete(self, id): |
|
81 | def delete(self, id): | |
48 | """DELETE /users/id: Delete an existing item""" |
|
82 | """DELETE /users/id: Delete an existing item""" | |
49 | # Forms posted to this method should contain a hidden field: |
|
83 | # Forms posted to this method should contain a hidden field: | |
@@ -63,15 +97,16 class UsersController(BaseController): | |||||
63 | def show(self, id, format='html'): |
|
97 | def show(self, id, format='html'): | |
64 | """GET /users/id: Show a specific item""" |
|
98 | """GET /users/id: Show a specific item""" | |
65 | # url('user', id=ID) |
|
99 | # url('user', id=ID) | |
66 | c.user = self.sa.query(Users).get(id) |
|
100 | ||
67 |
|
||||
68 | return htmlfill.render( |
|
|||
69 | render('/users_show.html'), |
|
|||
70 | defaults=c.user.__dict__, |
|
|||
71 | encoding="UTF-8", |
|
|||
72 | force_defaults=False |
|
|||
73 | ) |
|
|||
74 |
|
101 | |||
75 | def edit(self, id, format='html'): |
|
102 | def edit(self, id, format='html'): | |
76 | """GET /users/id/edit: Form to edit an existing item""" |
|
103 | """GET /users/id/edit: Form to edit an existing item""" | |
77 | # url('edit_user', id=ID) |
|
104 | # url('edit_user', id=ID) | |
|
105 | c.user = self.sa.query(Users).get(id) | |||
|
106 | ||||
|
107 | return htmlfill.render( | |||
|
108 | render('/user_edit.html'), | |||
|
109 | defaults=c.user.__dict__, | |||
|
110 | encoding="UTF-8", | |||
|
111 | force_defaults=False | |||
|
112 | ) |
@@ -173,6 +173,7 h2 { | |||||
173 | border-top: dotted 1px #D5E1E6; |
|
173 | border-top: dotted 1px #D5E1E6; | |
174 | font-weight: bold; |
|
174 | font-weight: bold; | |
175 | } |
|
175 | } | |
|
176 | ||||
176 | h2.no-link { |
|
177 | h2.no-link { | |
177 | color:#006699; |
|
178 | color:#006699; | |
178 | } |
|
179 | } | |
@@ -185,6 +186,15 h2 a { | |||||
185 | font-weight:bold; |
|
186 | font-weight:bold; | |
186 | color:#006699; |
|
187 | color:#006699; | |
187 | } |
|
188 | } | |
|
189 | h3 { | |||
|
190 | margin: 20px 0 10px; | |||
|
191 | height: 30px; | |||
|
192 | line-height: 30px; | |||
|
193 | text-indent: 20px; | |||
|
194 | background: #FFF; | |||
|
195 | font-size: 1.1em; | |||
|
196 | font-weight: bold; | |||
|
197 | } | |||
188 |
|
198 | |||
189 | div.page-path { |
|
199 | div.page-path { | |
190 | text-align: right; |
|
200 | text-align: right; |
@@ -26,7 +26,7 | |||||
26 | <div id="powered-by"> |
|
26 | <div id="powered-by"> | |
27 | <p> |
|
27 | <p> | |
28 | <a href="http://mercurial.selenic.com/" title="Mercurial"> |
|
28 | <a href="http://mercurial.selenic.com/" title="Mercurial"> | |
29 | <img src="${c.staticurl}hglogo.png" width="75" height="90" alt="mercurial"></a> |
|
29 | <img src="${c.staticurl}hglogo.png" width="75" height="90" alt="mercurial"/></a> | |
30 | </p> |
|
30 | </p> | |
31 | </div> |
|
31 | </div> | |
32 |
|
32 |
1 | NO CONTENT: file renamed from pylons_app/templates/repos_show.html to pylons_app/templates/repo_edit.html |
|
NO CONTENT: file renamed from pylons_app/templates/repos_show.html to pylons_app/templates/repo_edit.html |
1 | NO CONTENT: file renamed from pylons_app/templates/users_show.html to pylons_app/templates/user_edit.html |
|
NO CONTENT: file renamed from pylons_app/templates/users_show.html to pylons_app/templates/user_edit.html |
@@ -35,7 +35,8 | |||||
35 | %for user in c.users_list: |
|
35 | %for user in c.users_list: | |
36 | <tr> |
|
36 | <tr> | |
37 | <td>${user.user_id}</td> |
|
37 | <td>${user.user_id}</td> | |
38 | <td>${h.link_to(user.username,h.url('user', id=user.user_id))}</td> |
|
38 | <td>${h.link_to(user.username,h.url('edit_user', id=user.user_id))}</td> | |
|
39 | <td>${user.password}</td> | |||
39 | <td>${user.active}</td> |
|
40 | <td>${user.active}</td> | |
40 | <td>${user.admin}</td> |
|
41 | <td>${user.admin}</td> | |
41 | <td> |
|
42 | <td> | |
@@ -45,7 +46,8 | |||||
45 | </td> |
|
46 | </td> | |
46 | </tr> |
|
47 | </tr> | |
47 | %endfor |
|
48 | %endfor | |
48 |
</table> |
|
49 | </table> | |
|
50 | <h3>${h.link_to(u'Add user',h.url('new_user'))}</h3> | |||
49 | </div> |
|
51 | </div> | |
50 |
|
52 | |||
51 | </%def> No newline at end of file |
|
53 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now