diff --git a/events/migrations/0003_eventregistration_accepted.py b/events/migrations/0003_eventregistration_accepted.py new file mode 100644 index 0000000..3bf5856 --- /dev/null +++ b/events/migrations/0003_eventregistration_accepted.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.8 on 2021-04-21 14:36 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('events', '0002_auto_20210418_2026'), + ] + + operations = [ + migrations.AddField( + model_name='eventregistration', + name='accepted', + field=models.BooleanField(default=True), + ), + ] diff --git a/events/models.py b/events/models.py index 48507b5..1b61640 100644 --- a/events/models.py +++ b/events/models.py @@ -12,6 +12,9 @@ class Event(models.Model): def count_registrations(self): return self.eventregistration_set.count() + + def count_registrations_accepted(self): + return self.eventregistration_set.filter(accepted=True).count() def registration_of(self, user): if not user.is_authenticated: @@ -29,6 +32,9 @@ class Event(models.Model): class EventRegistration(TimeStampedModel): event = models.ForeignKey(Event, on_delete=models.CASCADE) user = models.ForeignKey(CustomUser, on_delete=models.CASCADE) + # A user is by default valid. + # The board can then check if a user has indeed been active in any way and they can invalidate the membership + accepted = models.BooleanField(default=True) class Meta: constraints = [ diff --git a/events/templates/events/registrations.html b/events/templates/events/registrations.html index b2d3e1d..3e61f27 100644 --- a/events/templates/events/registrations.html +++ b/events/templates/events/registrations.html @@ -4,8 +4,12 @@
{% endif %} {% csrf_token %} -

{{ event.count_registrations }} - registratie{% if event.count_registrations != 1 %}s{%endif%}

+ {% if user.is_staff %} +
+

{{ event.count_registrations }} registratie{% if event.count_registrations != 1 %}s{%endif%}

+

{{ event.count_registrations_accepted }} geaccepteerde registratie{% if event.count_registrations_accepted != 1 %}s{%endif%}

+
+ {% endif %} {% if not user.is_authenticated %}

Je moet inloggen voor je je kan inschrijven.