Fix no-responses created for disabled users.

This commit is contained in:
Casper V. Kristensen 2020-01-07 04:43:24 +01:00
parent dc9928f316
commit 4cca8ced19
Signed by: caspervk
GPG key ID: 289CA03790535054

View file

@ -32,6 +32,8 @@ def create_user_no_responses(instance: User, **kwargs):
# Delete all pre-existing no-responses for this user, in case date_joined or main was changed
RaidResponse.objects.filter(character__user=instance, status=RaidResponse.NO_RESPONSE).delete()
# Then create them (again)
if not instance.is_active:
return
RaidResponse.objects.bulk_create(
RaidResponse(
raid=raid,
@ -40,6 +42,6 @@ def create_user_no_responses(instance: User, **kwargs):
attendance=RaidResponse.STATUS_DEFAULT_ATTENDANCE[RaidResponse.NO_RESPONSE]
)
for raid in Raid.objects.exclude(
Q(response_deadline__lt=instance.date_joined) | Q(responses__character__user=instance)
Q(date__lt=instance.date_joined) | Q(responses__character__user=instance)
)
)