diff --git a/core/context_processors.py b/core/context_processors.py index 5b65ffc..0ab315a 100644 --- a/core/context_processors.py +++ b/core/context_processors.py @@ -16,7 +16,7 @@ def load_config(request): return { 'nav': Button.objects.filter(published=True), 'uppernav': UpperButton.objects.filter(published=True), - 'gpw': GrandPrixW.load(), + 'gpw': GrandPrixW.get_current(), 'posts': Post.objects.filter(published=True), 'daneadresowe': Data.load(), 'czlonkowie': Member.objects.all(), diff --git a/core/models.py b/core/models.py index afb2209..f23ec8a 100644 --- a/core/models.py +++ b/core/models.py @@ -25,7 +25,7 @@ class Button(OrderableModel): if h == reverse_lazy('calendar'): c = Calendar.get_current() - elif h in reverse_lazy('membership'): + elif h in reverse_lazy('membership') and h != '/': c = Membership.get_current() return h + (('#' + str(c.year)) if c is not None else '') diff --git a/core/templates/gpw-reverse.html b/core/templates/gpw-reverse.html new file mode 100644 index 0000000..c0e285a --- /dev/null +++ b/core/templates/gpw-reverse.html @@ -0,0 +1,17 @@ +{% extends 'base.html' %} + +{% block title %}Grand Prix Białegostoku | pdlzbs{% endblock %} + +{% load static tailwind_tags wysiwyg %} {% block content %} +
+
+ {% if focus.show_title %} +

{{ focus.title }}

+ {% endif %} +
{% content focus %}
+
+ {% buttons focus.buttons %} +
+
+
+{% endblock %} diff --git a/core/templates/grandprix.html b/core/templates/grandprix.html index 660f7a5..763365b 100644 --- a/core/templates/grandprix.html +++ b/core/templates/grandprix.html @@ -5,7 +5,7 @@ {% load static tailwind_tags wysiwyg %} {% block content %}
{% content gpb %} -
+
{% buttons gpb.buttons %}
diff --git a/core/templates/home.html b/core/templates/home.html index 4647e90..079748b 100644 --- a/core/templates/home.html +++ b/core/templates/home.html @@ -1,27 +1,27 @@ {% extends 'base.html' %} {% block title %}Strona główna | pdlzbs{% endblock %} {% load static tailwind_tags wysiwyg %} {% block content %} -
+
{% content gpw %}
-
+

Aktualności PodlZBS

-
+
{% for post in posts %}
{% if post.show_title %}

{{ post.title }}

{% endif %}
{% readmore post %}
-
+
{% buttons post.buttons %}
diff --git a/core/templatetags/wysiwyg.py b/core/templatetags/wysiwyg.py index 90137d9..79d40fb 100644 --- a/core/templatetags/wysiwyg.py +++ b/core/templatetags/wysiwyg.py @@ -23,7 +23,7 @@ def readmore(context, value: str): cntnt = res[0] if len(res) > 1: cntnt += '

...

' - cntnt += f'Czytaj dalej' + cntnt += f'Czytaj dalej' cntnt += '
' return mark_safe(tableoverflow(cntnt)) diff --git a/core/urls.py b/core/urls.py index b518eb2..6f01c4c 100644 --- a/core/urls.py +++ b/core/urls.py @@ -1,12 +1,13 @@ from django.urls import path from .views import rtpath, tpath -from db.main.models import Post +from db.main.models import Post, GrandPrixW from db.tournaments.models import Tournament from db.youth.models import Youth urlpatterns = [ tpath('', 'home', {'home': 'active'}), + rtpath('grandprixwojewodztwa/', 'gpw', GrandPrixW), rtpath('aktualnosci/', 'home', Post, {'home': 'active'}), tpath('zarzad', 'administration'), diff --git a/core/views.py b/core/views.py index 56e36b7..1c20a50 100644 --- a/core/views.py +++ b/core/views.py @@ -13,7 +13,7 @@ def template(filename, ec={}): def reverse_template(filename, model, ec={}): def closure(request, id): - return render(request, filename+'-reverse.html', {**ec, 'focus': model.objects.get(id=id)}) + return render(request, filename+'-reverse.html', {**ec, 'focus': model.objects.get(pk=id)}) return closure diff --git a/db/main/admin.py b/db/main/admin.py index 0bf09a4..8f4028f 100644 --- a/db/main/admin.py +++ b/db/main/admin.py @@ -11,3 +11,8 @@ class PostModelAdmin(OrderableAdmin, admin.ModelAdmin): list_editable = ['ordering'] ordering_field_hide_input = True exclude = ['ordering'] + + +@admin.register(GrandPrixW) +class GrandPrixWAdmin(admin.ModelAdmin): + list_display = ('__str__', 'link', 'published', 'current') diff --git a/db/main/migrations/0007_remove_grandprixw_id_grandprixw_current_and_more.py b/db/main/migrations/0007_remove_grandprixw_id_grandprixw_current_and_more.py new file mode 100644 index 0000000..a747f9a --- /dev/null +++ b/db/main/migrations/0007_remove_grandprixw_id_grandprixw_current_and_more.py @@ -0,0 +1,32 @@ +# Generated by Django 4.0.5 on 2023-01-18 21:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('main', '0006_grandprixw_buttons_post_buttons'), + ] + + operations = [ + migrations.RemoveField( + model_name='grandprixw', + name='id', + ), + migrations.AddField( + model_name='grandprixw', + name='current', + field=models.BooleanField(default=False, verbose_name='Aktualne GP (pokazywane na stronie głównej)'), + ), + migrations.AddField( + model_name='grandprixw', + name='published', + field=models.BooleanField(default=True, verbose_name='Grand Prix opublikowane'), + ), + migrations.AddField( + model_name='grandprixw', + name='year', + field=models.IntegerField(default=1, primary_key=True, serialize=False, verbose_name='Rok'), + ), + ] diff --git a/db/main/models.py b/db/main/models.py index aec68b2..82e8b26 100644 --- a/db/main/models.py +++ b/db/main/models.py @@ -54,14 +54,32 @@ class Post(OrderableModel): verbose_name_plural = 'Aktualności PodlZBS' -class GrandPrixW(SingletonModel): +class GrandPrixW(models.Model): + published = models.BooleanField('Grand Prix opublikowane', default=True) + year = models.IntegerField('Rok', primary_key=True, default=1) content = HTMLField('Tekst GPW', default='', blank=True) buttons = models.TextField( 'Przyciski', default='', blank=True, help_text=buttons_help_text) + current = models.BooleanField( + 'Aktualne GP (pokazywane na stronie głównej)', default=False) + + @staticmethod + def get_current(): + return GrandPrixW.objects.filter(current=True, published=True).first() + + def update(self, *args, **kwargs): + if self.current is True: + GrandPrixW.objects.exclude(year=self.year).update(current=False) def __str__(self): - return 'Grand Prix Województwa' + return f'Grand Prix Województwa {self.year}' + + @property + def link(self): + href = reverse_lazy('gpw-reverse', args=[self.year]) + return mark_safe(f'{href}') class Meta: verbose_name = 'Grand Prix Województwa' verbose_name_plural = 'Grand Prix Województwa' + ordering = ['-year'] diff --git a/theme/static/css/dist/styles.css b/theme/static/css/dist/styles.css index 2cb48a7..ff80b20 100644 --- a/theme/static/css/dist/styles.css +++ b/theme/static/css/dist/styles.css @@ -1081,6 +1081,22 @@ select { margin-bottom: 0; } +.btn { + display: inline-block; + border-radius: 0.375rem; + border-width: 1px; + -webkit-text-decoration-line: none; + text-decoration-line: none; + --tw-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); + --tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color); + box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); + transition-property: color, background-color, border-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-text-decoration-color, -webkit-backdrop-filter; + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter; + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-text-decoration-color, -webkit-backdrop-filter; + transition-duration: 300ms; + transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); +} + .button { display: inline-block; border-radius: 0.375rem; @@ -1295,6 +1311,10 @@ select { margin: 1rem; } +.m-0 { + margin: 0px; +} + .mx-auto { margin-left: auto; margin-right: auto; @@ -1310,6 +1330,21 @@ select { margin-bottom: 0.5rem; } +.my-5 { + margin-top: 1.25rem; + margin-bottom: 1.25rem; +} + +.my-3 { + margin-top: 0.75rem; + margin-bottom: 0.75rem; +} + +.my-6 { + margin-top: 1.5rem; + margin-bottom: 1.5rem; +} + .mb-2 { margin-bottom: 0.5rem; } @@ -1334,6 +1369,10 @@ select { margin-bottom: auto; } +.ml-2 { + margin-left: 0.5rem; +} + .block { display: block; } @@ -1366,6 +1405,10 @@ select { display: none; } +.h-auto { + height: auto; +} + .h-screen { height: 100vh; }