This is an automated email from the ASF dual-hosted git repository. brondsem pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/allura.git
commit 4ac5e5ac8a30afc0a61d96f0c187e64f60914261 Author: Vrinda A <vrind...@in.bosch.com> AuthorDate: Wed Dec 1 19:22:54 2021 +0530 [#8391] Unsubscribe from a project when a user is removed from Admin group --- Allura/allura/app.py | 11 +++++++++++ Allura/allura/ext/admin/admin_main.py | 3 +++ 2 files changed, 14 insertions(+) diff --git a/Allura/allura/app.py b/Allura/allura/app.py index 9f50c18..e2e34db 100644 --- a/Allura/allura/app.py +++ b/Allura/allura/app.py @@ -519,6 +519,17 @@ class Application: project_id=self.project._id, app_config_id=self.config._id) + def unsubscribe(self, user): + """Unsubscribe :class:`user <allura.model.auth.User>` to the + :class:`allura.model.notification.Mailbox` for this Application. + + """ + if user and user != model.User.anonymous(): + model.Mailbox.unsubscribe( + user_id=user._id, + project_id=self.project._id, + app_config_id=self.config._id) + @classmethod def default_options(cls): """Return a ``(name, default value)`` mapping of this Application's diff --git a/Allura/allura/ext/admin/admin_main.py b/Allura/allura/ext/admin/admin_main.py index 43cacf3..f3466d9 100644 --- a/Allura/allura/ext/admin/admin_main.py +++ b/Allura/allura/ext/admin/admin_main.py @@ -1175,6 +1175,9 @@ class GroupsController(BaseController): if len(user_role.roles) == 0: # user has no roles in this project any more, so don't leave a useless doc around user_role.delete() + if group.name == 'Admin': + for ac in c.project.app_configs: + c.project.app_instance(ac).unsubscribe(user) g.post_event('project_updated') return dict()