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),
|
||||||
|
),
|
||||||
|
]
|
|
@ -12,6 +12,9 @@ class Event(models.Model):
|
||||||
|
|
||||||
def count_registrations(self):
|
def count_registrations(self):
|
||||||
return self.eventregistration_set.count()
|
return self.eventregistration_set.count()
|
||||||
|
|
||||||
|
def count_registrations_accepted(self):
|
||||||
|
return self.eventregistration_set.filter(accepted=True).count()
|
||||||
|
|
||||||
def registration_of(self, user):
|
def registration_of(self, user):
|
||||||
if not user.is_authenticated:
|
if not user.is_authenticated:
|
||||||
|
@ -29,6 +32,9 @@ class Event(models.Model):
|
||||||
class EventRegistration(TimeStampedModel):
|
class EventRegistration(TimeStampedModel):
|
||||||
event = models.ForeignKey(Event, on_delete=models.CASCADE)
|
event = models.ForeignKey(Event, on_delete=models.CASCADE)
|
||||||
user = models.ForeignKey(CustomUser, 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:
|
class Meta:
|
||||||
constraints = [
|
constraints = [
|
||||||
|
|
|
@ -4,8 +4,12 @@
|
||||||
<form action="{% url 'events:deregister' event.id %}" method="post">
|
<form action="{% url 'events:deregister' event.id %}" method="post">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<p style="margin-left: 2em;">{{ event.count_registrations }}
|
{% if user.is_staff %}
|
||||||
registratie{% if event.count_registrations != 1 %}s{%endif%}</p>
|
<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 %}
|
{% if not user.is_authenticated %}
|
||||||
<p><i>Je moet inloggen voor je je kan inschrijven.</i></p>
|
<p><i>Je moet inloggen voor je je kan inschrijven.</i></p>
|
||||||
|
|
Loading…
Reference in a new issue