Skip to content

Commit

Permalink
Fix a bug where saving a Group would throw a 500 error (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
KiOui authored Sep 13, 2023
1 parent e002760 commit ec0dc09
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion website/users/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from users.models import GroupSettings
from users.services import update_staff_status
from django.contrib.auth.models import Group

User = get_user_model()

Expand All @@ -20,4 +21,9 @@ def after_user_groups_changed(sender, instance, **kwargs):
"""Update the is_staff value of the users when they are added to groups."""
action = kwargs.get("action")
if action == "post_add" or action == "post_remove":
update_staff_status(instance)
# This receiver gets triggered by both User and Group objects.
if isinstance(instance, User):
update_staff_status(instance)
elif isinstance(instance, Group):
for user in instance.user_set.all():
update_staff_status(user)

0 comments on commit ec0dc09

Please sign in to comment.