1
0

Include teaser in index page

This commit is contained in:
Marcel Schwarz 2022-09-04 00:37:02 +02:00
parent 6a2cb505b9
commit 534c6a32bd
12 changed files with 154 additions and 66 deletions

View File

@ -1,7 +1,7 @@
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, EventDateVotes, VotingUser from .models import Tobacco, TobaccoCategory, ClubhausEvent, EventDate, EventDateVote, VotingUser, Setting
@admin.register(Tobacco) @admin.register(Tobacco)
@ -29,7 +29,7 @@ class VotingUserAdmin(admin.ModelAdmin):
ordering = ("id",) ordering = ("id",)
@admin.register(EventDateVotes) @admin.register(EventDateVote)
class EventDateVotesAdmin(admin.ModelAdmin): class EventDateVotesAdmin(admin.ModelAdmin):
list_display = ("id", "voter", "date", "available") list_display = ("id", "voter", "date", "available")
list_editable = ('available',) list_editable = ('available',)
@ -49,3 +49,10 @@ class ClubhausEventAdmin(admin.ModelAdmin):
inlines = [ inlines = [
EventDateInline EventDateInline
] ]
@admin.register(Setting)
class SettingAdmin(admin.ModelAdmin):
list_display = ("name", "active")
ordering = ("active", "id")
list_editable = ("active",)

View File

@ -0,0 +1,17 @@
# Generated by Django 4.0.5 on 2022-09-03 15:21
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('homepage', '0019_clubhausevent_voting_locked_alter_tobacco_in_stock'),
]
operations = [
migrations.RenameModel(
old_name='EventDateVotes',
new_name='EventDateVote',
),
]

View File

@ -0,0 +1,22 @@
# Generated by Django 4.0.5 on 2022-09-03 15:37
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0020_rename_eventdatevotes_eventdatevote'),
]
operations = [
migrations.CreateModel(
name='Setting',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('active', models.BooleanField(default=True)),
('intro_text', models.TextField(blank=True)),
('intro_text_classes', models.CharField(blank=True, default='text-center fs-5', help_text='Extra CSS classes for the div for the intro text like text size', max_length=500)),
],
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 4.0.5 on 2022-09-03 15:42
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0021_setting'),
]
operations = [
migrations.AddField(
model_name='setting',
name='name',
field=models.CharField(default='Default Settings', max_length=200),
),
]

View File

@ -0,0 +1,17 @@
# Generated by Django 4.0.5 on 2022-09-03 15:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0022_setting_name'),
]
operations = [
migrations.AddConstraint(
model_name='setting',
constraint=models.UniqueConstraint(fields=('name',), name='unique_name'),
),
]

View File

@ -43,7 +43,7 @@ class ClubhausEvent(models.Model):
return f"{self.name}" return f"{self.name}"
class EventDateVotes(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)
available = models.BooleanField() available = models.BooleanField()
@ -68,3 +68,19 @@ class VotingUser(models.Model):
def __str__(self): def __str__(self):
return f"{self.name} ({self.id})" return f"{self.name} ({self.id})"
class Setting(models.Model):
active = models.BooleanField(default=True)
name = models.CharField(max_length=200, default="Default Settings", blank=False)
intro_text = models.TextField(blank=True)
intro_text_classes = models.CharField(max_length=500, default="text-center fs-5", blank=True,
help_text="Extra CSS classes for the div for the intro text like text size")
class Meta:
constraints = [
models.UniqueConstraint(fields=("name",), name="unique_name")
]
def __str__(self):
return f"{self.id} - {self.name}"

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -39,8 +39,6 @@
<nav class="nav nav-masthead justify-content-center float-md-end"> <nav class="nav nav-masthead justify-content-center float-md-end">
<a class="nav-link fw-bold py-1 px-0 {% if request.path == '/' %}active{% endif %}" <a class="nav-link fw-bold py-1 px-0 {% if request.path == '/' %}active{% endif %}"
href="{% url 'index' %}">Home</a> href="{% url 'index' %}">Home</a>
<a class="nav-link fw-bold py-1 px-0 {% if 'teaser' in request.path %}active{% endif %}"
href="{% url 'teaser' %}">Teaser</a>
<a class="nav-link fw-bold py-1 px-0 {% if 'event' in request.path %}active{% endif %}" <a class="nav-link fw-bold py-1 px-0 {% if 'event' in request.path %}active{% endif %}"
href="{% url 'events' %}">Event</a> href="{% url 'events' %}">Event</a>
<a class="nav-link fw-bold py-1 px-0 {% if 'tobacco' in request.path %}active{% endif %}" <a class="nav-link fw-bold py-1 px-0 {% if 'tobacco' in request.path %}active{% endif %}"

View File

@ -8,12 +8,57 @@
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
background-size: contain; background-size: contain;
height: 200px;
}
.video {
width: 100%;
height: auto;
aspect-ratio: 16 / 9;
} }
</style> </style>
<link rel="stylesheet" href="{% static 'homepage/assets/plyr/plyr.3.7.2.css' %}"/>
{% endblock %}
{% block extra_scripts_block %}
<script src="{% static 'homepage/assets/plyr/plyr.polyfilled.3.7.2.js' %}"></script>
<script>
const player = new Plyr('#trailerVideo', {
title: "Teaser 2022",
settings: ['quality']
});
</script>
{% endblock %} {% endblock %}
{% block main %} {% block main %}
<main class="d-flex flex-column h-100 mx-5"> <div class="mx-5">
<div class="d-flex row flex-grow-1 w-100 mt-5 mb-4 mx-auto bg-logo" style="max-width: 42rem"></div> <main class="d-flex flex-column h-100 mx-auto text-white" style="max-width: 52rem">
</main> <div class="row w-100 mt-5 mb-4 mx-auto bg-logo"></div>
<div class="row {{ settings.intro_text_classes }}">
{{ settings.intro_text | linebreaksbr }}
</div>
<div class="my-5">
<video id="trailerVideo" class="video"
controls
preload="none"
poster="{% static 'homepage/vid/teaser-2022/thumb.jpg' %}">
<source
src="{% static 'homepage/vid/teaser-2022/teaser-480p.mp4' %}"
type="video/mp4"
size="480"
/>
<source
src="{% static 'homepage/vid/teaser-2022/teaser-720p.mp4' %}"
type="video/mp4"
size="720"
/>
<source
src="{% static 'homepage/vid/teaser-2022/teaser-1080p.mp4' %}"
type="video/mp4"
size="1080"
/>
</video>
</div>
</main>
</div>
{% endblock %} {% endblock %}

