many gpws

main
yaemiku 2023-01-18 23:20:12 +01:00
parent 5e8f6c39d4
commit f192df7909
Signed by: podlaskizbs
GPG Key ID: ADC039636B3E4AAB
12 changed files with 130 additions and 14 deletions

View File

@ -16,7 +16,7 @@ def load_config(request):
return { return {
'nav': Button.objects.filter(published=True), 'nav': Button.objects.filter(published=True),
'uppernav': UpperButton.objects.filter(published=True), 'uppernav': UpperButton.objects.filter(published=True),
'gpw': GrandPrixW.load(), 'gpw': GrandPrixW.get_current(),
'posts': Post.objects.filter(published=True), 'posts': Post.objects.filter(published=True),
'daneadresowe': Data.load(), 'daneadresowe': Data.load(),
'czlonkowie': Member.objects.all(), 'czlonkowie': Member.objects.all(),

View File

@ -25,7 +25,7 @@ class Button(OrderableModel):
if h == reverse_lazy('calendar'): if h == reverse_lazy('calendar'):
c = Calendar.get_current() c = Calendar.get_current()
elif h in reverse_lazy('membership'): elif h in reverse_lazy('membership') and h != '/':
c = Membership.get_current() c = Membership.get_current()
return h + (('#' + str(c.year)) if c is not None else '') return h + (('#' + str(c.year)) if c is not None else '')

View File

@ -0,0 +1,17 @@
{% extends 'base.html' %}
<!---->
{% block title %}Grand Prix Białegostoku | pdlzbs{% endblock %}
<!---->
{% load static tailwind_tags wysiwyg %} {% block content %}
<div class="flex flex-col gap-8 justify-center lg:flex-row">
<article class="p-8 bg-white rounded-md shadow-md prose">
{% if focus.show_title %}
<h1 class="font-medium text-center">{{ focus.title }}</h1>
{% endif %}
<div>{% content focus %}</div>
<div class="flex flex-wrap gap-4 justify-center items-center">
{% buttons focus.buttons %}
</div>
</article>
</div>
{% endblock %}

View File

@ -5,7 +5,7 @@
{% load static tailwind_tags wysiwyg %} {% block content %} {% load static tailwind_tags wysiwyg %} {% block content %}
<article class="w-full"> <article class="w-full">
{% content gpb %} {% content gpb %}
<div class="flex flex-wrap gap-4 items-center justify-center"> <div class="flex flex-wrap gap-4 justify-center items-center">
{% buttons gpb.buttons %} {% buttons gpb.buttons %}
</div> </div>
</article> </article>

View File

@ -1,27 +1,27 @@
{% extends 'base.html' %} {% block title %}Strona główna | pdlzbs{% endblock %} {% extends 'base.html' %} {% block title %}Strona główna | pdlzbs{% endblock %}
{% load static tailwind_tags wysiwyg %} {% block content %} {% load static tailwind_tags wysiwyg %} {% block content %}
<div class="flex flex-col lg:flex-row justify-center gap-8"> <div class="flex flex-col gap-8 justify-center lg:flex-row">
<article <article
class="basis-1/2 prose max-w-screen-sm mb-auto bg-white shadow-md rounded-md p-4" class="p-4 mb-auto max-w-screen-sm bg-white rounded-md shadow-md basis-1/2 prose"
> >
{% content gpw %} {% content gpw %}
</article> </article>
<div class="basis-1/2 flex flex-col items-center gap-4"> <div class="flex flex-col gap-4 items-center basis-1/2">
<h1 <h1
class="text-[2.25rem] font-medium w-full text-center bg-white shadow-md rounded-md px-4 py-2" class="text-[2.25rem] font-medium w-full text-center bg-white shadow-md rounded-md px-4 py-2"
> >
Aktualności PodlZBS Aktualności PodlZBS
</h1> </h1>
<hr class="w-36 border-b border-stone-300 border-dashed" /> <hr class="w-36 border-b border-dashed border-stone-300" />
{% for post in posts %} {% for post in posts %}
<article <article
class="prose max-w-full w-full py-4 bg-white shadow-md rounded-md p-4" class="p-4 py-4 w-full max-w-full bg-white rounded-md shadow-md prose"
> >
{% if post.show_title %} {% if post.show_title %}
<h2 class="font-medium">{{ post.title }}</h2> <h2 class="font-medium">{{ post.title }}</h2>
{% endif %} {% endif %}
<div>{% readmore post %}</div> <div>{% readmore post %}</div>
<div class="flex flex-wrap gap-4 items-center justify-center"> <div class="flex flex-wrap gap-4 justify-center items-center">
{% buttons post.buttons %} {% buttons post.buttons %}
</div> </div>
</article> </article>

View File

@ -23,7 +23,7 @@ def readmore(context, value: str):
cntnt = res[0] cntnt = res[0]
if len(res) > 1: if len(res) > 1:
cntnt += '<br /><br /><p class="text-center">...</p>' cntnt += '<br /><br /><p class="text-center">...</p>'
cntnt += f'<a href="{reverse_view_url}" style="float: right;" class="button mt-4">Czytaj dalej</a>' cntnt += f'<a href="{reverse_view_url}" style="float: right;" class="mt-4 button">Czytaj dalej</a>'
cntnt += '<hr class="not-prose" style="border-color: white; margin: 3rem 0;" />' cntnt += '<hr class="not-prose" style="border-color: white; margin: 3rem 0;" />'
return mark_safe(tableoverflow(cntnt)) return mark_safe(tableoverflow(cntnt))

View File

@ -1,12 +1,13 @@
from django.urls import path from django.urls import path
from .views import rtpath, tpath 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.tournaments.models import Tournament
from db.youth.models import Youth from db.youth.models import Youth
urlpatterns = [ urlpatterns = [
tpath('', 'home', {'home': 'active'}), tpath('', 'home', {'home': 'active'}),
rtpath('grandprixwojewodztwa/<int:id>', 'gpw', GrandPrixW),
rtpath('aktualnosci/<int:id>', 'home', Post, {'home': 'active'}), rtpath('aktualnosci/<int:id>', 'home', Post, {'home': 'active'}),
tpath('zarzad', 'administration'), tpath('zarzad', 'administration'),

View File

@ -13,7 +13,7 @@ def template(filename, ec={}):
def reverse_template(filename, model, ec={}): def reverse_template(filename, model, ec={}):
def closure(request, id): 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 return closure

View File

@ -11,3 +11,8 @@ class PostModelAdmin(OrderableAdmin, admin.ModelAdmin):
list_editable = ['ordering'] list_editable = ['ordering']
ordering_field_hide_input = True ordering_field_hide_input = True
exclude = ['ordering'] exclude = ['ordering']
@admin.register(GrandPrixW)
class GrandPrixWAdmin(admin.ModelAdmin):
list_display = ('__str__', 'link', 'published', 'current')

View File

@ -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'),
),
]

View File

@ -54,14 +54,32 @@ class Post(OrderableModel):
verbose_name_plural = 'Aktualności PodlZBS' 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) content = HTMLField('Tekst GPW', default='', blank=True)
buttons = models.TextField( buttons = models.TextField(
'Przyciski', default='', blank=True, help_text=buttons_help_text) '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): 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'<a href="{href}" target="_blank">{href}</a>')
class Meta: class Meta:
verbose_name = 'Grand Prix Województwa' verbose_name = 'Grand Prix Województwa'
verbose_name_plural = 'Grand Prix Województwa' verbose_name_plural = 'Grand Prix Województwa'
ordering = ['-year']

View File

@ -1081,6 +1081,22 @@ select {
margin-bottom: 0; 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 { .button {
display: inline-block; display: inline-block;
border-radius: 0.375rem; border-radius: 0.375rem;
@ -1295,6 +1311,10 @@ select {
margin: 1rem; margin: 1rem;
} }
.m-0 {
margin: 0px;
}
.mx-auto { .mx-auto {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
@ -1310,6 +1330,21 @@ select {
margin-bottom: 0.5rem; 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 { .mb-2 {
margin-bottom: 0.5rem; margin-bottom: 0.5rem;
} }
@ -1334,6 +1369,10 @@ select {
margin-bottom: auto; margin-bottom: auto;
} }
.ml-2 {
margin-left: 0.5rem;
}
.block { .block {
display: block; display: block;
} }
@ -1366,6 +1405,10 @@ select {
display: none; display: none;
} }
.h-auto {
height: auto;
}
.h-screen { .h-screen {
height: 100vh; height: 100vh;
} }