Mercurial > kallithea
annotate rhodecode/controllers/admin/repos_groups.py @ 3183:54bea1081508 beta
version bump
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 21 Jan 2013 01:10:30 +0100 |
parents | 87258a137018 |
children | b4daef4cc26d |
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 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
6 Repositories 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 |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
33 from pylons.controllers.util import 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 |
2945
68e95f5ae3a7
lightweight dashboard fix for repos group
Marcin Kuzminski <marcin@python-works.com>
parents:
2831
diff
changeset
|
40 from rhodecode.lib.ext_json 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,\ |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
42 HasReposGroupPermissionAnyDecorator |
1171 | 43 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
|
44 from rhodecode.model.db import RepoGroup, Repository |
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
|
45 from rhodecode.model.repos_group import ReposGroupModel |
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
|
46 from rhodecode.model.forms import ReposGroupForm |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
47 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
|
48 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
|
49 from webob.exc import HTTPInternalServerError, HTTPNotFound |
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
|
50 from rhodecode.lib.utils2 import str2bool |
2945
68e95f5ae3a7
lightweight dashboard fix for repos group
Marcin Kuzminski <marcin@python-works.com>
parents:
2831
diff
changeset
|
51 from sqlalchemy.sql.expression import func |
1171 | 52 |
53 log = logging.getLogger(__name__) | |
54 | |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
55 |
1171 | 56 class ReposGroupsController(BaseController): |
57 """REST Controller styled on the Atom Publishing Protocol""" | |
58 # To properly map this controller, ensure your config/routing.py | |
59 # file has a resource setup: | |
60 # map.resource('repos_group', 'repos_groups') | |
61 | |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
62 @LoginRequired() |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
63 def __before__(self): |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
64 super(ReposGroupsController, self).__before__() |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
65 |
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
|
66 def __load_defaults(self): |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1547
diff
changeset
|
67 c.repo_groups = RepoGroup.groups_choices() |
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
|
68 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups) |
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
|
69 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
70 repo_model = RepoModel() |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
71 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
|
72 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
|
73 |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
74 def __load_data(self, group_id): |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
75 """ |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
76 Load defaults settings for edit, and update |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
77 |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
78 :param group_id: |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
79 """ |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
80 self.__load_defaults() |
2496
fddd8e3fc157
use get_or_404 where possible
Marcin Kuzminski <marcin@python-works.com>
parents:
2055
diff
changeset
|
81 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
|
82 data = repo_group.get_dict() |
1538
27be8f94c207
implements #226 repo groups available by path
Marcin Kuzminski <marcin@python-works.com>
parents:
1482
diff
changeset
|
83 data['group_name'] = repo_group.name |
27be8f94c207
implements #226 repo groups available by path
Marcin Kuzminski <marcin@python-works.com>
parents:
1482
diff
changeset
|
84 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
85 # fill repository users |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
86 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
|
87 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
|
88 p.permission.permission_name}) |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
89 |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
90 # fill repository groups |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
91 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
|
92 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
|
93 p.permission.permission_name}) |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
94 |
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 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
|
96 |
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
|
97 @HasPermissionAnyDecorator('hg.admin') |
1171 | 98 def index(self, format='html'): |
99 """GET /repos_groups: All items in the collection""" | |
100 # url('repos_groups') | |
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
|
101 sk = lambda g: g.parents[0].group_name if g.parents else g.group_name |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1547
diff
changeset
|
102 c.groups = sorted(RepoGroup.query().all(), 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
|
103 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
|
104 |
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
|
105 @HasPermissionAnyDecorator('hg.admin') |
1171 | 106 def create(self): |
107 """POST /repos_groups: Create a new item""" | |
108 # url('repos_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
|
109 self.__load_defaults() |
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
|
110 repos_group_form = ReposGroupForm(available_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
|
111 c.repo_groups_choices)() |
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
|
112 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
|
113 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
|
114 ReposGroupModel().create( |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
115 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
|
116 group_description=form_result['group_description'], |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
117 parent=form_result['group_parent_id'] |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
118 ) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2631
diff
changeset
|
119 Session().commit() |
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
|
120 h.flash(_('created repos group %s') \ |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
121 % 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
|
122 #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
|
123 except formencode.Invalid, errors: |
1171 | 124 |
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
|
125 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
|
126 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
|
127 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
|
128 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
|
129 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
|
130 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
|
131 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
|
132 log.error(traceback.format_exc()) |
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
|
133 h.flash(_('error occurred during creation of repos group %s') \ |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
134 % request.POST.get('group_name'), category='error') |
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
|
135 |
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
|
136 return redirect(url('repos_groups')) |
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
|
137 |
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 @HasPermissionAnyDecorator('hg.admin') |
1171 | 139 def new(self, format='html'): |
140 """GET /repos_groups/new: Form to create a new item""" | |
141 # url('new_repos_group') | |
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
|
142 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
|
143 return render('admin/repos_groups/repos_groups_add.html') |
1171 | 144 |
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
|
145 @HasPermissionAnyDecorator('hg.admin') |
1171 | 146 def update(self, id): |
147 """PUT /repos_groups/id: Update an existing item""" | |
148 # Forms posted to this method should contain a hidden field: | |
149 # <input type="hidden" name="_method" value="PUT" /> | |
150 # Or using helpers: | |
151 # h.form(url('repos_group', id=ID), | |
152 # method='put') | |
153 # url('repos_group', id=ID) | |
154 | |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
155 self.__load_defaults() |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1547
diff
changeset
|
156 c.repos_group = RepoGroup.get(id) |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
157 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
158 repos_group_form = ReposGroupForm( |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
159 edit=True, |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
160 old_data=c.repos_group.get_dict(), |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
161 available_groups=c.repo_groups_choices |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
162 )() |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
163 try: |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
164 form_result = repos_group_form.to_python(dict(request.POST)) |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
165 ReposGroupModel().update(id, form_result) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2631
diff
changeset
|
166 Session().commit() |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
167 h.flash(_('updated repos group %s') \ |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
168 % form_result['group_name'], category='success') |
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
|
169 #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
|
170 except formencode.Invalid, errors: |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
171 |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
172 return htmlfill.render( |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
173 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
|
174 defaults=errors.value, |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
175 errors=errors.error_dict or {}, |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
176 prefix_error=False, |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
177 encoding="UTF-8") |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
178 except Exception: |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
179 log.error(traceback.format_exc()) |
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
|
180 h.flash(_('error occurred during update of repos group %s') \ |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
181 % request.POST.get('group_name'), category='error') |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
182 |
2749
3ed4dae499d0
Recursive set locking on all children of a group.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
183 return redirect(url('edit_repos_group', id=id)) |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
184 |
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
|
185 @HasPermissionAnyDecorator('hg.admin') |
1171 | 186 def delete(self, id): |
187 """DELETE /repos_groups/id: Delete an existing item""" | |
188 # Forms posted to this method should contain a hidden field: | |
189 # <input type="hidden" name="_method" value="DELETE" /> | |
190 # Or using helpers: | |
191 # h.form(url('repos_group', id=ID), | |
192 # method='delete') | |
193 # url('repos_group', id=ID) | |
194 | |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1547
diff
changeset
|
195 gr = RepoGroup.get(id) |
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
|
196 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
|
197 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
|
198 h.flash(_('This group contains %s repositores and cannot be ' |
2570 | 199 'deleted') % len(repos), |
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
|
200 category='error') |
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
|
201 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
|
202 |
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
|
203 try: |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
204 ReposGroupModel().delete(id) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2631
diff
changeset
|
205 Session().commit() |
2749
3ed4dae499d0
Recursive set locking on all children of a group.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
206 h.flash(_('removed repos group %s') % gr.group_name, |
3ed4dae499d0
Recursive set locking on all children of a group.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
207 category='success') |
1482
a39c0e5fca89
removed obsolete sort code
Marcin Kuzminski <marcin@python-works.com>
parents:
1394
diff
changeset
|
208 #TODO: in future action_logger(, '', '', '', self.sa) |
1543
ada6926c374f
Added friendly message about removing a group that still contains subgroups.
Marcin Kuzminski <marcin@python-works.com>
parents:
1538
diff
changeset
|
209 except IntegrityError, e: |
2749
3ed4dae499d0
Recursive set locking on all children of a group.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
210 if str(e.message).find('groups_group_parent_id_fkey') != -1: |
1543
ada6926c374f
Added friendly message about removing a group that still contains subgroups.
Marcin Kuzminski <marcin@python-works.com>
parents:
1538
diff
changeset
|
211 log.error(traceback.format_exc()) |
ada6926c374f
Added friendly message about removing a group that still contains subgroups.
Marcin Kuzminski <marcin@python-works.com>
parents:
1538
diff
changeset
|
212 h.flash(_('Cannot delete this group it still contains ' |
ada6926c374f
Added friendly message about removing a group that still contains subgroups.
Marcin Kuzminski <marcin@python-works.com>
parents:
1538
diff
changeset
|
213 'subgroups'), |
ada6926c374f
Added friendly message about removing a group that still contains subgroups.
Marcin Kuzminski <marcin@python-works.com>
parents:
1538
diff
changeset
|
214 category='warning') |
ada6926c374f
Added friendly message about removing a group that still contains subgroups.
Marcin Kuzminski <marcin@python-works.com>
parents:
1538
diff
changeset
|
215 else: |
ada6926c374f
Added friendly message about removing a group that still contains subgroups.
Marcin Kuzminski <marcin@python-works.com>
parents:
1538
diff
changeset
|
216 log.error(traceback.format_exc()) |
ada6926c374f
Added friendly message about removing a group that still contains subgroups.
Marcin Kuzminski <marcin@python-works.com>
parents:
1538
diff
changeset
|
217 h.flash(_('error occurred during deletion of repos ' |
2570 | 218 'group %s') % gr.group_name, category='error') |
1543
ada6926c374f
Added friendly message about removing a group that still contains subgroups.
Marcin Kuzminski <marcin@python-works.com>
parents:
1538
diff
changeset
|
219 |
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
|
220 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
|
221 log.error(traceback.format_exc()) |
1543
ada6926c374f
Added friendly message about removing a group that still contains subgroups.
Marcin Kuzminski <marcin@python-works.com>
parents:
1538
diff
changeset
|
222 h.flash(_('error occurred during deletion of repos ' |
2570 | 223 'group %s') % gr.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
|
224 |
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
|
225 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
|
226 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
227 @HasReposGroupPermissionAnyDecorator('group.admin') |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
228 def delete_repos_group_user_perm(self, group_name): |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
229 """ |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
230 DELETE an existing repositories group permission user |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
231 |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
232 :param group_name: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
233 """ |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
234 try: |
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
|
235 recursive = str2bool(request.POST.get('recursive', False)) |
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
|
236 ReposGroupModel().delete_permission( |
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
|
237 repos_group=group_name, obj=request.POST['user_id'], |
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
|
238 obj_type='user', recursive=recursive |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
239 ) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2631
diff
changeset
|
240 Session().commit() |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
241 except Exception: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
242 log.error(traceback.format_exc()) |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
243 h.flash(_('An error occurred during deletion of group user'), |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
244 category='error') |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
245 raise HTTPInternalServerError() |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
246 |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
247 @HasReposGroupPermissionAnyDecorator('group.admin') |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
248 def delete_repos_group_users_group_perm(self, group_name): |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
249 """ |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
250 DELETE an existing repositories group permission users group |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
251 |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
252 :param group_name: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
253 """ |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
254 |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
255 try: |
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
|
256 recursive = str2bool(request.POST.get('recursive', False)) |
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
|
257 ReposGroupModel().delete_permission( |
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
|
258 repos_group=group_name, obj=request.POST['users_group_id'], |
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
|
259 obj_type='users_group', recursive=recursive |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
260 ) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2631
diff
changeset
|
261 Session().commit() |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
262 except Exception: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
263 log.error(traceback.format_exc()) |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
264 h.flash(_('An error occurred during deletion of group' |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
265 ' users groups'), |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
266 category='error') |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
267 raise HTTPInternalServerError() |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
268 |
1538
27be8f94c207
implements #226 repo groups available by path
Marcin Kuzminski <marcin@python-works.com>
parents:
1482
diff
changeset
|
269 def show_by_name(self, group_name): |
2055
c8a8684efc74
fixed issue #370
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
270 """ |
c8a8684efc74
fixed issue #370
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
271 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
|
272 the group by id view instead |
c8a8684efc74
fixed issue #370
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
273 """ |
c8a8684efc74
fixed issue #370
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
274 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
|
275 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
|
276 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
|
277 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
|
278 raise HTTPNotFound |
1538
27be8f94c207
implements #226 repo groups available by path
Marcin Kuzminski <marcin@python-works.com>
parents:
1482
diff
changeset
|
279 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
280 @HasReposGroupPermissionAnyDecorator('group.read', 'group.write', |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1961
diff
changeset
|
281 'group.admin') |
1171 | 282 def show(self, id, format='html'): |
283 """GET /repos_groups/id: Show a specific item""" | |
284 # url('repos_group', id=ID) | |
285 | |
2496
fddd8e3fc157
use get_or_404 where possible
Marcin Kuzminski <marcin@python-works.com>
parents:
2055
diff
changeset
|
286 c.group = RepoGroup.get_or_404(id) |
fddd8e3fc157
use get_or_404 where possible
Marcin Kuzminski <marcin@python-works.com>
parents:
2055
diff
changeset
|
287 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
|
288 |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
289 #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
|
290 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
|
291 c.repo_cnt = 0 |
1343
a04fe5986109
#47 implemented basic gui for browsing repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
292 |
2831
0959096b2c02
Wraps group listing with permissions check so they don't get displayed
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
293 groups = RepoGroup.query().order_by(RepoGroup.group_name)\ |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1547
diff
changeset
|
294 .filter(RepoGroup.group_parent_id == 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
|
295 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
|
296 |
68e95f5ae3a7
lightweight dashboard fix for repos group
Marcin Kuzminski <marcin@python-works.com>
parents:
2831
diff
changeset
|
297 if c.visual.lightweight_dashboard is False: |
3167
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
298 c.repos_list = self.scm_model.get_repos(all_repos=gr_filter) |
2945
68e95f5ae3a7
lightweight dashboard fix for repos group
Marcin Kuzminski <marcin@python-works.com>
parents:
2831
diff
changeset
|
299 ## lightweight version of dashboard |
68e95f5ae3a7
lightweight dashboard fix for repos group
Marcin Kuzminski <marcin@python-works.com>
parents:
2831
diff
changeset
|
300 else: |
68e95f5ae3a7
lightweight dashboard fix for repos group
Marcin Kuzminski <marcin@python-works.com>
parents:
2831
diff
changeset
|
301 c.repos_list = Repository.query()\ |
68e95f5ae3a7
lightweight dashboard fix for repos group
Marcin Kuzminski <marcin@python-works.com>
parents:
2831
diff
changeset
|
302 .filter(Repository.group_id == id)\ |
68e95f5ae3a7
lightweight dashboard fix for repos group
Marcin Kuzminski <marcin@python-works.com>
parents:
2831
diff
changeset
|
303 .order_by(func.lower(Repository.repo_name))\ |
68e95f5ae3a7
lightweight dashboard fix for repos group
Marcin Kuzminski <marcin@python-works.com>
parents:
2831
diff
changeset
|
304 .all() |
68e95f5ae3a7
lightweight dashboard fix for repos group
Marcin Kuzminski <marcin@python-works.com>
parents:
2831
diff
changeset
|
305 |
3167
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
306 repos_data = RepoModel().get_repos_as_dict(repos_list=c.repos_list, |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
307 admin=False) |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
308 #json used to render the grid |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
309 c.data = json.dumps(repos_data) |
2973
9937afa7f093
whitespace cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2945
diff
changeset
|
310 |
1193
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
311 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
|
312 |
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
|
313 @HasPermissionAnyDecorator('hg.admin') |
1171 | 314 def edit(self, id, format='html'): |
315 """GET /repos_groups/id/edit: Form to edit an existing item""" | |
316 # url('edit_repos_group', id=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
|
317 |
2631
f597cfb492f9
Added quick links for editing permissions for users from permission overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
318 c.repos_group = ReposGroupModel()._get_repos_group(id) |
f597cfb492f9
Added quick links for editing permissions for users from permission overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
319 defaults = self.__load_data(c.repos_group.group_id) |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
320 |
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
|
321 # we need to exclude this group from the group list for editing |
2631
f597cfb492f9
Added quick links for editing permissions for users from permission overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
322 c.repo_groups = filter(lambda x: x[0] != c.repos_group.group_id, |
f597cfb492f9
Added quick links for editing permissions for users from permission overview
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
323 c.repo_groups) |
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
|
324 |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
325 return htmlfill.render( |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
326 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
|
327 defaults=defaults, |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
328 encoding="UTF-8", |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
329 force_defaults=False |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
330 ) |