Mercurial > kallithea
annotate rhodecode/controllers/admin/users_groups.py @ 3884:31f8c9d76a26 beta
Remove translation calls in API
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 22 May 2013 02:00:57 +0200 |
parents | c74eaaae4437 |
children |
rev | line source |
---|---|
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 """ |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 rhodecode.controllers.admin.users_groups |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 |
3410
5f1850e4712a
"Users groups" is grammatically incorrect English - rename to "user groups"
Mads Kiilerich <madski@unity3d.com>
parents:
2987
diff
changeset
|
6 User Groups crud controller for pylons |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1117
diff
changeset
|
7 |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 :created_on: Jan 25, 2011 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 :author: marcink |
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
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:
1117
diff
changeset
|
17 # |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
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:
1117
diff
changeset
|
22 # |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
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/>. |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 import logging |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 import traceback |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 import formencode |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 from formencode import htmlfill |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 from pylons import request, session, tmpl_context as c, url, config |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 from pylons.controllers.util import abort, redirect |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 from pylons.i18n.translation import _ |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 |
2109 | 35 from rhodecode.lib import helpers as h |
3788
d9b89874edf9
UserGroup on UserGroup permissions implementation.
Marcin Kuzminski <marcin@python-works.com>
parents:
3737
diff
changeset
|
36 from rhodecode.lib.exceptions import UserGroupsAssignedException,\ |
d9b89874edf9
UserGroup on UserGroup permissions implementation.
Marcin Kuzminski <marcin@python-works.com>
parents:
3737
diff
changeset
|
37 RepoGroupAssignmentError |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
38 from rhodecode.lib.utils2 import safe_unicode, str2bool, safe_int |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
39 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator,\ |
3737
46b17730ca32
implemented usergroup permissions checks.
Marcin Kuzminski <marcin@python-works.com>
parents:
3736
diff
changeset
|
40 HasUserGroupPermissionAnyDecorator, HasPermissionAnyDecorator |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 from rhodecode.lib.base import BaseController, render |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
42 from rhodecode.model.scm import UserGroupList |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
43 from rhodecode.model.users_group import UserGroupModel |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
44 from rhodecode.model.repo import RepoModel |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
45 from rhodecode.model.db import User, UserGroup, UserGroupToPerm,\ |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
46 UserGroupRepoToPerm, UserGroupRepoGroupToPerm |
3736
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
47 from rhodecode.model.forms import UserGroupForm, UserGroupPermsForm,\ |
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
48 CustomDefaultPermissionsForm |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1436
diff
changeset
|
49 from rhodecode.model.meta import Session |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
50 from rhodecode.lib.utils import action_logger |
2987
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
51 from sqlalchemy.orm import joinedload |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
52 from webob.exc import HTTPInternalServerError |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
53 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
54 log = logging.getLogger(__name__) |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
55 |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
56 |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
57 class UsersGroupsController(BaseController): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
58 """REST Controller styled on the Atom Publishing Protocol""" |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 # To properly map this controller, ensure your config/routing.py |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
60 # file has a resource setup: |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
61 # map.resource('users_group', 'users_groups') |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
62 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
63 @LoginRequired() |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 def __before__(self): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 super(UsersGroupsController, self).__before__() |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
66 c.available_permissions = config['available_permissions'] |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
67 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
68 def __load_data(self, user_group_id): |
3861
c74eaaae4437
added permission overview into users group
Marcin Kuzminski <marcin@python-works.com>
parents:
3788
diff
changeset
|
69 permissions = { |
c74eaaae4437
added permission overview into users group
Marcin Kuzminski <marcin@python-works.com>
parents:
3788
diff
changeset
|
70 'repositories': {}, |
c74eaaae4437
added permission overview into users group
Marcin Kuzminski <marcin@python-works.com>
parents:
3788
diff
changeset
|
71 'repositories_groups': {} |
c74eaaae4437
added permission overview into users group
Marcin Kuzminski <marcin@python-works.com>
parents:
3788
diff
changeset
|
72 } |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
73 ugroup_repo_perms = UserGroupRepoToPerm.query()\ |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
74 .options(joinedload(UserGroupRepoToPerm.permission))\ |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
75 .options(joinedload(UserGroupRepoToPerm.repository))\ |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
76 .filter(UserGroupRepoToPerm.users_group_id == user_group_id)\ |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
77 .all() |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
78 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
79 for gr in ugroup_repo_perms: |
3861
c74eaaae4437
added permission overview into users group
Marcin Kuzminski <marcin@python-works.com>
parents:
3788
diff
changeset
|
80 permissions['repositories'][gr.repository.repo_name] \ |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
81 = gr.permission.permission_name |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
82 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
83 ugroup_group_perms = UserGroupRepoGroupToPerm.query()\ |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
84 .options(joinedload(UserGroupRepoGroupToPerm.permission))\ |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
85 .options(joinedload(UserGroupRepoGroupToPerm.group))\ |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
86 .filter(UserGroupRepoGroupToPerm.users_group_id == user_group_id)\ |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
87 .all() |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
88 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
89 for gr in ugroup_group_perms: |
3861
c74eaaae4437
added permission overview into users group
Marcin Kuzminski <marcin@python-works.com>
parents:
3788
diff
changeset
|
90 permissions['repositories_groups'][gr.group.group_name] \ |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
91 = gr.permission.permission_name |
3861
c74eaaae4437
added permission overview into users group
Marcin Kuzminski <marcin@python-works.com>
parents:
3788
diff
changeset
|
92 c.permissions = permissions |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
93 c.group_members_obj = sorted((x.user for x in c.users_group.members), |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
94 key=lambda u: u.username.lower()) |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
95 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
96 c.group_members = [(x.user_id, x.username) for x in c.group_members_obj] |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
97 c.available_members = sorted(((x.user_id, x.username) for x in |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
98 User.query().all()), |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
99 key=lambda u: u[1].lower()) |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
100 repo_model = RepoModel() |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
101 c.users_array = repo_model.get_users_js() |
3788
d9b89874edf9
UserGroup on UserGroup permissions implementation.
Marcin Kuzminski <marcin@python-works.com>
parents:
3737
diff
changeset
|
102 c.users_groups_array = repo_model.get_users_groups_js() |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
103 c.available_permissions = config['available_permissions'] |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
104 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
105 def __load_defaults(self, user_group_id): |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
106 """ |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
107 Load defaults settings for edit, and update |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
108 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
109 :param user_group_id: |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
110 """ |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
111 user_group = UserGroup.get_or_404(user_group_id) |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
112 data = user_group.get_dict() |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
113 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
114 ug_model = UserGroupModel() |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
115 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
116 data.update({ |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
117 'create_repo_perm': ug_model.has_perm(user_group, |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
118 'hg.create.repository'), |
3736
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
119 'create_user_group_perm': ug_model.has_perm(user_group, |
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
120 'hg.usergroup.create.true'), |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
121 'fork_repo_perm': ug_model.has_perm(user_group, |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
122 'hg.fork.repository'), |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
123 }) |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
124 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
125 # fill user group users |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
126 for p in user_group.user_user_group_to_perm: |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
127 data.update({'u_perm_%s' % p.user.username: |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
128 p.permission.permission_name}) |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
129 |
3788
d9b89874edf9
UserGroup on UserGroup permissions implementation.
Marcin Kuzminski <marcin@python-works.com>
parents:
3737
diff
changeset
|
130 for p in user_group.user_group_user_group_to_perm: |
d9b89874edf9
UserGroup on UserGroup permissions implementation.
Marcin Kuzminski <marcin@python-works.com>
parents:
3737
diff
changeset
|
131 data.update({'g_perm_%s' % p.user_group.users_group_name: |
d9b89874edf9
UserGroup on UserGroup permissions implementation.
Marcin Kuzminski <marcin@python-works.com>
parents:
3737
diff
changeset
|
132 p.permission.permission_name}) |
d9b89874edf9
UserGroup on UserGroup permissions implementation.
Marcin Kuzminski <marcin@python-works.com>
parents:
3737
diff
changeset
|
133 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
134 return data |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
135 |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
136 def index(self, format='html'): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
137 """GET /users_groups: All items in the collection""" |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
138 # url('users_groups') |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
139 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
140 group_iter = UserGroupList(UserGroup().query().all(), |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
141 perm_set=['usergroup.admin']) |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
142 sk = lambda g: g.users_group_name |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
143 c.users_groups_list = sorted(group_iter, key=sk) |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
144 return render('admin/users_groups/users_groups.html') |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
145 |
3737
46b17730ca32
implemented usergroup permissions checks.
Marcin Kuzminski <marcin@python-works.com>
parents:
3736
diff
changeset
|
146 @HasPermissionAnyDecorator('hg.admin', 'hg.usergroup.create.true') |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
147 def create(self): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
148 """POST /users_groups: Create a new item""" |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
149 # url('users_groups') |
1436
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1435
diff
changeset
|
150 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
151 users_group_form = UserGroupForm()() |
959
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
152 try: |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
153 form_result = users_group_form.to_python(dict(request.POST)) |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
154 UserGroupModel().create(name=form_result['users_group_name'], |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
155 owner=self.rhodecode_user.user_id, |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
156 active=form_result['users_group_active']) |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
157 |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
158 gr = form_result['users_group_name'] |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
159 action_logger(self.rhodecode_user, |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
160 'admin_created_users_group:%s' % gr, |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
161 None, self.ip_addr, self.sa) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3417
diff
changeset
|
162 h.flash(_('Created user group %s') % gr, category='success') |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2375
diff
changeset
|
163 Session().commit() |
959
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
164 except formencode.Invalid, errors: |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
165 return htmlfill.render( |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
166 render('admin/users_groups/users_group_add.html'), |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
167 defaults=errors.value, |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
168 errors=errors.error_dict or {}, |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
169 prefix_error=False, |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
170 encoding="UTF-8") |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
171 except Exception: |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
172 log.error(traceback.format_exc()) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3417
diff
changeset
|
173 h.flash(_('Error occurred during creation of user group %s') \ |
959
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
174 % request.POST.get('users_group_name'), category='error') |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
175 |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
176 return redirect(url('users_groups')) |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
177 |
3737
46b17730ca32
implemented usergroup permissions checks.
Marcin Kuzminski <marcin@python-works.com>
parents:
3736
diff
changeset
|
178 @HasPermissionAnyDecorator('hg.admin', 'hg.usergroup.create.true') |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
179 def new(self, format='html'): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
180 """GET /users_groups/new: Form to create a new item""" |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
181 # url('new_users_group') |
959
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
182 return render('admin/users_groups/users_group_add.html') |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
183 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
184 @HasUserGroupPermissionAnyDecorator('usergroup.admin') |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
185 def update(self, id): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
186 """PUT /users_groups/id: Update an existing item""" |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
187 # Forms posted to this method should contain a hidden field: |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
188 # <input type="hidden" name="_method" value="PUT" /> |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
189 # Or using helpers: |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
190 # h.form(url('users_group', id=ID), |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
191 # method='put') |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
192 # url('users_group', id=ID) |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
193 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
194 c.users_group = UserGroup.get_or_404(id) |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
195 self.__load_data(id) |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
196 |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1436
diff
changeset
|
197 available_members = [safe_unicode(x[0]) for x in c.available_members] |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
198 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
199 users_group_form = UserGroupForm(edit=True, |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
200 old_data=c.users_group.get_dict(), |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1436
diff
changeset
|
201 available_members=available_members)() |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
202 |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
203 try: |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
204 form_result = users_group_form.to_python(request.POST) |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
205 UserGroupModel().update(c.users_group, form_result) |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
206 gr = form_result['users_group_name'] |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
207 action_logger(self.rhodecode_user, |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
208 'admin_updated_users_group:%s' % gr, |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
209 None, self.ip_addr, self.sa) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3417
diff
changeset
|
210 h.flash(_('Updated user group %s') % gr, category='success') |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2375
diff
changeset
|
211 Session().commit() |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
212 except formencode.Invalid, errors: |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
213 ug_model = UserGroupModel() |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
214 defaults = errors.value |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
215 e = errors.error_dict or {} |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
216 defaults.update({ |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
217 'create_repo_perm': ug_model.has_perm(id, |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
218 'hg.create.repository'), |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
219 'fork_repo_perm': ug_model.has_perm(id, |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
220 'hg.fork.repository'), |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
221 '_method': 'put' |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
222 }) |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
223 |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
224 return htmlfill.render( |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
225 render('admin/users_groups/users_group_edit.html'), |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
226 defaults=defaults, |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
227 errors=e, |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
228 prefix_error=False, |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
229 encoding="UTF-8") |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
230 except Exception: |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
231 log.error(traceback.format_exc()) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3417
diff
changeset
|
232 h.flash(_('Error occurred during update of user group %s') \ |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
233 % request.POST.get('users_group_name'), category='error') |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
234 |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
235 return redirect(url('edit_users_group', id=id)) |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
236 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
237 @HasUserGroupPermissionAnyDecorator('usergroup.admin') |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
238 def delete(self, id): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
239 """DELETE /users_groups/id: Delete an existing item""" |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
240 # Forms posted to this method should contain a hidden field: |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
241 # <input type="hidden" name="_method" value="DELETE" /> |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
242 # Or using helpers: |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
243 # h.form(url('users_group', id=ID), |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
244 # method='delete') |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
245 # url('users_group', id=ID) |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
246 usr_gr = UserGroup.get_or_404(id) |
973
9be6d46c72d6
#56 implemented users groups deletes
Marcin Kuzminski <marcin@python-works.com>
parents:
972
diff
changeset
|
247 try: |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
248 UserGroupModel().delete(usr_gr) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2375
diff
changeset
|
249 Session().commit() |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3417
diff
changeset
|
250 h.flash(_('Successfully deleted user group'), category='success') |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
251 except UserGroupsAssignedException, e: |
1435
a62af7d509ee
fixes #228 - added detection of assigned groups to prevent errors on sqlite
Marcin Kuzminski <marcin@python-works.com>
parents:
1271
diff
changeset
|
252 h.flash(e, category='error') |
973
9be6d46c72d6
#56 implemented users groups deletes
Marcin Kuzminski <marcin@python-works.com>
parents:
972
diff
changeset
|
253 except Exception: |
2063
d9ba58526712
fixed #373 missing cascade drop on user_group_to_perm table
Marcin Kuzminski <marcin@python-works.com>
parents:
1952
diff
changeset
|
254 log.error(traceback.format_exc()) |
3410
5f1850e4712a
"Users groups" is grammatically incorrect English - rename to "user groups"
Mads Kiilerich <madski@unity3d.com>
parents:
2987
diff
changeset
|
255 h.flash(_('An error occurred during deletion of user group'), |
973
9be6d46c72d6
#56 implemented users groups deletes
Marcin Kuzminski <marcin@python-works.com>
parents:
972
diff
changeset
|
256 category='error') |
9be6d46c72d6
#56 implemented users groups deletes
Marcin Kuzminski <marcin@python-works.com>
parents:
972
diff
changeset
|
257 return redirect(url('users_groups')) |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
258 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
259 @HasUserGroupPermissionAnyDecorator('usergroup.admin') |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
260 def set_user_group_perm_member(self, id): |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
261 """ |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
262 grant permission for given usergroup |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
263 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
264 :param id: |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
265 """ |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
266 user_group = UserGroup.get_or_404(id) |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
267 form = UserGroupPermsForm()().to_python(request.POST) |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
268 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
269 # set the permissions ! |
3788
d9b89874edf9
UserGroup on UserGroup permissions implementation.
Marcin Kuzminski <marcin@python-works.com>
parents:
3737
diff
changeset
|
270 try: |
d9b89874edf9
UserGroup on UserGroup permissions implementation.
Marcin Kuzminski <marcin@python-works.com>
parents:
3737
diff
changeset
|
271 UserGroupModel()._update_permissions(user_group, form['perms_new'], |
d9b89874edf9
UserGroup on UserGroup permissions implementation.
Marcin Kuzminski <marcin@python-works.com>
parents:
3737
diff
changeset
|
272 form['perms_updates']) |
d9b89874edf9
UserGroup on UserGroup permissions implementation.
Marcin Kuzminski <marcin@python-works.com>
parents:
3737
diff
changeset
|
273 except RepoGroupAssignmentError: |
d9b89874edf9
UserGroup on UserGroup permissions implementation.
Marcin Kuzminski <marcin@python-works.com>
parents:
3737
diff
changeset
|
274 h.flash(_('Target group cannot be the same'), category='error') |
d9b89874edf9
UserGroup on UserGroup permissions implementation.
Marcin Kuzminski <marcin@python-works.com>
parents:
3737
diff
changeset
|
275 return redirect(url('edit_users_group', id=id)) |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
276 #TODO: implement this |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
277 #action_logger(self.rhodecode_user, 'admin_changed_repo_permissions', |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
278 # repo_name, self.ip_addr, self.sa) |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
279 Session().commit() |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
280 h.flash(_('User Group permissions updated'), category='success') |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
281 return redirect(url('edit_users_group', id=id)) |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
282 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
283 @HasUserGroupPermissionAnyDecorator('usergroup.admin') |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
284 def delete_user_group_perm_member(self, id): |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
285 """ |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
286 DELETE an existing repository group permission user |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
287 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
288 :param group_name: |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
289 """ |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
290 try: |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
291 obj_type = request.POST.get('obj_type') |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
292 obj_id = None |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
293 if obj_type == 'user': |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
294 obj_id = safe_int(request.POST.get('user_id')) |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
295 elif obj_type == 'user_group': |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
296 obj_id = safe_int(request.POST.get('user_group_id')) |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
297 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
298 if not c.rhodecode_user.is_admin: |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
299 if obj_type == 'user' and c.rhodecode_user.user_id == obj_id: |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
300 msg = _('Cannot revoke permission for yourself as admin') |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
301 h.flash(msg, category='warning') |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
302 raise Exception('revoke admin permission on self') |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
303 if obj_type == 'user': |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
304 UserGroupModel().revoke_user_permission(user_group=id, |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
305 user=obj_id) |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
306 elif obj_type == 'user_group': |
3788
d9b89874edf9
UserGroup on UserGroup permissions implementation.
Marcin Kuzminski <marcin@python-works.com>
parents:
3737
diff
changeset
|
307 UserGroupModel().revoke_users_group_permission(target_user_group=id, |
d9b89874edf9
UserGroup on UserGroup permissions implementation.
Marcin Kuzminski <marcin@python-works.com>
parents:
3737
diff
changeset
|
308 user_group=obj_id) |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
309 Session().commit() |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
310 except Exception: |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
311 log.error(traceback.format_exc()) |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
312 h.flash(_('An error occurred during revoking of permission'), |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
313 category='error') |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
314 raise HTTPInternalServerError() |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
315 |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
316 def show(self, id, format='html'): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
317 """GET /users_groups/id: Show a specific item""" |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
318 # url('users_group', id=ID) |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
319 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
320 @HasUserGroupPermissionAnyDecorator('usergroup.admin') |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
321 def edit(self, id, format='html'): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
322 """GET /users_groups/id/edit: Form to edit an existing item""" |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
323 # url('edit_users_group', id=ID) |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
324 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
325 c.users_group = UserGroup.get_or_404(id) |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
326 self.__load_data(id) |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
327 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
328 defaults = self.__load_defaults(id) |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
329 |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
330 return htmlfill.render( |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
331 render('admin/users_groups/users_group_edit.html'), |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
332 defaults=defaults, |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
333 encoding="UTF-8", |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
334 force_defaults=False |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
335 ) |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
336 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
337 @HasUserGroupPermissionAnyDecorator('usergroup.admin') |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
338 def update_perm(self, id): |
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
339 """PUT /users_perm/id: Update an existing item""" |
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
340 # url('users_group_perm', id=ID, method='put') |
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
341 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
342 users_group = UserGroup.get_or_404(id) |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
343 |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
344 try: |
3736
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
345 form = CustomDefaultPermissionsForm()() |
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
346 form_result = form.to_python(request.POST) |
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
347 |
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
348 inherit_perms = form_result['inherit_default_permissions'] |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
349 users_group.inherit_default_permissions = inherit_perms |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
350 Session().add(users_group) |
3736
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
351 usergroup_model = UserGroupModel() |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
352 |
3736
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
353 defs = UserGroupToPerm.query()\ |
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
354 .filter(UserGroupToPerm.users_group == users_group)\ |
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
355 .all() |
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
356 for ug in defs: |
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
357 Session().delete(ug) |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
358 |
3736
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
359 if form_result['create_repo_perm']: |
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
360 usergroup_model.grant_perm(id, 'hg.create.repository') |
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
361 else: |
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
362 usergroup_model.grant_perm(id, 'hg.create.none') |
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
363 if form_result['create_user_group_perm']: |
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
364 usergroup_model.grant_perm(id, 'hg.usergroup.create.true') |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
365 else: |
3736
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
366 usergroup_model.grant_perm(id, 'hg.usergroup.create.false') |
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
367 if form_result['fork_repo_perm']: |
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
368 usergroup_model.grant_perm(id, 'hg.fork.repository') |
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
369 else: |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
370 usergroup_model.grant_perm(id, 'hg.fork.none') |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
371 |
3736
87e6960e250b
Iteration on default permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3715
diff
changeset
|
372 h.flash(_("Updated permissions"), category='success') |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2375
diff
changeset
|
373 Session().commit() |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
374 except Exception: |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
375 log.error(traceback.format_exc()) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
376 h.flash(_('An error occurred during permissions saving'), |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
377 category='error') |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
378 |
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
379 return redirect(url('edit_users_group', id=id)) |