diff --git a/events/migrations/0001_initial.py b/events/migrations/0001_initial.py index a9dac90..37689ff 100644 --- a/events/migrations/0001_initial.py +++ b/events/migrations/0001_initial.py @@ -1,6 +1,5 @@ -# Generated by Django 3.0.8 on 2020-07-22 13:42 +# Generated by Django 3.0.8 on 2020-07-22 16:03 -from django.conf import settings from django.db import migrations, models import django.db.models.deletion @@ -10,7 +9,6 @@ class Migration(migrations.Migration): initial = True dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ @@ -19,7 +17,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('date', models.DateField()), - ('time', models.IntegerField(choices=[(0, 'Voormiddag'), (1, 'Namiddag'), (2, 'Avond')], default=0)), + ('time', models.IntegerField(choices=[(0, 'voormiddag'), (1, 'namiddag'), (2, 'avond')], default=0)), ('capacity', models.IntegerField(default=6)), ], ), @@ -27,13 +25,8 @@ class Migration(migrations.Migration): name='EventRegistration', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('state', models.CharField(choices=[('I', 'Interested'), ('A', 'Admitted')], max_length=1)), + ('state', models.CharField(choices=[('I', 'op wachtlijst'), ('A', 'bevestigd')], max_length=1)), ('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='events.Event')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], ), - migrations.AddConstraint( - model_name='eventregistration', - constraint=models.UniqueConstraint(fields=('event', 'user'), name='user can only register once per event'), - ), ] diff --git a/events/migrations/0002_auto_20200722_1803.py b/events/migrations/0002_auto_20200722_1803.py new file mode 100644 index 0000000..ec96b19 --- /dev/null +++ b/events/migrations/0002_auto_20200722_1803.py @@ -0,0 +1,27 @@ +# Generated by Django 3.0.8 on 2020-07-22 16:03 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('events', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='eventregistration', + name='user', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + migrations.AddConstraint( + model_name='eventregistration', + constraint=models.UniqueConstraint(fields=('event', 'user'), name='register_only_once'), + ), + ] diff --git a/events/models.py b/events/models.py index f3d5722..000c483 100644 --- a/events/models.py +++ b/events/models.py @@ -1,4 +1,5 @@ from django.db import models +from django.db.models import Q from users.models import CustomUser @@ -61,8 +62,8 @@ class EventRegistration(models.Model): class Meta: constraints = [ models.UniqueConstraint( - fields=["event", "user"], name="user can only register once per event" - ) + fields=["event", "user"], name="register_only_once" + ), ] diff --git a/events/templates/events/index.html b/events/templates/events/index.html index 89e30df..8e569bc 100644 --- a/events/templates/events/index.html +++ b/events/templates/events/index.html @@ -3,6 +3,9 @@ {% block title %}Events{% endblock %} {% block content %} +

Events

+ +{% if events %} +{% else %} +

Geen events binnenkort

+{% endif %} {% endblock %} diff --git a/events/templates/events/registrations.html b/events/templates/events/registrations.html index 1b45df8..9fce07f 100644 --- a/events/templates/events/registrations.html +++ b/events/templates/events/registrations.html @@ -6,13 +6,13 @@

{{ event.count_interested }} in wachtlijst

{% endif %} - {% if user.is_authenticated %} - {% if not my_registration %} -

- {% else %} -

Mijn status: {{ my_registration.state_str }}

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

Je moet inloggen voor je je kan inschrijven.

+ {% elif not user.has_ugent_info %} +

Je moet je studentennummer en echte naam invullen in je profiel voor je je kan inschrijven.

+ {% elif not my_registration %} +

{% else %} -

Je moet inloggen voor je je kan inschrijven

+

Mijn status: {{ my_registration.state_str }}

{% endif %} diff --git a/events/views.py b/events/views.py index b2dcc6a..a6cd689 100644 --- a/events/views.py +++ b/events/views.py @@ -28,6 +28,9 @@ def view_score_stuff(request): def register(request, event_id): if request.method == "POST": + if not request.user.has_ugent_info: + raise ValueError("User has missing UGent info missing") + event = get_object_or_404(Event, id=event_id) event.eventregistration_set.create( diff --git a/static/main.css b/static/main.css index 9043f1e..53d2297 100644 --- a/static/main.css +++ b/static/main.css @@ -48,14 +48,10 @@ nav a { font-family: monospace; } -nav a:hover, nav a:focus, nav button:hover, nav buttton:focus { +nav a:hover, nav a:focus { background-color: rgba(255, 255, 255, 0.5); } -button { - display: none; -} - /*change the layout of the navigation bar for all the screens that have a width less or equal than 500px*/ @@ -68,17 +64,6 @@ that have a width less or equal than 500px*/ nav a { display: block; } - - button { - display: block; - - padding: 2vw; - font-size: 3vh; - background-color: #ff8000; - border: none; - - cursor: pointer; - } } @media only screen and (min-width: 750px) { diff --git a/templates/base.html b/templates/base.html index a3c8fd5..43b03fb 100644 --- a/templates/base.html +++ b/templates/base.html @@ -14,7 +14,6 @@

Zeus WPI Kelder­registratie­systeem™