Add select able event backgrounds
This commit is contained in:
parent
f0e512de6b
commit
ab71d062cf
@ -1,7 +1,8 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
# Register your models here.
|
# 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)
|
@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)
|
@admin.register(Setting)
|
||||||
class SettingAdmin(admin.ModelAdmin):
|
class SettingAdmin(admin.ModelAdmin):
|
||||||
list_display = ("name", "active")
|
list_display = ("name", "active")
|
||||||
|
@ -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'),
|
||||||
|
),
|
||||||
|
]
|
@ -38,11 +38,20 @@ class ClubhausEvent(models.Model):
|
|||||||
location = models.TextField(blank=True)
|
location = models.TextField(blank=True)
|
||||||
beverages = models.TextField(blank=True)
|
beverages = models.TextField(blank=True)
|
||||||
food = 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):
|
def __str__(self):
|
||||||
return f"{self.name}"
|
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):
|
class EventDateVote(models.Model):
|
||||||
voter = models.ForeignKey(to="VotingUser", on_delete=models.CASCADE)
|
voter = models.ForeignKey(to="VotingUser", on_delete=models.CASCADE)
|
||||||
date = models.ForeignKey(to="EventDate", to_field="date", on_delete=models.CASCADE)
|
date = models.ForeignKey(to="EventDate", to_field="date", on_delete=models.CASCADE)
|
||||||
|
@ -5,7 +5,11 @@
|
|||||||
{% block extra_header_block %}
|
{% block extra_header_block %}
|
||||||
<style>
|
<style>
|
||||||
.cus-bg-image {
|
.cus-bg-image {
|
||||||
|
{% if next_event.background_picture %}
|
||||||
|
background-image: url("{% get_media_prefix %}{{ next_event.background_picture.picture }}");
|
||||||
|
{% else %}
|
||||||
background-image: url("{% static 'homepage/img/background.jpg' %}");
|
background-image: url("{% static 'homepage/img/background.jpg' %}");
|
||||||
|
{% endif %}
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
|
Loading…
Reference in New Issue
Block a user