Mercurial > kallithea
annotate rhodecode/controllers/admin/repos_groups.py @ 4045:9b4ba12ef8c3
Add ini option to controll custom advanced hooks settings
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 27 Jun 2013 00:47:15 +0200 |
parents | 099585ff56c8 |
children |
rev | line source |
---|---|
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
1 # -*- coding: utf-8 -*- |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
2 """ |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
3 rhodecode.controllers.admin.repos_groups |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
5 |
3410
5f1850e4712a
"Users groups" is grammatically incorrect English - rename to "user groups"
Mads Kiilerich <madski@unity3d.com>
parents:
3332
diff
changeset
|
6 Repository groups controller for RhodeCode |
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
7 |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
8 :created_on: Mar 23, 2010 |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
9 :author: marcink |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
12 """ |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
13 # This program is free software: you can redistribute it and/or modify |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
14 # it under the terms of the GNU General Public License as published by |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
15 # the Free Software Foundation, either version 3 of the License, or |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
16 # (at your option) any later version. |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
17 # |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
21 # GNU General Public License for more details. |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
22 # |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
23 # You should have received a copy of the GNU General Public License |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
25 |
1171 | 26 import logging |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
27 import traceback |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
28 import formencode |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
29 |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
30 from formencode import htmlfill |
1171 | 31 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
32 from pylons import request, tmpl_context as c, url |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
33 from pylons.controllers.util import abort, redirect |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
34 from pylons.i18n.translation import _ |
1171 | 35 |
1543
ada6926c374f
Added friendly message about removing a group that still contains subgroups.
Marcin Kuzminski <marcin@python-works.com>
parents:
1538
diff
changeset
|
36 from sqlalchemy.exc import IntegrityError |
ada6926c374f
Added friendly message about removing a group that still contains subgroups.
Marcin Kuzminski <marcin@python-works.com>
parents:
1538
diff
changeset
|
37 |
2945
68e95f5ae3a7
lightweight dashboard fix for repos group
Marcin Kuzminski <marcin@python-works.com>
parents:
2831
diff
changeset
|
38 import rhodecode |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
39 from rhodecode.lib import helpers as h |
3705
f37d7514e7ab
always use json from compat module
Marcin Kuzminski <marcin@python-works.com>
parents:
3653
diff
changeset
|
40 from rhodecode.lib.compat import json |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
41 from rhodecode.lib.auth import LoginRequired, HasPermissionAnyDecorator,\ |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
42 HasReposGroupPermissionAnyDecorator, HasReposGroupPermissionAll,\ |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
43 HasPermissionAll |
1171 | 44 from rhodecode.lib.base import BaseController, render |
2945
68e95f5ae3a7
lightweight dashboard fix for repos group
Marcin Kuzminski <marcin@python-works.com>
parents:
2831
diff
changeset
|
45 from rhodecode.model.db import RepoGroup, Repository |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
46 from rhodecode.model.scm import RepoGroupList |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
47 from rhodecode.model.repos_group import ReposGroupModel |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
48 from rhodecode.model.forms import ReposGroupForm, RepoGroupPermsForm |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
49 from rhodecode.model.meta import Session |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
50 from rhodecode.model.repo import RepoModel |
2497
5a8c19c4dbe1
Fixed bug in repos group discovery, when inner folder of bare git repos were detected as a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2496
diff
changeset
|
51 from webob.exc import HTTPInternalServerError, HTTPNotFound |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
52 from rhodecode.lib.utils2 import str2bool, safe_int |
2945
68e95f5ae3a7
lightweight dashboard fix for repos group
Marcin Kuzminski <marcin@python-works.com>
parents:
2831
diff
changeset
|
53 from sqlalchemy.sql.expression import func |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
54 |
1171 | 55 |
56 log = logging.getLogger(__name__) | |
57 | |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
58 |
1171 | 59 class ReposGroupsController(BaseController): |
60 """REST Controller styled on the Atom Publishing Protocol""" | |
61 # To properly map this controller, ensure your config/routing.py | |
62 # file has a resource setup: | |
63 # map.resource('repos_group', 'repos_groups') | |
64 | |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
65 @LoginRequired() |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
66 def __before__(self): |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
67 super(ReposGroupsController, self).__before__() |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
68 |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
69 def __load_defaults(self, allow_empty_group=False, exclude_group_ids=[]): |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
70 if HasPermissionAll('hg.admin')('group edit'): |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
71 #we're global admin, we're ok and we can create TOP level groups |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
72 allow_empty_group = True |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
73 |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
74 #override the choices for this form, we need to filter choices |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
75 #and display only those we have ADMIN right |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
76 groups_with_admin_rights = RepoGroupList(RepoGroup.query().all(), |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
77 perm_set=['group.admin']) |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
78 c.repo_groups = RepoGroup.groups_choices(groups=groups_with_admin_rights, |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
79 show_empty_group=allow_empty_group) |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
80 # exclude filtered ids |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
81 c.repo_groups = filter(lambda x: x[0] not in exclude_group_ids, |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
82 c.repo_groups) |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
83 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups) |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
84 repo_model = RepoModel() |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
85 c.users_array = repo_model.get_users_js() |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
86 c.users_groups_array = repo_model.get_users_groups_js() |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
87 |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
88 def __load_data(self, group_id): |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
89 """ |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
90 Load defaults settings for edit, and update |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
91 |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
92 :param group_id: |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
93 """ |
2496
fddd8e3fc157
use get_or_404 where possible
Marcin Kuzminski <marcin@python-works.com>
parents:
2055
diff
changeset
|
94 repo_group = RepoGroup.get_or_404(group_id) |
1349
526120c77a38
#47 added editing of groups, and moving them between. Added check constraint for groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1347
diff
changeset
|
95 data = repo_group.get_dict() |
1538
27be8f94c207
implements #226 repo groups available by path
Marcin Kuzminski <marcin@python-works.com>
parents:
1482
diff
changeset
|
96 data['group_name'] = repo_group.name |
27be8f94c207
implements #226 repo groups available by path
Marcin Kuzminski <marcin@python-works.com>
parents:
1482
diff
changeset
|
97 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
98 # fill repository group users |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
99 for p in repo_group.repo_group_to_perm: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
100 data.update({'u_perm_%s' % p.user.username: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
101 p.permission.permission_name}) |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
102 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
103 # fill repository group groups |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
104 for p in repo_group.users_group_to_perm: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
105 data.update({'g_perm_%s' % p.users_group.users_group_name: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
106 p.permission.permission_name}) |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
107 |
1349
526120c77a38
#47 added editing of groups, and moving them between. Added check constraint for groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1347
diff
changeset
|
108 return data |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
109 |
3332
92dfc033ee6f
forbid removing yourself as beeing an admin of a group
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
110 def _revoke_perms_on_yourself(self, form_result): |
92dfc033ee6f
forbid removing yourself as beeing an admin of a group
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
111 _up = filter(lambda u: c.rhodecode_user.username == u[0], |
92dfc033ee6f
forbid removing yourself as beeing an admin of a group
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
112 form_result['perms_updates']) |
92dfc033ee6f
forbid removing yourself as beeing an admin of a group
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
113 _new = filter(lambda u: c.rhodecode_user.username == u[0], |
92dfc033ee6f
forbid removing yourself as beeing an admin of a group
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
114 form_result['perms_new']) |
92dfc033ee6f
forbid removing yourself as beeing an admin of a group
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
115 if _new and _new[0][1] != 'group.admin' or _up and _up[0][1] != 'group.admin': |
92dfc033ee6f
forbid removing yourself as beeing an admin of a group
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
116 return True |
92dfc033ee6f
forbid removing yourself as beeing an admin of a group
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
117 return False |
92dfc033ee6f
forbid removing yourself as beeing an admin of a group
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
118 |
1171 | 119 def index(self, format='html'): |
120 """GET /repos_groups: All items in the collection""" | |
121 # url('repos_groups') | |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
122 group_iter = RepoGroupList(RepoGroup.query().all(), |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
123 perm_set=['group.admin']) |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
124 sk = lambda g: g.parents[0].group_name if g.parents else g.group_name |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
125 c.groups = sorted(group_iter, key=sk) |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
126 return render('admin/repos_groups/repos_groups_show.html') |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
127 |
1171 | 128 def create(self): |
129 """POST /repos_groups: Create a new item""" | |
130 # url('repos_groups') | |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
131 |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
132 self.__load_defaults() |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
133 |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
134 # permissions for can create group based on parent_id are checked |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
135 # here in the Form |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
136 repos_group_form = ReposGroupForm(available_groups= |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
137 map(lambda k: unicode(k[0]), c.repo_groups))() |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
138 try: |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
139 form_result = repos_group_form.to_python(dict(request.POST)) |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
140 ReposGroupModel().create( |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
141 group_name=form_result['group_name'], |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
142 group_description=form_result['group_description'], |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
143 parent=form_result['group_parent_id'], |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
144 owner=self.rhodecode_user.user_id |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
145 ) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2631
diff
changeset
|
146 Session().commit() |
3653
4c78a0855a17
Fix 'repos group' - it is 'repository group'
Mads Kiilerich <madski@unity3d.com>
parents:
3625
diff
changeset
|
147 h.flash(_('Created repository group %s') \ |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
148 % form_result['group_name'], category='success') |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
149 #TODO: in futureaction_logger(, '', '', '', self.sa) |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
150 except formencode.Invalid, errors: |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
151 return htmlfill.render( |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
152 render('admin/repos_groups/repos_groups_add.html'), |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
153 defaults=errors.value, |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
154 errors=errors.error_dict or {}, |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
155 prefix_error=False, |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
156 encoding="UTF-8") |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
157 except Exception: |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
158 log.error(traceback.format_exc()) |
3653
4c78a0855a17
Fix 'repos group' - it is 'repository group'
Mads Kiilerich <madski@unity3d.com>
parents:
3625
diff
changeset
|
159 h.flash(_('Error occurred during creation of repository group %s') \ |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
160 % request.POST.get('group_name'), category='error') |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
161 parent_group_id = form_result['group_parent_id'] |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
162 #TODO: maybe we should get back to the main view, not the admin one |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
163 return redirect(url('repos_groups', parent_group=parent_group_id)) |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
164 |
1171 | 165 def new(self, format='html'): |
166 """GET /repos_groups/new: Form to create a new item""" | |
167 # url('new_repos_group') | |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
168 if HasPermissionAll('hg.admin')('group create'): |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
169 #we're global admin, we're ok and we can create TOP level groups |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
170 pass |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
171 else: |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
172 # we pass in parent group into creation form, thus we know |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
173 # what would be the group, we can check perms here ! |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
174 group_id = safe_int(request.GET.get('parent_group')) |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
175 group = RepoGroup.get(group_id) if group_id else None |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
176 group_name = group.group_name if group else None |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
177 if HasReposGroupPermissionAll('group.admin')(group_name, 'group create'): |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
178 pass |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
179 else: |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
180 return abort(403) |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
181 |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
182 self.__load_defaults() |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1343
diff
changeset
|
183 return render('admin/repos_groups/repos_groups_add.html') |
1171 | 184 |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
185 @HasReposGroupPermissionAnyDecorator('group.admin') |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
186 def update(self, group_name): |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
187 """PUT /repos_groups/group_name: Update an existing item""" |
1171 | 188 # Forms posted to this method should contain a hidden field: |
189 # <input type="hidden" name="_method" value="PUT" /> | |
190 # Or using helpers: | |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
191 # h.form(url('repos_group', group_name=GROUP_NAME), |
1171 | 192 # method='put') |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
193 # url('repos_group', group_name=GROUP_NAME) |
1171 | 194 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
195 c.repos_group = ReposGroupModel()._get_repo_group(group_name) |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
196 if HasPermissionAll('hg.admin')('group edit'): |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
197 #we're global admin, we're ok and we can create TOP level groups |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
198 allow_empty_group = True |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
199 elif not c.repos_group.parent_group: |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
200 allow_empty_group = True |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
201 else: |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
202 allow_empty_group = False |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
203 self.__load_defaults(allow_empty_group=allow_empty_group, |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
204 exclude_group_ids=[c.repos_group.group_id]) |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
205 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
206 repos_group_form = ReposGroupForm( |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
207 edit=True, |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
208 old_data=c.repos_group.get_dict(), |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
209 available_groups=c.repo_groups_choices, |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
210 can_create_in_root=allow_empty_group, |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
211 )() |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
212 try: |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
213 form_result = repos_group_form.to_python(dict(request.POST)) |
3332
92dfc033ee6f
forbid removing yourself as beeing an admin of a group
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
214 |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
215 new_gr = ReposGroupModel().update(group_name, form_result) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2631
diff
changeset
|
216 Session().commit() |
3653
4c78a0855a17
Fix 'repos group' - it is 'repository group'
Mads Kiilerich <madski@unity3d.com>
parents:
3625
diff
changeset
|
217 h.flash(_('Updated repository group %s') \ |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
218 % form_result['group_name'], category='success') |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
219 # we now have new name ! |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
220 group_name = new_gr.group_name |
2820
c0cc8f8a71b0
Permissions on group can be set in recursive mode setting defined permission to all children
Marcin Kuzminski <marcin@python-works.com>
parents:
2749
diff
changeset
|
221 #TODO: in future action_logger(, '', '', '', self.sa) |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
222 except formencode.Invalid, errors: |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
223 |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
224 return htmlfill.render( |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
225 render('admin/repos_groups/repos_groups_edit.html'), |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
226 defaults=errors.value, |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
227 errors=errors.error_dict or {}, |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
228 prefix_error=False, |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
229 encoding="UTF-8") |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
230 except Exception: |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
231 log.error(traceback.format_exc()) |
3653
4c78a0855a17
Fix 'repos group' - it is 'repository group'
Mads Kiilerich <madski@unity3d.com>
parents:
3625
diff
changeset
|
232 h.flash(_('Error occurred during update of repository group %s') \ |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
233 % request.POST.get('group_name'), category='error') |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
234 |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
235 return redirect(url('edit_repos_group', group_name=group_name)) |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
236 |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
237 @HasReposGroupPermissionAnyDecorator('group.admin') |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
238 def delete(self, group_name): |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
239 """DELETE /repos_groups/group_name: Delete an existing item""" |
1171 | 240 # Forms posted to this method should contain a hidden field: |
241 # <input type="hidden" name="_method" value="DELETE" /> | |
242 # Or using helpers: | |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
243 # h.form(url('repos_group', group_name=GROUP_NAME), |
1171 | 244 # method='delete') |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
245 # url('repos_group', group_name=GROUP_NAME) |
1171 | 246 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
247 gr = c.repos_group = ReposGroupModel()._get_repo_group(group_name) |
1346
cf78d302d441
#47 implemented deleting of empty groups. Fixed problem with full paths on nested groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1345
diff
changeset
|
248 repos = gr.repositories.all() |
cf78d302d441
#47 implemented deleting of empty groups. Fixed problem with full paths on nested groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1345
diff
changeset
|
249 if repos: |
cf78d302d441
#47 implemented deleting of empty groups. Fixed problem with full paths on nested groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1345
diff
changeset
|
250 h.flash(_('This group contains %s repositores and cannot be ' |
3458
0ad025ee005e
better detection of deleting groups with subgroups inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3410
diff
changeset
|
251 'deleted') % len(repos), category='warning') |
0ad025ee005e
better detection of deleting groups with subgroups inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3410
diff
changeset
|
252 return redirect(url('repos_groups')) |
0ad025ee005e
better detection of deleting groups with subgroups inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3410
diff
changeset
|
253 |
0ad025ee005e
better detection of deleting groups with subgroups inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3410
diff
changeset
|
254 children = gr.children.all() |
0ad025ee005e
better detection of deleting groups with subgroups inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3410
diff
changeset
|
255 if children: |
0ad025ee005e
better detection of deleting groups with subgroups inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3410
diff
changeset
|
256 h.flash(_('This group contains %s subgroups and cannot be deleted' |
0ad025ee005e
better detection of deleting groups with subgroups inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3410
diff
changeset
|
257 % (len(children))), category='warning') |
1346
cf78d302d441
#47 implemented deleting of empty groups. Fixed problem with full paths on nested groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1345
diff
changeset
|
258 return redirect(url('repos_groups')) |
cf78d302d441
#47 implemented deleting of empty groups. Fixed problem with full paths on nested groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1345
diff
changeset
|
259 |
cf78d302d441
#47 implemented deleting of empty groups. Fixed problem with full paths on nested groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1345
diff
changeset
|
260 try: |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
261 ReposGroupModel().delete(group_name) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2631
diff
changeset
|
262 Session().commit() |
3653
4c78a0855a17
Fix 'repos group' - it is 'repository group'
Mads Kiilerich <madski@unity3d.com>
parents:
3625
diff
changeset
|
263 h.flash(_('Removed repository group %s') % group_name, |
2749
3ed4dae499d0
Recursive set locking on all children of a group.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
264 category='success') |
1482
a39c0e5fca89
removed obsolete sort code
Marcin Kuzminski <marcin@python-works.com>
parents:
1394
diff
changeset
|
265 #TODO: in future action_logger(, '', '', '', self.sa) |
1346
cf78d302d441
#47 implemented deleting of empty groups. Fixed problem with full paths on nested groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1345
diff
changeset
|
266 except Exception: |
cf78d302d441
#47 implemented deleting of empty groups. Fixed problem with full paths on nested groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1345
diff
changeset
|
267 log.error(traceback.format_exc()) |
3931
099585ff56c8
renamed repos group -> repository group
Marcin Kuzminski <marcin@python-works.com>
parents:
3883
diff
changeset
|
268 h.flash(_('Error occurred during deletion of repository group %s') |
099585ff56c8
renamed repos group -> repository group
Marcin Kuzminski <marcin@python-works.com>
parents:
3883
diff
changeset
|
269 % group_name, category='error') |
1346
cf78d302d441
#47 implemented deleting of empty groups. Fixed problem with full paths on nested groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1345
diff
changeset
|
270 |
cf78d302d441
#47 implemented deleting of empty groups. Fixed problem with full paths on nested groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1345
diff
changeset
|
271 return redirect(url('repos_groups')) |
cf78d302d441
#47 implemented deleting of empty groups. Fixed problem with full paths on nested groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1345
diff
changeset
|
272 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
273 @HasReposGroupPermissionAnyDecorator('group.admin') |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
274 def set_repo_group_perm_member(self, group_name): |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
275 c.repos_group = ReposGroupModel()._get_repo_group(group_name) |
3883
88ec8f7b9e64
Fixed issues with group renames for local repository group admins.
Marcin Kuzminski <marcin@python-works.com>
parents:
3752
diff
changeset
|
276 form_result = RepoGroupPermsForm()().to_python(request.POST) |
88ec8f7b9e64
Fixed issues with group renames for local repository group admins.
Marcin Kuzminski <marcin@python-works.com>
parents:
3752
diff
changeset
|
277 if not c.rhodecode_user.is_admin: |
88ec8f7b9e64
Fixed issues with group renames for local repository group admins.
Marcin Kuzminski <marcin@python-works.com>
parents:
3752
diff
changeset
|
278 if self._revoke_perms_on_yourself(form_result): |
88ec8f7b9e64
Fixed issues with group renames for local repository group admins.
Marcin Kuzminski <marcin@python-works.com>
parents:
3752
diff
changeset
|
279 msg = _('Cannot revoke permission for yourself as admin') |
88ec8f7b9e64
Fixed issues with group renames for local repository group admins.
Marcin Kuzminski <marcin@python-works.com>
parents:
3752
diff
changeset
|
280 h.flash(msg, category='warning') |
88ec8f7b9e64
Fixed issues with group renames for local repository group admins.
Marcin Kuzminski <marcin@python-works.com>
parents:
3752
diff
changeset
|
281 return redirect(url('edit_repos_group', group_name=group_name)) |
88ec8f7b9e64
Fixed issues with group renames for local repository group admins.
Marcin Kuzminski <marcin@python-works.com>
parents:
3752
diff
changeset
|
282 recursive = form_result['recursive'] |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
283 # iterate over all members(if in recursive mode) of this groups and |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
284 # set the permissions ! |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
285 # this can be potentially heavy operation |
3883
88ec8f7b9e64
Fixed issues with group renames for local repository group admins.
Marcin Kuzminski <marcin@python-works.com>
parents:
3752
diff
changeset
|
286 ReposGroupModel()._update_permissions(c.repos_group, |
88ec8f7b9e64
Fixed issues with group renames for local repository group admins.
Marcin Kuzminski <marcin@python-works.com>
parents:
3752
diff
changeset
|
287 form_result['perms_new'], |
88ec8f7b9e64
Fixed issues with group renames for local repository group admins.
Marcin Kuzminski <marcin@python-works.com>
parents:
3752
diff
changeset
|
288 form_result['perms_updates'], |
88ec8f7b9e64
Fixed issues with group renames for local repository group admins.
Marcin Kuzminski <marcin@python-works.com>
parents:
3752
diff
changeset
|
289 recursive) |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
290 #TODO: implement this |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
291 #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:
3705
diff
changeset
|
292 # 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:
3705
diff
changeset
|
293 Session().commit() |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
294 h.flash(_('Repository Group permissions updated'), category='success') |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
295 return redirect(url('edit_repos_group', group_name=group_name)) |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
296 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
297 @HasReposGroupPermissionAnyDecorator('group.admin') |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
298 def delete_repo_group_perm_member(self, group_name): |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
299 """ |
3410
5f1850e4712a
"Users groups" is grammatically incorrect English - rename to "user groups"
Mads Kiilerich <madski@unity3d.com>
parents:
3332
diff
changeset
|
300 DELETE an existing repository group permission user |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
301 |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
302 :param group_name: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
303 """ |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
304 try: |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
305 obj_type = request.POST.get('obj_type') |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
306 obj_id = None |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
307 if obj_type == 'user': |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
308 obj_id = safe_int(request.POST.get('user_id')) |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
309 elif obj_type == 'user_group': |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
310 obj_id = safe_int(request.POST.get('user_group_id')) |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
311 |
3332
92dfc033ee6f
forbid removing yourself as beeing an admin of a group
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
312 if not c.rhodecode_user.is_admin: |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
313 if obj_type == 'user' and c.rhodecode_user.user_id == obj_id: |
3332
92dfc033ee6f
forbid removing yourself as beeing an admin of a group
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
314 msg = _('Cannot revoke permission for yourself as admin') |
92dfc033ee6f
forbid removing yourself as beeing an admin of a group
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
315 h.flash(msg, category='warning') |
92dfc033ee6f
forbid removing yourself as beeing an admin of a group
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
316 raise Exception('revoke admin permission on self') |
2820
c0cc8f8a71b0
Permissions on group can be set in recursive mode setting defined permission to all children
Marcin Kuzminski <marcin@python-works.com>
parents:
2749
diff
changeset
|
317 recursive = str2bool(request.POST.get('recursive', False)) |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
318 if obj_type == 'user': |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
319 ReposGroupModel().delete_permission( |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
320 repos_group=group_name, obj=obj_id, |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
321 obj_type='user', recursive=recursive |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
322 ) |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
323 elif obj_type == 'user_group': |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
324 ReposGroupModel().delete_permission( |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
325 repos_group=group_name, obj=obj_id, |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
326 obj_type='users_group', recursive=recursive |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
327 ) |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
328 |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2631
diff
changeset
|
329 Session().commit() |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
330 except Exception: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
331 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
|
332 h.flash(_('An error occurred during revoking of permission'), |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
333 category='error') |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
334 raise HTTPInternalServerError() |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
335 |
1538
27be8f94c207
implements #226 repo groups available by path
Marcin Kuzminski <marcin@python-works.com>
parents:
1482
diff
changeset
|
336 def show_by_name(self, group_name): |
2055
c8a8684efc74
fixed issue #370
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
337 """ |
c8a8684efc74
fixed issue #370
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
338 This is a proxy that does a lookup group_name -> id, and shows |
c8a8684efc74
fixed issue #370
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
339 the group by id view instead |
c8a8684efc74
fixed issue #370
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
340 """ |
c8a8684efc74
fixed issue #370
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
341 group_name = group_name.rstrip('/') |
2497
5a8c19c4dbe1
Fixed bug in repos group discovery, when inner folder of bare git repos were detected as a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2496
diff
changeset
|
342 id_ = RepoGroup.get_by_group_name(group_name) |
5a8c19c4dbe1
Fixed bug in repos group discovery, when inner folder of bare git repos were detected as a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2496
diff
changeset
|
343 if id_: |
5a8c19c4dbe1
Fixed bug in repos group discovery, when inner folder of bare git repos were detected as a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2496
diff
changeset
|
344 return self.show(id_.group_id) |
5a8c19c4dbe1
Fixed bug in repos group discovery, when inner folder of bare git repos were detected as a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2496
diff
changeset
|
345 raise HTTPNotFound |
1538
27be8f94c207
implements #226 repo groups available by path
Marcin Kuzminski <marcin@python-works.com>
parents:
1482
diff
changeset
|
346 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
347 @HasReposGroupPermissionAnyDecorator('group.read', 'group.write', |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
348 'group.admin') |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
349 def show(self, group_name, format='html'): |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
350 """GET /repos_groups/group_name: Show a specific item""" |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
351 # url('repos_group', group_name=GROUP_NAME) |
1171 | 352 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
353 c.group = c.repos_group = ReposGroupModel()._get_repo_group(group_name) |
2496
fddd8e3fc157
use get_or_404 where possible
Marcin Kuzminski <marcin@python-works.com>
parents:
2055
diff
changeset
|
354 c.group_repos = c.group.repositories.all() |
1193
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
355 |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
356 #overwrite our cached list with current filter |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1349
diff
changeset
|
357 gr_filter = c.group_repos |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1349
diff
changeset
|
358 c.repo_cnt = 0 |
1343
a04fe5986109
#47 implemented basic gui for browsing repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
359 |
2831
0959096b2c02
Wraps group listing with permissions check so they don't get displayed
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
360 groups = RepoGroup.query().order_by(RepoGroup.group_name)\ |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
361 .filter(RepoGroup.group_parent_id == c.group.group_id).all() |
2831
0959096b2c02
Wraps group listing with permissions check so they don't get displayed
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
362 c.groups = self.scm_model.get_repos_groups(groups) |
2945
68e95f5ae3a7
lightweight dashboard fix for repos group
Marcin Kuzminski <marcin@python-works.com>
parents:
2831
diff
changeset
|
363 |
3752
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3715
diff
changeset
|
364 c.repos_list = Repository.query()\ |
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3715
diff
changeset
|
365 .filter(Repository.group_id == c.group.group_id)\ |
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3715
diff
changeset
|
366 .order_by(func.lower(Repository.repo_name))\ |
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3715
diff
changeset
|
367 .all() |
2945
68e95f5ae3a7
lightweight dashboard fix for repos group
Marcin Kuzminski <marcin@python-works.com>
parents:
2831
diff
changeset
|
368 |
3752
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3715
diff
changeset
|
369 repos_data = RepoModel().get_repos_as_dict(repos_list=c.repos_list, |
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3715
diff
changeset
|
370 admin=False) |
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3715
diff
changeset
|
371 #json used to render the grid |
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3715
diff
changeset
|
372 c.data = json.dumps(repos_data) |
2973
9937afa7f093
whitespace cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2945
diff
changeset
|
373 |
1193
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
374 return render('admin/repos_groups/repos_groups.html') |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
375 |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
376 @HasReposGroupPermissionAnyDecorator('group.admin') |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
377 def edit(self, group_name, format='html'): |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
378 """GET /repos_groups/group_name/edit: Form to edit an existing item""" |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
379 # url('edit_repos_group', group_name=GROUP_NAME) |
1349
526120c77a38
#47 added editing of groups, and moving them between. Added check constraint for groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1347
diff
changeset
|
380 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3705
diff
changeset
|
381 c.repos_group = ReposGroupModel()._get_repo_group(group_name) |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
382 #we can only allow moving empty group if it's already a top-level |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
383 #group, ie has no parents, or we're admin |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
384 if HasPermissionAll('hg.admin')('group edit'): |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
385 #we're global admin, we're ok and we can create TOP level groups |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
386 allow_empty_group = True |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
387 elif not c.repos_group.parent_group: |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
388 allow_empty_group = True |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
389 else: |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
390 allow_empty_group = False |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
391 |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
392 self.__load_defaults(allow_empty_group=allow_empty_group, |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
393 exclude_group_ids=[c.repos_group.group_id]) |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3167
diff
changeset
|
394 defaults = self.__load_data(c.repos_group.group_id) |
1349
526120c77a38
#47 added editing of groups, and moving them between. Added check constraint for groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1347
diff
changeset
|
395 |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
396 return htmlfill.render( |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
397 render('admin/repos_groups/repos_groups_edit.html'), |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
398 defaults=defaults, |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
399 encoding="UTF-8", |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
400 force_defaults=False |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
401 ) |