Mercurial > kallithea
annotate rhodecode/controllers/admin/users_groups.py @ 3598:7d774f09dba5 beta
pullrequests: only create special select entry for a changeset if it has no symbolic name
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 26 Mar 2013 01:23:35 +0100 |
parents | a8f2d78d14ea |
children | 4dddb7ee8865 |
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 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
36 from rhodecode.lib.exceptions import UserGroupsAssignedException |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
37 from rhodecode.lib.utils2 import safe_unicode, str2bool |
1117
6eb5bb24a948
Major rewrite of auth objects. Moved parts of filling user data into user model.
Marcin Kuzminski <marcin@python-works.com>
parents:
974
diff
changeset
|
38 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 from rhodecode.lib.base import BaseController, render |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
41 from rhodecode.model.users_group import UserGroupModel |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1436
diff
changeset
|
42 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
43 from rhodecode.model.db import User, UserGroup, UserGroupToPerm,\ |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
44 UserGroupRepoToPerm, UserGroupRepoGroupToPerm |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
45 from rhodecode.model.forms import UserGroupForm |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1436
diff
changeset
|
46 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
|
47 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
|
48 from sqlalchemy.orm import joinedload |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 log = logging.getLogger(__name__) |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
52 |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
53 class UsersGroupsController(BaseController): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
54 """REST Controller styled on the Atom Publishing Protocol""" |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
55 # 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
|
56 # file has a resource setup: |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
57 # map.resource('users_group', 'users_groups') |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
58 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 @LoginRequired() |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
60 @HasPermissionAllDecorator('hg.admin') |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
61 def __before__(self): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
62 c.admin_user = session.get('admin_user') |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
63 c.admin_username = session.get('admin_username') |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 super(UsersGroupsController, self).__before__() |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 c.available_permissions = config['available_permissions'] |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
66 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
67 def index(self, format='html'): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
68 """GET /users_groups: All items in the collection""" |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
69 # url('users_groups') |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
70 c.users_groups_list = UserGroup().query().all() |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
71 return render('admin/users_groups/users_groups.html') |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
72 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
73 def create(self): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
74 """POST /users_groups: Create a new item""" |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
75 # url('users_groups') |
1436
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1435
diff
changeset
|
76 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
77 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
|
78 try: |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
79 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
|
80 UserGroupModel().create(name=form_result['users_group_name'], |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1436
diff
changeset
|
81 active=form_result['users_group_active']) |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
82 gr = form_result['users_group_name'] |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
83 action_logger(self.rhodecode_user, |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
84 'admin_created_users_group:%s' % gr, |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
85 None, self.ip_addr, self.sa) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3417
diff
changeset
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 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
|
94 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
|
95 except Exception: |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
96 log.error(traceback.format_exc()) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3417
diff
changeset
|
97 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
|
98 % 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
|
99 |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
100 return redirect(url('users_groups')) |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
101 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
102 def new(self, format='html'): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
103 """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
|
104 # 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
|
105 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
|
106 |
2987
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
107 def _load_data(self, id): |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
108 c.users_group.permissions = { |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
109 'repositories': {}, |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
110 'repositories_groups': {} |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
111 } |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
112 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
113 ugroup_repo_perms = UserGroupRepoToPerm.query()\ |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
114 .options(joinedload(UserGroupRepoToPerm.permission))\ |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
115 .options(joinedload(UserGroupRepoToPerm.repository))\ |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
116 .filter(UserGroupRepoToPerm.users_group_id == id)\ |
2987
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
117 .all() |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
118 |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
119 for gr in ugroup_repo_perms: |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
120 c.users_group.permissions['repositories'][gr.repository.repo_name] \ |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
121 = gr.permission.permission_name |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
122 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
123 ugroup_group_perms = UserGroupRepoGroupToPerm.query()\ |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
124 .options(joinedload(UserGroupRepoGroupToPerm.permission))\ |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
125 .options(joinedload(UserGroupRepoGroupToPerm.group))\ |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
126 .filter(UserGroupRepoGroupToPerm.users_group_id == id)\ |
2987
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
127 .all() |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
128 |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
129 for gr in ugroup_group_perms: |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
130 c.users_group.permissions['repositories_groups'][gr.group.group_name] \ |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
131 = gr.permission.permission_name |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
132 |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
133 c.group_members_obj = [x.user for x in c.users_group.members] |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
134 c.group_members = [(x.user_id, x.username) for x in |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
135 c.group_members_obj] |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
136 c.available_members = [(x.user_id, x.username) for x in |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
137 User.query().all()] |
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
138 |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
139 def update(self, id): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
140 """PUT /users_groups/id: Update an existing item""" |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
141 # 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
|
142 # <input type="hidden" name="_method" value="PUT" /> |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
143 # Or using helpers: |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
144 # h.form(url('users_group', id=ID), |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
145 # method='put') |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
146 # url('users_group', id=ID) |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
147 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
148 c.users_group = UserGroup.get_or_404(id) |
2987
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
149 self._load_data(id) |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
150 |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1436
diff
changeset
|
151 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
|
152 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
153 users_group_form = UserGroupForm(edit=True, |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
154 old_data=c.users_group.get_dict(), |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1436
diff
changeset
|
155 available_members=available_members)() |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
156 |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
157 try: |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
158 form_result = users_group_form.to_python(request.POST) |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
159 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
|
160 gr = form_result['users_group_name'] |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
161 action_logger(self.rhodecode_user, |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
162 'admin_updated_users_group:%s' % gr, |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
163 None, self.ip_addr, self.sa) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3417
diff
changeset
|
164 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
|
165 Session().commit() |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
166 except formencode.Invalid, errors: |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
167 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
|
168 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
|
169 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
|
170 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
|
171 '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
|
172 '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
|
173 '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
|
174 '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
|
175 '_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
|
176 }) |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
177 |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
178 return htmlfill.render( |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
179 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
|
180 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
|
181 errors=e, |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
182 prefix_error=False, |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
183 encoding="UTF-8") |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
184 except Exception: |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
185 log.error(traceback.format_exc()) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3417
diff
changeset
|
186 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
|
187 % request.POST.get('users_group_name'), category='error') |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
188 |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
189 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
|
190 |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
191 def delete(self, id): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
192 """DELETE /users_groups/id: Delete an existing item""" |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
193 # 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
|
194 # <input type="hidden" name="_method" value="DELETE" /> |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
195 # Or using helpers: |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
196 # h.form(url('users_group', id=ID), |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
197 # method='delete') |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
198 # url('users_group', id=ID) |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
199 usr_gr = UserGroup.get_or_404(id) |
973
9be6d46c72d6
#56 implemented users groups deletes
Marcin Kuzminski <marcin@python-works.com>
parents:
972
diff
changeset
|
200 try: |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
201 UserGroupModel().delete(usr_gr) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2375
diff
changeset
|
202 Session().commit() |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3417
diff
changeset
|
203 h.flash(_('Successfully deleted user group'), category='success') |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
204 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
|
205 h.flash(e, category='error') |
973
9be6d46c72d6
#56 implemented users groups deletes
Marcin Kuzminski <marcin@python-works.com>
parents:
972
diff
changeset
|
206 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
|
207 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
|
208 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
|
209 category='error') |
9be6d46c72d6
#56 implemented users groups deletes
Marcin Kuzminski <marcin@python-works.com>
parents:
972
diff
changeset
|
210 return redirect(url('users_groups')) |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
211 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
212 def show(self, id, format='html'): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
213 """GET /users_groups/id: Show a specific item""" |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
214 # url('users_group', id=ID) |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
215 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
216 def edit(self, id, format='html'): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
217 """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
|
218 # url('edit_users_group', id=ID) |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
219 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
220 c.users_group = UserGroup.get_or_404(id) |
2987
4150c45b5f7f
Implemented #638 permissions overview to groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
221 self._load_data(id) |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
222 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
223 ug_model = UserGroupModel() |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
224 defaults = c.users_group.get_dict() |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
225 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
|
226 'create_repo_perm': ug_model.has_perm(c.users_group, |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
227 '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
|
228 'fork_repo_perm': ug_model.has_perm(c.users_group, |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
229 '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
|
230 }) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
231 |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
232 return htmlfill.render( |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
233 render('admin/users_groups/users_group_edit.html'), |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
234 defaults=defaults, |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
235 encoding="UTF-8", |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
236 force_defaults=False |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
237 ) |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
238 |
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
239 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
|
240 """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
|
241 # 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
|
242 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
243 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
|
244 grant_create_perm = str2bool(request.POST.get('create_repo_perm')) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
245 grant_fork_perm = str2bool(request.POST.get('fork_repo_perm')) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
246 inherit_perms = str2bool(request.POST.get('inherit_default_permissions')) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
247 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
248 usergroup_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
|
249 |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
250 try: |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
251 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
|
252 Session().add(users_group) |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
253 |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
254 if grant_create_perm: |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
255 usergroup_model.revoke_perm(id, 'hg.create.none') |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
256 usergroup_model.grant_perm(id, 'hg.create.repository') |
3410
5f1850e4712a
"Users groups" is grammatically incorrect English - rename to "user groups"
Mads Kiilerich <madski@unity3d.com>
parents:
2987
diff
changeset
|
257 h.flash(_("Granted 'repository create' permission to user group"), |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
258 category='success') |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
259 else: |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
260 usergroup_model.revoke_perm(id, 'hg.create.repository') |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
261 usergroup_model.grant_perm(id, 'hg.create.none') |
3410
5f1850e4712a
"Users groups" is grammatically incorrect English - rename to "user groups"
Mads Kiilerich <madski@unity3d.com>
parents:
2987
diff
changeset
|
262 h.flash(_("Revoked 'repository create' permission to user group"), |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
263 category='success') |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
264 |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
265 if grant_fork_perm: |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
266 usergroup_model.revoke_perm(id, 'hg.fork.none') |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
267 usergroup_model.grant_perm(id, 'hg.fork.repository') |
3410
5f1850e4712a
"Users groups" is grammatically incorrect English - rename to "user groups"
Mads Kiilerich <madski@unity3d.com>
parents:
2987
diff
changeset
|
268 h.flash(_("Granted 'repository fork' permission to user group"), |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
269 category='success') |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
270 else: |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
271 usergroup_model.revoke_perm(id, 'hg.fork.repository') |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3410
diff
changeset
|
272 usergroup_model.grant_perm(id, 'hg.fork.none') |
3410
5f1850e4712a
"Users groups" is grammatically incorrect English - rename to "user groups"
Mads Kiilerich <madski@unity3d.com>
parents:
2987
diff
changeset
|
273 h.flash(_("Revoked 'repository fork' permission to user group"), |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
274 category='success') |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
275 |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2375
diff
changeset
|
276 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
|
277 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
|
278 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
|
279 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
|
280 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
|
281 |
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
282 return redirect(url('edit_users_group', id=id)) |