diff --git a/clubhaus/homepage/admin.py b/clubhaus/homepage/admin.py index e0b01a3..f3756b3 100644 --- a/clubhaus/homepage/admin.py +++ b/clubhaus/homepage/admin.py @@ -1,7 +1,8 @@ from django.contrib import admin # Register your models here. -from .models import Tobacco, TobaccoCategory, ClubhausEvent, EventDate, EventDateVote, VotingUser, Setting +from .models import Tobacco, TobaccoCategory, ClubhausEvent, EventDate, EventDateVote, VotingUser, Setting, \ + EventBackground @admin.register(Tobacco) @@ -51,6 +52,12 @@ class ClubhausEventAdmin(admin.ModelAdmin): ] +@admin.register(EventBackground) +class EventBackgroundAdmin(admin.ModelAdmin): + list_display = ("id", "name", "picture") + ordering = ("id",) + + @admin.register(Setting) class SettingAdmin(admin.ModelAdmin): list_display = ("name", "active") diff --git a/clubhaus/homepage/migrations/0024_eventbackground_clubhausevent_background_picture.py b/clubhaus/homepage/migrations/0024_eventbackground_clubhausevent_background_picture.py new file mode 100644 index 0000000..67c8fa5 --- /dev/null +++ b/clubhaus/homepage/migrations/0024_eventbackground_clubhausevent_background_picture.py @@ -0,0 +1,27 @@ +# Generated by Django 4.2 on 2023-04-30 18:35 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('homepage', '0023_setting_unique_name'), + ] + + operations = [ + migrations.CreateModel( + name='EventBackground', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(blank=True, max_length=200)), + ('picture', models.ImageField(blank=True, upload_to='event_backgrounds/')), + ], + ), + migrations.AddField( + model_name='clubhausevent', + name='background_picture', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='homepage.eventbackground'), + ), + ] diff --git a/clubhaus/homepage/models.py b/clubhaus/homepage/models.py index ad44196..12842a5 100644 --- a/clubhaus/homepage/models.py +++ b/clubhaus/homepage/models.py @@ -38,11 +38,20 @@ class ClubhausEvent(models.Model): location = models.TextField(blank=True) beverages = models.TextField(blank=True) food = models.TextField(blank=True) + background_picture = models.ForeignKey(to="EventBackground", on_delete=models.DO_NOTHING, blank=True, null=True) def __str__(self): return f"{self.name}" +class EventBackground(models.Model): + name = models.CharField(max_length=200, blank=True) + picture = models.ImageField(upload_to="event_backgrounds/", null=False, blank=True, ) + + def __str__(self): + return f"{self.name} ({self.id})" + + class EventDateVote(models.Model): voter = models.ForeignKey(to="VotingUser", on_delete=models.CASCADE) date = models.ForeignKey(to="EventDate", to_field="date", on_delete=models.CASCADE) diff --git a/clubhaus/homepage/templates/homepage/events.html b/clubhaus/homepage/templates/homepage/events.html index 0e639d2..9529d6f 100644 --- a/clubhaus/homepage/templates/homepage/events.html +++ b/clubhaus/homepage/templates/homepage/events.html @@ -5,7 +5,11 @@ {% block extra_header_block %}