Mercurial > kallithea
annotate rhodecode/controllers/admin/permissions.py @ 2709:d2d35cf2b351 beta
RhodeCode now has a option to explicitly set forking permissions. ref #508
- changed the way permissons on users groups behave. Now explicit set on user
is more important than permission set on users group
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 10 Aug 2012 03:09:36 +0200 |
parents | 91c442a489bb |
children | 63e58ef80ef1 d3200c58764e |
rev | line source |
---|---|
760
fb7a3b291e64
Cleaned up scm model codes,Admin/admin permissions controller codes
Marcin Kuzminski <marcin@python-works.com>
parents:
705
diff
changeset
|
1 # -*- coding: utf-8 -*- |
fb7a3b291e64
Cleaned up scm model codes,Admin/admin permissions controller codes
Marcin Kuzminski <marcin@python-works.com>
parents:
705
diff
changeset
|
2 """ |
853
f67868ef6cd2
some docs updates on controller
Marcin Kuzminski <marcin@python-works.com>
parents:
769
diff
changeset
|
3 rhodecode.controllers.admin.permissions |
f67868ef6cd2
some docs updates on controller
Marcin Kuzminski <marcin@python-works.com>
parents:
769
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
5 |
760
fb7a3b291e64
Cleaned up scm model codes,Admin/admin permissions controller codes
Marcin Kuzminski <marcin@python-works.com>
parents:
705
diff
changeset
|
6 permissions controller for Rhodecode |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
7 |
760
fb7a3b291e64
Cleaned up scm model codes,Admin/admin permissions controller codes
Marcin Kuzminski <marcin@python-works.com>
parents:
705
diff
changeset
|
8 :created_on: Apr 27, 2010 |
fb7a3b291e64
Cleaned up scm model codes,Admin/admin permissions controller codes
Marcin Kuzminski <marcin@python-works.com>
parents:
705
diff
changeset
|
9 :author: marcink |
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
760
fb7a3b291e64
Cleaned up scm model codes,Admin/admin permissions controller codes
Marcin Kuzminski <marcin@python-works.com>
parents:
705
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
fb7a3b291e64
Cleaned up scm model codes,Admin/admin permissions controller codes
Marcin Kuzminski <marcin@python-works.com>
parents:
705
diff
changeset
|
12 """ |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
13 # This program is free software: you can redistribute it and/or modify |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
14 # it under the terms of the GNU General Public License as published by |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
15 # the Free Software Foundation, either version 3 of the License, or |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
16 # (at your option) any later version. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
17 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
230
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
230
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
230
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
230
diff
changeset
|
21 # GNU General Public License for more details. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
22 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
230
diff
changeset
|
23 # You should have received a copy of the GNU General Public License |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
25 |
1501
a828b83dfa4b
Deprecated UserModel removals
Marcin Kuzminski <marcin@python-works.com>
parents:
1315
diff
changeset
|
26 import logging |
a828b83dfa4b
Deprecated UserModel removals
Marcin Kuzminski <marcin@python-works.com>
parents:
1315
diff
changeset
|
27 import traceback |
a828b83dfa4b
Deprecated UserModel removals
Marcin Kuzminski <marcin@python-works.com>
parents:
1315
diff
changeset
|
28 import formencode |
305
61be6dcd49a0
protected admin controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
29 from formencode import htmlfill |
1501
a828b83dfa4b
Deprecated UserModel removals
Marcin Kuzminski <marcin@python-works.com>
parents:
1315
diff
changeset
|
30 |
305
61be6dcd49a0
protected admin controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
31 from pylons import request, session, tmpl_context as c, url |
61be6dcd49a0
protected admin controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
32 from pylons.controllers.util import abort, redirect |
61be6dcd49a0
protected admin controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
33 from pylons.i18n.translation import _ |
1501
a828b83dfa4b
Deprecated UserModel removals
Marcin Kuzminski <marcin@python-works.com>
parents:
1315
diff
changeset
|
34 |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
418
diff
changeset
|
35 from rhodecode.lib import helpers as h |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
418
diff
changeset
|
36 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
418
diff
changeset
|
37 from rhodecode.lib.base import BaseController, render |
1501
a828b83dfa4b
Deprecated UserModel removals
Marcin Kuzminski <marcin@python-works.com>
parents:
1315
diff
changeset
|
38 from rhodecode.model.forms import DefaultPermissionsForm |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
673
diff
changeset
|
39 from rhodecode.model.permission import PermissionModel |
1501
a828b83dfa4b
Deprecated UserModel removals
Marcin Kuzminski <marcin@python-works.com>
parents:
1315
diff
changeset
|
40 from rhodecode.model.db import User |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
41 from rhodecode.model.meta import Session |
230
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 log = logging.getLogger(__name__) |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
45 |
230
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 class PermissionsController(BaseController): |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
47 """REST Controller styled on the Atom Publishing Protocol""" |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 # To properly map this controller, ensure your config/routing.py |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 # file has a resource setup: |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 # map.resource('permission', 'permissions') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
51 |
305
61be6dcd49a0
protected admin controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
52 @LoginRequired() |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
53 @HasPermissionAllDecorator('hg.admin') |
305
61be6dcd49a0
protected admin controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
54 def __before__(self): |
61be6dcd49a0
protected admin controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
55 c.admin_user = session.get('admin_user') |
61be6dcd49a0
protected admin controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
56 c.admin_username = session.get('admin_username') |
61be6dcd49a0
protected admin controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
57 super(PermissionsController, self).__before__() |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
58 |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
59 self.perms_choices = [('repository.none', _('None'),), |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
60 ('repository.read', _('Read'),), |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
61 ('repository.write', _('Write'),), |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
62 ('repository.admin', _('Admin'),)] |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
63 self.register_choices = [ |
673
dd532af216d9
#49 Enabled anonymous access for web interface controllable from permissions pannel
Marcin Kuzminski <marcin@python-works.com>
parents:
664
diff
changeset
|
64 ('hg.register.none', |
dd532af216d9
#49 Enabled anonymous access for web interface controllable from permissions pannel
Marcin Kuzminski <marcin@python-works.com>
parents:
664
diff
changeset
|
65 _('disabled')), |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
66 ('hg.register.manual_activate', |
673
dd532af216d9
#49 Enabled anonymous access for web interface controllable from permissions pannel
Marcin Kuzminski <marcin@python-works.com>
parents:
664
diff
changeset
|
67 _('allowed with manual account activation')), |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
68 ('hg.register.auto_activate', |
673
dd532af216d9
#49 Enabled anonymous access for web interface controllable from permissions pannel
Marcin Kuzminski <marcin@python-works.com>
parents:
664
diff
changeset
|
69 _('allowed with automatic account activation')), ] |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
70 |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
71 self.create_choices = [('hg.create.none', _('Disabled')), |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
72 ('hg.create.repository', _('Enabled'))] |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
73 |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
74 self.fork_choices = [('hg.fork.none', _('Disabled')), |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
75 ('hg.fork.repository', _('Enabled'))] |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
76 |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
77 # set the global template variables |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
78 c.perms_choices = self.perms_choices |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
79 c.register_choices = self.register_choices |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
80 c.create_choices = self.create_choices |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
81 c.fork_choices = self.fork_choices |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
82 |
230
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
83 def index(self, format='html'): |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
84 """GET /permissions: All items in the collection""" |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
85 # url('permissions') |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
86 |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
87 def create(self): |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
88 """POST /permissions: Create a new item""" |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
89 # url('permissions') |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
90 |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
91 def new(self, format='html'): |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
92 """GET /permissions/new: Form to create a new item""" |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
93 # url('new_permission') |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
94 |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
95 def update(self, id): |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
96 """PUT /permissions/id: Update an existing item""" |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
97 # Forms posted to this method should contain a hidden field: |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
98 # <input type="hidden" name="_method" value="PUT" /> |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
99 # Or using helpers: |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
100 # h.form(url('permission', id=ID), |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
101 # method='put') |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
102 # url('permission', id=ID) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
103 |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
104 permission_model = PermissionModel() |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
105 |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
106 _form = DefaultPermissionsForm([x[0] for x in self.perms_choices], |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
107 [x[0] for x in self.register_choices], |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
108 [x[0] for x in self.create_choices], |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
109 [x[0] for x in self.fork_choices])() |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
110 |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
111 try: |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
112 form_result = _form.to_python(dict(request.POST)) |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
113 form_result.update({'perm_user_name': id}) |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
114 permission_model.update(form_result) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
115 Session().commit() |
705
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
116 h.flash(_('Default permissions updated successfully'), |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
117 category='success') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
118 |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
119 except formencode.Invalid, errors: |
705
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
120 defaults = errors.value |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
121 |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
122 return htmlfill.render( |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
123 render('admin/permissions/permissions.html'), |
705
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
124 defaults=defaults, |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
125 errors=errors.error_dict or {}, |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
126 prefix_error=False, |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
127 encoding="UTF-8") |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
128 except Exception: |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
129 log.error(traceback.format_exc()) |
860
5f7731e3ab4d
fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents:
853
diff
changeset
|
130 h.flash(_('error occurred during update of permissions'), |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
131 category='error') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
132 |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
133 return redirect(url('edit_permission', id=id)) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
134 |
230
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
135 def delete(self, id): |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
136 """DELETE /permissions/id: Delete an existing item""" |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
137 # Forms posted to this method should contain a hidden field: |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
138 # <input type="hidden" name="_method" value="DELETE" /> |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
139 # Or using helpers: |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
140 # h.form(url('permission', id=ID), |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
141 # method='delete') |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
142 # url('permission', id=ID) |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
143 |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
144 def show(self, id, format='html'): |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
145 """GET /permissions/id: Show a specific item""" |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
146 # url('permission', id=ID) |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
147 |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
148 def edit(self, id, format='html'): |
d982ed8e32d8
Admin templating updates, added rest permission controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
149 """GET /permissions/id/edit: Form to edit an existing item""" |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
150 #url('edit_permission', id=ID) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
151 |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
152 #this form can only edit default user permissions |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
153 if id == 'default': |
1530
04027bdb876c
Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1501
diff
changeset
|
154 default_user = User.get_by_username('default') |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
155 defaults = {'_method': 'put', |
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
156 'anonymous': default_user.active} |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
760
diff
changeset
|
157 |
673
dd532af216d9
#49 Enabled anonymous access for web interface controllable from permissions pannel
Marcin Kuzminski <marcin@python-works.com>
parents:
664
diff
changeset
|
158 for p in default_user.user_perms: |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
159 if p.permission.permission_name.startswith('repository.'): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
160 defaults['default_perm'] = p.permission.permission_name |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
161 |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
162 if p.permission.permission_name.startswith('hg.register.'): |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
163 defaults['default_register'] = p.permission.permission_name |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
164 |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
165 if p.permission.permission_name.startswith('hg.create.'): |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
166 defaults['default_create'] = p.permission.permission_name |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
167 |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
168 if p.permission.permission_name.startswith('hg.fork.'): |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
169 defaults['default_fork'] = p.permission.permission_name |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
170 |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
171 return htmlfill.render( |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
172 render('admin/permissions/permissions.html'), |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
173 defaults=defaults, |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
174 encoding="UTF-8", |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
175 force_defaults=True, |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
176 ) |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
177 else: |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
178 return redirect(url('admin_home')) |