diff --git a/events/admin.py b/events/admin.py index 8c38f3f..a1d2300 100644 --- a/events/admin.py +++ b/events/admin.py @@ -1,3 +1,6 @@ from django.contrib import admin -# Register your models here. +from .models import Event, EventRegistration + +admin.site.register(Event) +admin.site.register(EventRegistration) diff --git a/events/migrations/0001_initial.py b/events/migrations/0001_initial.py index f50a5f5..af3db1d 100644 --- a/events/migrations/0001_initial.py +++ b/events/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.0.8 on 2020-07-21 21:36 +# Generated by Django 3.0.8 on 2020-07-22 01:36 from django.conf import settings from django.db import migrations, models @@ -18,7 +18,8 @@ class Migration(migrations.Migration): name='Event', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('date', models.DateTimeField()), + ('date', models.DateField()), + ('time', models.IntegerField(choices=[(0, 'Voormiddag'), (1, 'Namiddag'), (2, 'Avond')])), ('capacity', models.IntegerField()), ], ), @@ -26,7 +27,7 @@ class Migration(migrations.Migration): name='EventRegistration', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('shirt_size', models.CharField(choices=[('I', 'Interested'), ('A', 'Admitted'), ('D', 'Denied')], max_length=1)), + ('state', models.CharField(choices=[('I', 'Interested'), ('A', 'Admitted'), ('D', 'Denied')], max_length=1)), ('event_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='events.Event')), ('user_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], diff --git a/events/models.py b/events/models.py index b030d7f..f5c353a 100644 --- a/events/models.py +++ b/events/models.py @@ -4,16 +4,32 @@ from users.models import CustomUser class Event(models.Model): - date = models.DateTimeField() - capacity = models.IntegerField() + MORNING, AFTERNOON, EVENING = range(3) + TIME_SLOTS = { + MORNING: "Voormiddag", + AFTERNOON: "Namiddag", + EVENING: "Avond", + } + date = models.DateField() + time = models.IntegerField(choices=TIME_SLOTS.items(), default=MORNING) + capacity = models.IntegerField(default=6) + + def __str__(self): + return f"{self.date} {self.TIME_SLOTS[self.time]}" class EventRegistration(models.Model): + INTERESTED = "I" + ADMITTED = "A" + DENIED = "D" REGISTRATION_STATE = ( - ('I', 'Interested'), - ('A', 'Admitted'), - ('D', 'Denied'), + (INTERESTED, "Interested"), + (ADMITTED, "Admitted"), + (DENIED, "Denied"), ) event_id = models.ForeignKey(Event, on_delete=models.CASCADE) user_id = models.ForeignKey(CustomUser, on_delete=models.CASCADE) state = models.CharField(max_length=1, choices=REGISTRATION_STATE) + + def __str__(self): + return f"[{self.state}] {self.user.username}" diff --git a/events/templates/events/detail.html b/events/templates/events/detail.html new file mode 100644 index 0000000..1a144a8 --- /dev/null +++ b/events/templates/events/detail.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} + +{% block content %} +