diff options
author | 2021-08-31 19:21:36 +0200 | |
---|---|---|
committer | 2021-11-26 21:14:16 +0100 | |
commit | f34a52016bd5a7d50c1146d6fbd213ce889f58c7 (patch) | |
tree | 358f03d4735a91391272070c9eb27c60318be70c /pydis_site/apps/api/signals.py | |
parent | Patch roles test to use fresh instance from the DB (diff) |
Patch signals to use post_delete, instead of pre_delete
From now on the signal will only get executed after the Role has been deleted
The commit also introduces minor changes in the tests of roles
Diffstat (limited to 'pydis_site/apps/api/signals.py')
-rw-r--r-- | pydis_site/apps/api/signals.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/pydis_site/apps/api/signals.py b/pydis_site/apps/api/signals.py index c69704b1..5c26bfb6 100644 --- a/pydis_site/apps/api/signals.py +++ b/pydis_site/apps/api/signals.py @@ -1,10 +1,10 @@ -from django.db.models.signals import pre_delete +from django.db.models.signals import post_delete from django.dispatch import receiver from pydis_site.apps.api.models.bot import Role, User -@receiver(signal=pre_delete, sender=Role) +@receiver(signal=post_delete, sender=Role) def delete_role_from_user(sender: Role, instance: Role, **kwargs) -> None: """Unassigns the Role (instance) that is being deleted from every user that has it.""" for user in User.objects.filter(roles__contains=[instance.id]): |