Show More
@@ -24,6 +24,7 b' import deform' | |||||
24 | from pyramid.view import view_config |
|
24 | from pyramid.view import view_config | |
25 | from pyramid.httpexceptions import HTTPFound |
|
25 | from pyramid.httpexceptions import HTTPFound | |
26 |
|
26 | |||
|
27 | from rhodecode import events | |||
27 | from rhodecode.apps._base import RepoGroupAppView |
|
28 | from rhodecode.apps._base import RepoGroupAppView | |
28 | from rhodecode.forms import RcForm |
|
29 | from rhodecode.forms import RcForm | |
29 | from rhodecode.lib import helpers as h |
|
30 | from rhodecode.lib import helpers as h | |
@@ -31,7 +32,7 b' from rhodecode.lib import audit_logger' | |||||
31 | from rhodecode.lib.auth import ( |
|
32 | from rhodecode.lib.auth import ( | |
32 | LoginRequired, HasPermissionAll, |
|
33 | LoginRequired, HasPermissionAll, | |
33 | HasRepoGroupPermissionAny, HasRepoGroupPermissionAnyDecorator, CSRFRequired) |
|
34 | HasRepoGroupPermissionAny, HasRepoGroupPermissionAnyDecorator, CSRFRequired) | |
34 | from rhodecode.model.db import Session, RepoGroup |
|
35 | from rhodecode.model.db import Session, RepoGroup, User | |
35 | from rhodecode.model.scm import RepoGroupList |
|
36 | from rhodecode.model.scm import RepoGroupList | |
36 | from rhodecode.model.repo_group import RepoGroupModel |
|
37 | from rhodecode.model.repo_group import RepoGroupModel | |
37 | from rhodecode.model.validation_schema.schemas import repo_group_schema |
|
38 | from rhodecode.model.validation_schema.schemas import repo_group_schema | |
@@ -72,8 +73,6 b' class RepoGroupSettingsView(RepoGroupApp' | |||||
72 | if add_parent_group: |
|
73 | if add_parent_group: | |
73 | c.repo_groups_choices.append(parent_group.group_id) |
|
74 | c.repo_groups_choices.append(parent_group.group_id) | |
74 | c.repo_groups.append(RepoGroup._generate_choice(parent_group)) |
|
75 | c.repo_groups.append(RepoGroup._generate_choice(parent_group)) | |
75 |
|
||||
76 |
|
||||
77 | return c |
|
76 | return c | |
78 |
|
77 | |||
79 | def _can_create_repo_group(self, parent_group_id=None): |
|
78 | def _can_create_repo_group(self, parent_group_id=None): | |
@@ -179,5 +178,12 b' class RepoGroupSettingsView(RepoGroupApp' | |||||
179 | h.flash(_('Error occurred during update of repository group %s') |
|
178 | h.flash(_('Error occurred during update of repository group %s') | |
180 | % old_repo_group_name, category='error') |
|
179 | % old_repo_group_name, category='error') | |
181 |
|
180 | |||
|
181 | name_changed = old_repo_group_name != new_repo_group_name | |||
|
182 | if name_changed: | |||
|
183 | owner = User.get_by_username(schema_data['repo_group_owner']) | |||
|
184 | owner_id = owner.user_id if owner else self._rhodecode_user.user_id | |||
|
185 | events.trigger(events.UserPermissionsChange([ | |||
|
186 | self._rhodecode_user.user_id, owner_id])) | |||
|
187 | ||||
182 | raise HTTPFound( |
|
188 | raise HTTPFound( | |
183 | h.route_path('edit_repo_group', repo_group_name=new_repo_group_name)) |
|
189 | h.route_path('edit_repo_group', repo_group_name=new_repo_group_name)) |
@@ -24,13 +24,14 b' import deform' | |||||
24 | from pyramid.httpexceptions import HTTPFound |
|
24 | from pyramid.httpexceptions import HTTPFound | |
25 | from pyramid.view import view_config |
|
25 | from pyramid.view import view_config | |
26 |
|
26 | |||
|
27 | from rhodecode import events | |||
27 | from rhodecode.apps._base import RepoAppView |
|
28 | from rhodecode.apps._base import RepoAppView | |
28 | from rhodecode.forms import RcForm |
|
29 | from rhodecode.forms import RcForm | |
29 | from rhodecode.lib import helpers as h |
|
30 | from rhodecode.lib import helpers as h | |
30 | from rhodecode.lib import audit_logger |
|
31 | from rhodecode.lib import audit_logger | |
31 | from rhodecode.lib.auth import ( |
|
32 | from rhodecode.lib.auth import ( | |
32 | LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired) |
|
33 | LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired) | |
33 | from rhodecode.model.db import RepositoryField, RepoGroup, Repository |
|
34 | from rhodecode.model.db import RepositoryField, RepoGroup, Repository, User | |
34 | from rhodecode.model.meta import Session |
|
35 | from rhodecode.model.meta import Session | |
35 | from rhodecode.model.repo import RepoModel |
|
36 | from rhodecode.model.repo import RepoModel | |
36 | from rhodecode.model.scm import RepoGroupList, ScmModel |
|
37 | from rhodecode.model.scm import RepoGroupList, ScmModel | |
@@ -71,8 +72,6 b' class RepoSettingsView(RepoAppView):' | |||||
71 | c.personal_repo_group = c.auth_user.personal_repo_group |
|
72 | c.personal_repo_group = c.auth_user.personal_repo_group | |
72 | c.repo_fields = RepositoryField.query()\ |
|
73 | c.repo_fields = RepositoryField.query()\ | |
73 | .filter(RepositoryField.repository == self.db_repo).all() |
|
74 | .filter(RepositoryField.repository == self.db_repo).all() | |
74 |
|
||||
75 |
|
||||
76 | return c |
|
75 | return c | |
77 |
|
76 | |||
78 | def _get_schema(self, c, old_values=None): |
|
77 | def _get_schema(self, c, old_values=None): | |
@@ -176,6 +175,13 b' class RepoSettingsView(RepoAppView):' | |||||
176 | h.flash(_('Error occurred during update of repository {}').format( |
|
175 | h.flash(_('Error occurred during update of repository {}').format( | |
177 | old_repo_name), category='error') |
|
176 | old_repo_name), category='error') | |
178 |
|
177 | |||
|
178 | name_changed = old_repo_name != new_repo_name | |||
|
179 | if name_changed: | |||
|
180 | owner = User.get_by_username(schema_data['repo_owner']) | |||
|
181 | owner_id = owner.user_id if owner else self._rhodecode_user.user_id | |||
|
182 | events.trigger(events.UserPermissionsChange([ | |||
|
183 | self._rhodecode_user.user_id, owner_id])) | |||
|
184 | ||||
179 | raise HTTPFound( |
|
185 | raise HTTPFound( | |
180 | h.route_path('edit_repo', repo_name=new_repo_name)) |
|
186 | h.route_path('edit_repo', repo_name=new_repo_name)) | |
181 |
|
187 |
@@ -140,6 +140,9 b' class UserGroupsView(UserGroupAppView):' | |||||
140 | user_group = self.db_user_group |
|
140 | user_group = self.db_user_group | |
141 | user_group_id = user_group.users_group_id |
|
141 | user_group_id = user_group.users_group_id | |
142 |
|
142 | |||
|
143 | old_user_group_name = self.db_user_group_name | |||
|
144 | new_user_group_name = old_user_group_name | |||
|
145 | ||||
143 | c = self.load_default_context() |
|
146 | c = self.load_default_context() | |
144 | c.user_group = user_group |
|
147 | c.user_group = user_group | |
145 | c.group_members_obj = [x.user for x in c.user_group.members] |
|
148 | c.group_members_obj = [x.user for x in c.user_group.members] | |
@@ -152,7 +155,7 b' class UserGroupsView(UserGroupAppView):' | |||||
152 | old_data=c.user_group.get_dict(), allow_disabled=True)() |
|
155 | old_data=c.user_group.get_dict(), allow_disabled=True)() | |
153 |
|
156 | |||
154 | old_values = c.user_group.get_api_data() |
|
157 | old_values = c.user_group.get_api_data() | |
155 | user_group_name = self.request.POST.get('users_group_name') |
|
158 | ||
156 | try: |
|
159 | try: | |
157 | form_result = users_group_form.to_python(self.request.POST) |
|
160 | form_result = users_group_form.to_python(self.request.POST) | |
158 | pstruct = peppercorn.parse(self.request.POST.items()) |
|
161 | pstruct = peppercorn.parse(self.request.POST.items()) | |
@@ -160,7 +163,7 b' class UserGroupsView(UserGroupAppView):' | |||||
160 |
|
163 | |||
161 | user_group, added_members, removed_members = \ |
|
164 | user_group, added_members, removed_members = \ | |
162 | UserGroupModel().update(c.user_group, form_result) |
|
165 | UserGroupModel().update(c.user_group, form_result) | |
163 |
|
|
166 | new_user_group_name = form_result['users_group_name'] | |
164 |
|
167 | |||
165 | for user_id in added_members: |
|
168 | for user_id in added_members: | |
166 | user = User.get(user_id) |
|
169 | user = User.get(user_id) | |
@@ -182,12 +185,20 b' class UserGroupsView(UserGroupAppView):' | |||||
182 | 'user_group.edit', action_data={'old_data': old_values}, |
|
185 | 'user_group.edit', action_data={'old_data': old_values}, | |
183 | user=self._rhodecode_user) |
|
186 | user=self._rhodecode_user) | |
184 |
|
187 | |||
185 |
h.flash(_('Updated user group %s') % |
|
188 | h.flash(_('Updated user group %s') % new_user_group_name, | |
186 | category='success') |
|
189 | category='success') | |
187 |
|
190 | |||
188 | affected_user_ids = [] |
|
191 | affected_user_ids = [] | |
189 | for user_id in added_members + removed_members: |
|
192 | for user_id in added_members + removed_members: | |
190 | affected_user_ids.append(user_id) |
|
193 | affected_user_ids.append(user_id) | |
|
194 | ||||
|
195 | name_changed = old_user_group_name != new_user_group_name | |||
|
196 | if name_changed: | |||
|
197 | owner = User.get_by_username(form_result['user']) | |||
|
198 | owner_id = owner.user_id if owner else self._rhodecode_user.user_id | |||
|
199 | affected_user_ids.append(self._rhodecode_user.user_id) | |||
|
200 | affected_user_ids.append(owner_id) | |||
|
201 | ||||
191 | events.trigger(events.UserPermissionsChange(affected_user_ids)) |
|
202 | events.trigger(events.UserPermissionsChange(affected_user_ids)) | |
192 |
|
203 | |||
193 | Session().commit() |
|
204 | Session().commit() | |
@@ -211,7 +222,7 b' class UserGroupsView(UserGroupAppView):' | |||||
211 | except Exception: |
|
222 | except Exception: | |
212 | log.exception("Exception during update of user group") |
|
223 | log.exception("Exception during update of user group") | |
213 | h.flash(_('Error occurred during update of user group %s') |
|
224 | h.flash(_('Error occurred during update of user group %s') | |
214 | % user_group_name, category='error') |
|
225 | % new_user_group_name, category='error') | |
215 |
|
226 | |||
216 | raise HTTPFound( |
|
227 | raise HTTPFound( | |
217 | h.route_path('edit_user_group', user_group_id=user_group_id)) |
|
228 | h.route_path('edit_user_group', user_group_id=user_group_id)) |
General Comments 0
You need to be logged in to leave comments.
Login now