comparison pylons_app/controllers/admin/permissions.py @ 323:8026872a10ee

Moved admin controllers to separate module
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 30 Jun 2010 17:14:47 +0200
parents pylons_app/controllers/permissions.py@fdf9f6ee5217
children 3ed2d46a2ca7
comparison
equal deleted inserted replaced
322:46b7d108ea7a 323:8026872a10ee
1 #!/usr/bin/env python
2 # encoding: utf-8
3 # permissions controller for pylons
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
5
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2
9 # of the License or (at your opinion) any later version of the license.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
20 """
21 Created on April 27, 2010
22 permissions controller for pylons
23 @author: marcink
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
36 import logging
37
38 log = logging.getLogger(__name__)
39
40 class PermissionsController(BaseController):
41 """REST Controller styled on the Atom Publishing Protocol"""
42 # To properly map this controller, ensure your config/routing.py
43 # file has a resource setup:
44 # map.resource('permission', 'permissions')
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
53 def index(self, format='html'):
54 """GET /permissions: All items in the collection"""
55 # url('permissions')
56 return render('admin/permissions/permissions.html')
57
58 def create(self):
59 """POST /permissions: Create a new item"""
60 # url('permissions')
61
62 def new(self, format='html'):
63 """GET /permissions/new: Form to create a new item"""
64 # url('new_permission')
65
66 def update(self, id):
67 """PUT /permissions/id: Update an existing item"""
68 # Forms posted to this method should contain a hidden field:
69 # <input type="hidden" name="_method" value="PUT" />
70 # Or using helpers:
71 # h.form(url('permission', id=ID),
72 # method='put')
73 # url('permission', id=ID)
74
75 def delete(self, id):
76 """DELETE /permissions/id: Delete an existing item"""
77 # Forms posted to this method should contain a hidden field:
78 # <input type="hidden" name="_method" value="DELETE" />
79 # Or using helpers:
80 # h.form(url('permission', id=ID),
81 # method='delete')
82 # url('permission', id=ID)
83
84 def show(self, id, format='html'):
85 """GET /permissions/id: Show a specific item"""
86 # url('permission', id=ID)
87
88 def edit(self, id, format='html'):
89 """GET /permissions/id/edit: Form to edit an existing item"""
90 # url('edit_permission', id=ID)