Show More
@@ -28,7 +28,7 b' from pylons_app.lib.base import BaseCont' | |||||
28 | from pylons_app.model import meta |
|
28 | from pylons_app.model import meta | |
29 | from pylons_app.model.db import UserLog |
|
29 | from pylons_app.model.db import UserLog | |
30 | from webhelpers.paginate import Page |
|
30 | from webhelpers.paginate import Page | |
31 | from pylons_app.lib.auth import LoginRequired |
|
31 | from pylons_app.lib.auth import LoginRequired, HasPermissionAllDecorator | |
32 |
|
32 | |||
33 | log = logging.getLogger(__name__) |
|
33 | log = logging.getLogger(__name__) | |
34 |
|
34 | |||
@@ -36,11 +36,9 b' class AdminController(BaseController):' | |||||
36 |
|
36 | |||
37 | @LoginRequired() |
|
37 | @LoginRequired() | |
38 | def __before__(self): |
|
38 | def __before__(self): | |
39 | user = session['hg_app_user'] |
|
|||
40 | c.admin_user = user.is_admin |
|
|||
41 | c.admin_username = user.username |
|
|||
42 | super(AdminController, self).__before__() |
|
39 | super(AdminController, self).__before__() | |
43 |
|
|
40 | ||
|
41 | @HasPermissionAllDecorator('hg.admin') | |||
44 | def index(self): |
|
42 | def index(self): | |
45 | sa = meta.Session |
|
43 | sa = meta.Session | |
46 |
|
44 |
@@ -22,13 +22,19 b' Created on April 27, 2010' | |||||
22 | permissions controller for pylons |
|
22 | permissions controller for pylons | |
23 | @author: marcink |
|
23 | @author: marcink | |
24 | """ |
|
24 | """ | |
|
25 | from formencode import htmlfill | |||
|
26 | from pylons import request, session, tmpl_context as c, url | |||
|
27 | from pylons.controllers.util import abort, redirect | |||
|
28 | from pylons.i18n.translation import _ | |||
|
29 | from pylons_app.lib import helpers as h | |||
|
30 | from pylons_app.lib.auth import LoginRequired, HasPermissionAllDecorator | |||
|
31 | from pylons_app.lib.base import BaseController, render | |||
|
32 | from pylons_app.model.db import User, UserLog | |||
|
33 | from pylons_app.model.forms import UserForm | |||
|
34 | from pylons_app.model.user_model import UserModel | |||
|
35 | import formencode | |||
25 | import logging |
|
36 | import logging | |
26 |
|
37 | |||
27 | from pylons import request, response, session, tmpl_context as c, url |
|
|||
28 | from pylons.controllers.util import abort, redirect |
|
|||
29 |
|
||||
30 | from pylons_app.lib.base import BaseController, render |
|
|||
31 |
|
||||
32 | log = logging.getLogger(__name__) |
|
38 | log = logging.getLogger(__name__) | |
33 |
|
39 | |||
34 | class PermissionsController(BaseController): |
|
40 | class PermissionsController(BaseController): | |
@@ -36,7 +42,14 b' class PermissionsController(BaseControll' | |||||
36 | # To properly map this controller, ensure your config/routing.py |
|
42 | # To properly map this controller, ensure your config/routing.py | |
37 | # file has a resource setup: |
|
43 | # file has a resource setup: | |
38 | # map.resource('permission', 'permissions') |
|
44 | # map.resource('permission', 'permissions') | |
39 |
|
45 | |||
|
46 | @LoginRequired() | |||
|
47 | @HasPermissionAllDecorator('hg.admin') | |||
|
48 | def __before__(self): | |||
|
49 | c.admin_user = session.get('admin_user') | |||
|
50 | c.admin_username = session.get('admin_username') | |||
|
51 | super(PermissionsController, self).__before__() | |||
|
52 | ||||
40 | def index(self, format='html'): |
|
53 | def index(self, format='html'): | |
41 | """GET /permissions: All items in the collection""" |
|
54 | """GET /permissions: All items in the collection""" | |
42 | # url('permissions') |
|
55 | # url('permissions') |
@@ -22,18 +22,18 b' Created on April 4, 2010' | |||||
22 | users controller for pylons |
|
22 | users controller for pylons | |
23 | @author: marcink |
|
23 | @author: marcink | |
24 | """ |
|
24 | """ | |
25 | import logging |
|
25 | from formencode import htmlfill | |
26 | from pylons import request, session, tmpl_context as c, url |
|
26 | from pylons import request, session, tmpl_context as c, url | |
27 | from pylons.controllers.util import abort, redirect |
|
27 | from pylons.controllers.util import abort, redirect | |
28 | from pylons.i18n.translation import _ |
|
28 | from pylons.i18n.translation import _ | |
29 | from pylons_app.lib import helpers as h |
|
29 | from pylons_app.lib import helpers as h | |
30 | from pylons_app.lib.auth import LoginRequired |
|
30 | from pylons_app.lib.auth import LoginRequired, HasPermissionAllDecorator | |
31 | from pylons_app.lib.base import BaseController, render |
|
31 | from pylons_app.lib.base import BaseController, render | |
32 | from pylons_app.model.db import User, UserLog |
|
32 | from pylons_app.model.db import User, UserLog | |
33 | from pylons_app.model.forms import UserForm |
|
33 | from pylons_app.model.forms import UserForm | |
34 | from pylons_app.model.user_model import UserModel |
|
34 | from pylons_app.model.user_model import UserModel | |
35 | import formencode |
|
35 | import formencode | |
36 | from formencode import htmlfill |
|
36 | import logging | |
37 |
|
37 | |||
38 | log = logging.getLogger(__name__) |
|
38 | log = logging.getLogger(__name__) | |
39 |
|
39 | |||
@@ -42,7 +42,9 b' class UsersController(BaseController):' | |||||
42 | # To properly map this controller, ensure your config/routing.py |
|
42 | # To properly map this controller, ensure your config/routing.py | |
43 | # file has a resource setup: |
|
43 | # file has a resource setup: | |
44 | # map.resource('user', 'users') |
|
44 | # map.resource('user', 'users') | |
|
45 | ||||
45 | @LoginRequired() |
|
46 | @LoginRequired() | |
|
47 | @HasPermissionAllDecorator('hg.admin') | |||
46 | def __before__(self): |
|
48 | def __before__(self): | |
47 | c.admin_user = session.get('admin_user') |
|
49 | c.admin_user = session.get('admin_user') | |
48 | c.admin_username = session.get('admin_username') |
|
50 | c.admin_username = session.get('admin_username') | |
@@ -110,7 +112,7 b' class UsersController(BaseController):' | |||||
110 | % form_result['username'], category='error') |
|
112 | % form_result['username'], category='error') | |
111 |
|
113 | |||
112 | return redirect(url('users')) |
|
114 | return redirect(url('users')) | |
113 |
|
115 | |||
114 | def delete(self, id): |
|
116 | def delete(self, id): | |
115 | """DELETE /users/id: Delete an existing item""" |
|
117 | """DELETE /users/id: Delete an existing item""" | |
116 | # Forms posted to this method should contain a hidden field: |
|
118 | # Forms posted to this method should contain a hidden field: |
General Comments 0
You need to be logged in to leave comments.
Login now