comparison rhodecode/controllers/admin/users_groups.py @ 956:83d35d716a02 beta

started working on issue #56
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 25 Jan 2011 18:59:20 +0100
parents
children fff21c9b075c
comparison
equal deleted inserted replaced
955:129eb072b8a8 956:83d35d716a02
1 # -*- coding: utf-8 -*-
2 """
3 rhodecode.controllers.admin.users_groups
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
6 Users Groups crud controller for pylons
7
8 :created_on: Jan 25, 2011
9 :author: marcink
10 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License
15 # as published by the Free Software Foundation; version 2
16 # of the License or (at your opinion) any later version of the license.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26 # MA 02110-1301, USA.
27
28 import logging
29 import traceback
30 import formencode
31
32 from formencode import htmlfill
33 from pylons import request, session, tmpl_context as c, url, config
34 from pylons.controllers.util import abort, redirect
35 from pylons.i18n.translation import _
36
37 from rhodecode.lib.exceptions import DefaultUserException, UserOwnsReposException
38 from rhodecode.lib import helpers as h
39 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \
40 fill_perms
41 from rhodecode.lib.base import BaseController, render
42
43 from rhodecode.model.db import User, UsersGroup
44 from rhodecode.model.forms import UserForm
45 from rhodecode.model.user import UserModel
46
47 log = logging.getLogger(__name__)
48
49 class UsersGroupsController(BaseController):
50 """REST Controller styled on the Atom Publishing Protocol"""
51 # To properly map this controller, ensure your config/routing.py
52 # file has a resource setup:
53 # map.resource('users_group', 'users_groups')
54
55 @LoginRequired()
56 @HasPermissionAllDecorator('hg.admin')
57 def __before__(self):
58 c.admin_user = session.get('admin_user')
59 c.admin_username = session.get('admin_username')
60 super(UsersGroupsController, self).__before__()
61 c.available_permissions = config['available_permissions']
62
63 def index(self, format='html'):
64 """GET /users_groups: All items in the collection"""
65 # url('users_groups')
66 c.users_groups_list = []
67 return render('admin/users_groups/users_groups.html')
68
69 def create(self):
70 """POST /users_groups: Create a new item"""
71 # url('users_groups')
72
73 def new(self, format='html'):
74 """GET /users_groups/new: Form to create a new item"""
75 # url('new_users_group')
76
77 def update(self, id):
78 """PUT /users_groups/id: Update an existing item"""
79 # Forms posted to this method should contain a hidden field:
80 # <input type="hidden" name="_method" value="PUT" />
81 # Or using helpers:
82 # h.form(url('users_group', id=ID),
83 # method='put')
84 # url('users_group', id=ID)
85
86 def delete(self, id):
87 """DELETE /users_groups/id: Delete an existing item"""
88 # Forms posted to this method should contain a hidden field:
89 # <input type="hidden" name="_method" value="DELETE" />
90 # Or using helpers:
91 # h.form(url('users_group', id=ID),
92 # method='delete')
93 # url('users_group', id=ID)
94
95 def show(self, id, format='html'):
96 """GET /users_groups/id: Show a specific item"""
97 # url('users_group', id=ID)
98
99 def edit(self, id, format='html'):
100 """GET /users_groups/id/edit: Form to edit an existing item"""
101 # url('edit_users_group', id=ID)