View File

@ -1,49 +0,0 @@
{% extends 'homepage/base.html' %}
{% load static %}
{% block extra_header_block %}
<style>
video {
width: 100%;
height: auto;
aspect-ratio: 16 / 9;
}
</style>
<link rel="stylesheet" href="{% static 'homepage/assets/plyr/plyr.3.7.2.css' %}"/>
{% endblock %}
{% block extra_scripts_block %}
<script src="{% static 'homepage/assets/plyr/plyr.polyfilled.3.7.2.js' %}"></script>
<script>
const player = new Plyr('#trailerVideo', {
title: "Teaser 2022",
settings: ['quality']
});
</script>
{% endblock %}
{% block main %}
<main class="container d-flex flex-column flex-grow-1 text-white mt-5" style="max-width: 52rem">
<h1 class="fst-italic mx-auto">Teaser 2022</h1>
<video id="trailerVideo" class="mx-auto"
controls
preload="none"
poster="{% static 'homepage/vid/teaser-2022/thumb.jpg' %}">
<source
src="{% static 'homepage/vid/teaser-2022/teaser-480p.mp4' %}"
type="video/mp4"
size="480"
/>
<source
src="{% static 'homepage/vid/teaser-2022/teaser-720p.mp4' %}"
type="video/mp4"
size="720"
/>
<source
src="{% static 'homepage/vid/teaser-2022/teaser-1080p.mp4' %}"
type="video/mp4"
size="1080"
/>
</video>
</main>
{% endblock %}

View File

@ -7,7 +7,6 @@ urlpatterns = [
path('event', views.events, name='events'), path('event', views.events, name='events'),
path('tobacco', views.tobacco, name='tobacco'), path('tobacco', views.tobacco, name='tobacco'),
path('voting', views.voting, name='voting'), path('voting', views.voting, name='voting'),
path('teaser', views.teaser, name='teaser'),
path('law/impressum', views.impressum, name='impressum'), path('law/impressum', views.impressum, name='impressum'),
path('law/cookies-policy', views.cookies, name='cookies'), path('law/cookies-policy', views.cookies, name='cookies'),
] ]

View File

@ -6,7 +6,7 @@ from django.urls import reverse
import clubhaus.settings as django_settings import clubhaus.settings as django_settings
from .exceptions import RateLimitHit, ProxyUsageDetected from .exceptions import RateLimitHit, ProxyUsageDetected
from .models import Tobacco, ClubhausEvent, EventDate, EventDateVotes, VotingUser from .models import Tobacco, ClubhausEvent, EventDate, EventDateVote, VotingUser, Setting
def bad_request(request, exception, template_name="homepage/400.html"): def bad_request(request, exception, template_name="homepage/400.html"):
@ -14,7 +14,8 @@ def bad_request(request, exception, template_name="homepage/400.html"):
def index(request: HttpRequest) -> django.http.HttpResponse: def index(request: HttpRequest) -> django.http.HttpResponse:
return render(request, 'homepage/index.html', {}) settings = Setting.objects.filter(active=True).first()
return render(request, 'homepage/index.html', {'settings': settings})
def impressum(request: HttpRequest) -> django.http.HttpResponse: def impressum(request: HttpRequest) -> django.http.HttpResponse:
@ -30,16 +31,12 @@ def tobacco(request: HttpRequest) -> django.http.HttpResponse:
return render(request, 'homepage/tobacco.html', context) return render(request, 'homepage/tobacco.html', context)
def teaser(request: HttpRequest) -> django.http.HttpResponse:
return render(request, 'homepage/teaser.html')
def events(request: HttpRequest) -> django.http.HttpResponse: def events(request: HttpRequest) -> django.http.HttpResponse:
next_events = ClubhausEvent.objects.filter(active=True).order_by('-id') next_events = ClubhausEvent.objects.filter(active=True).order_by('-id')
if len(next_events) == 1: if len(next_events) == 1:
next_event = next_events[0] next_event = next_events[0]
dates = EventDate.objects.filter(event=next_event).order_by("date") dates = EventDate.objects.filter(event=next_event).order_by("date")
votes = EventDateVotes.objects.filter(date__event=next_event).order_by("voter_id", "date") votes = EventDateVote.objects.filter(date__event=next_event).order_by("voter_id", "date")
unique_voters = list(set(map(lambda v: v.voter, votes))) unique_voters = list(set(map(lambda v: v.voter, votes)))
vote_map = {} vote_map = {}
@ -99,6 +96,6 @@ def voting(request: HttpRequest) -> django.http.HttpResponse:
for date in event_dates: for date in event_dates:
available = date.date.isoformat() in request.POST available = date.date.isoformat() in request.POST
EventDateVotes.objects.update_or_create(voter=user, date=date, defaults={"available": available}) EventDateVote.objects.update_or_create(voter=user, date=date, defaults={"available": available})
return HttpResponseRedirect(reverse("events")) return HttpResponseRedirect(reverse("events"))