Remove magic constants "A" and "I"

These stand for "admitted" and "interested", but we have constants for
that.
This commit is contained in:
Midgard 2020-07-25 18:28:04 +02:00
parent d107409619
commit 3e88f1d207
Signed by: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -10,7 +10,7 @@ def calc_score(user: CustomUser):
registrations_last_month = EventRegistration.objects.all().filter(user_id=user.id, registrations_last_month = EventRegistration.objects.all().filter(user_id=user.id,
event__date__gt=date.today() - timedelta(days=30), event__date__gt=date.today() - timedelta(days=30),
event__date__lte=date.today(), event__date__lte=date.today(),
state__exact='A') state=EventRegistration.ADMITTED)
score = 0 score = 0
for r in registrations_last_month: for r in registrations_last_month:
days_ago = (date.today() - r.event.date.date()).days days_ago = (date.today() - r.event.date.date()).days
@ -35,7 +35,7 @@ def assign_reservations(self):
# Reservations # Reservations
registrations: List[EventRegistration] = EventRegistration.objects.all().filter( registrations: List[EventRegistration] = EventRegistration.objects.all().filter(
event_id__in=map(lambda event: event.id, events), event_id__in=map(lambda event: event.id, events),
state__exact='I') state=EventRegistration.INTERESTED)
if len(registrations) == 0: if len(registrations) == 0:
print("NO REGISTRATIONS?") print("NO REGISTRATIONS?")