##// END OF EJS Templates
caches: flush permission caches when editing affected objects so we can reach them right after changes.
marcink -
r2876:3939ff15 default
parent child Browse files
Show More
@@ -24,6 +24,7 b' import deform'
24 24 from pyramid.view import view_config
25 25 from pyramid.httpexceptions import HTTPFound
26 26
27 from rhodecode import events
27 28 from rhodecode.apps._base import RepoGroupAppView
28 29 from rhodecode.forms import RcForm
29 30 from rhodecode.lib import helpers as h
@@ -31,7 +32,7 b' from rhodecode.lib import audit_logger'
31 32 from rhodecode.lib.auth import (
32 33 LoginRequired, HasPermissionAll,
33 34 HasRepoGroupPermissionAny, HasRepoGroupPermissionAnyDecorator, CSRFRequired)
34 from rhodecode.model.db import Session, RepoGroup
35 from rhodecode.model.db import Session, RepoGroup, User
35 36 from rhodecode.model.scm import RepoGroupList
36 37 from rhodecode.model.repo_group import RepoGroupModel
37 38 from rhodecode.model.validation_schema.schemas import repo_group_schema
@@ -72,8 +73,6 b' class RepoGroupSettingsView(RepoGroupApp'
72 73 if add_parent_group:
73 74 c.repo_groups_choices.append(parent_group.group_id)
74 75 c.repo_groups.append(RepoGroup._generate_choice(parent_group))
75
76
77 76 return c
78 77
79 78 def _can_create_repo_group(self, parent_group_id=None):
@@ -179,5 +178,12 b' class RepoGroupSettingsView(RepoGroupApp'
179 178 h.flash(_('Error occurred during update of repository group %s')
180 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 188 raise HTTPFound(
183 189 h.route_path('edit_repo_group', repo_group_name=new_repo_group_name))
@@ -24,13 +24,14 b' import deform'
24 24 from pyramid.httpexceptions import HTTPFound
25 25 from pyramid.view import view_config
26 26
27 from rhodecode import events
27 28 from rhodecode.apps._base import RepoAppView
28 29 from rhodecode.forms import RcForm
29 30 from rhodecode.lib import helpers as h
30 31 from rhodecode.lib import audit_logger
31 32 from rhodecode.lib.auth import (
32 33 LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired)
33 from rhodecode.model.db import RepositoryField, RepoGroup, Repository
34 from rhodecode.model.db import RepositoryField, RepoGroup, Repository, User
34 35 from rhodecode.model.meta import Session
35 36 from rhodecode.model.repo import RepoModel
36 37 from rhodecode.model.scm import RepoGroupList, ScmModel
@@ -71,8 +72,6 b' class RepoSettingsView(RepoAppView):'
71 72 c.personal_repo_group = c.auth_user.personal_repo_group
72 73 c.repo_fields = RepositoryField.query()\
73 74 .filter(RepositoryField.repository == self.db_repo).all()
74
75
76 75 return c
77 76
78 77 def _get_schema(self, c, old_values=None):
@@ -176,6 +175,13 b' class RepoSettingsView(RepoAppView):'
176 175 h.flash(_('Error occurred during update of repository {}').format(
177 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 185 raise HTTPFound(
180 186 h.route_path('edit_repo', repo_name=new_repo_name))
181 187
@@ -140,6 +140,9 b' class UserGroupsView(UserGroupAppView):'
140 140 user_group = self.db_user_group
141 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 146 c = self.load_default_context()
144 147 c.user_group = user_group
145 148 c.group_members_obj = [x.user for x in c.user_group.members]
@@ -152,7 +155,7 b' class UserGroupsView(UserGroupAppView):'
152 155 old_data=c.user_group.get_dict(), allow_disabled=True)()
153 156
154 157 old_values = c.user_group.get_api_data()
155 user_group_name = self.request.POST.get('users_group_name')
158
156 159 try:
157 160 form_result = users_group_form.to_python(self.request.POST)
158 161 pstruct = peppercorn.parse(self.request.POST.items())
@@ -160,7 +163,7 b' class UserGroupsView(UserGroupAppView):'
160 163
161 164 user_group, added_members, removed_members = \
162 165 UserGroupModel().update(c.user_group, form_result)
163 updated_user_group = form_result['users_group_name']
166 new_user_group_name = form_result['users_group_name']
164 167
165 168 for user_id in added_members:
166 169 user = User.get(user_id)
@@ -182,12 +185,20 b' class UserGroupsView(UserGroupAppView):'
182 185 'user_group.edit', action_data={'old_data': old_values},
183 186 user=self._rhodecode_user)
184 187
185 h.flash(_('Updated user group %s') % updated_user_group,
188 h.flash(_('Updated user group %s') % new_user_group_name,
186 189 category='success')
187 190
188 191 affected_user_ids = []
189 192 for user_id in added_members + removed_members:
190 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 202 events.trigger(events.UserPermissionsChange(affected_user_ids))
192 203
193 204 Session().commit()
@@ -211,7 +222,7 b' class UserGroupsView(UserGroupAppView):'
211 222 except Exception:
212 223 log.exception("Exception during update of user group")
213 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 227 raise HTTPFound(
217 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