add registration acceptance, show count to staff only
This commit is contained in:
parent
4fe71f6561
commit
f295e97edc
3 changed files with 30 additions and 2 deletions
18
events/migrations/0003_eventregistration_accepted.py
Normal file
18
events/migrations/0003_eventregistration_accepted.py
Normal file
|
@ -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),
|
||||
),
|
||||
]
|
|
@ -13,6 +13,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:
|
||||
return None
|
||||
|
@ -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 = [
|
||||
|
|
|
@ -4,8 +4,12 @@
|
|||
<form action="{% url 'events:deregister' event.id %}" method="post">
|
||||
{% endif %}
|
||||
{% csrf_token %}
|
||||
<p style="margin-left: 2em;">{{ event.count_registrations }}
|
||||
registratie{% if event.count_registrations != 1 %}s{%endif%}</p>
|
||||
{% if user.is_staff %}
|
||||
<div style="margin-left: 2em;">
|
||||
<p>{{ event.count_registrations }} registratie{% if event.count_registrations != 1 %}s{%endif%}</p>
|
||||
<p>{{ event.count_registrations_accepted }} geaccepteerde registratie{% if event.count_registrations_accepted != 1 %}s{%endif%}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if not user.is_authenticated %}
|
||||
<p><i>Je moet inloggen voor je je kan inschrijven.</i></p>
|
||||
|
|
Loading…
Reference in a new issue