From 7ff779b3a9cfb67bd5a42630eeea0887248b0aad Mon Sep 17 00:00:00 2001 From: bonnedav Date: Wed, 21 Aug 2024 02:22:57 -0600 Subject: [PATCH] WHO_CAN_ANONYMIZE_ACCOUNTS Fix for #943 . --- askbot/models/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py index 22e45b2d90..283c6beb42 100644 --- a/askbot/models/__init__.py +++ b/askbot/models/__init__.py @@ -527,6 +527,11 @@ def user_has_badge(self, badge): def user_can_anonymize_account(self, user): """`True`, if `self` can anonymize and disable account of `user`""" perm = askbot_settings.WHO_CAN_ANONYMIZE_ACCOUNTS + + # non-admins cannot remove admins or moderators + if not self.is_administrator() and user.is_administrator_or_moderator(): + return False + if perm == 'admins': return self.is_administrator() and self.pk != user.pk elif self.is_administrator_or_moderator():