many gpws

main
yaemiku 2023-05-31 21:04:29 +02:00
parent de9a718bb0
commit aa65cb09a8
Signed by: podlaskizbs
GPG Key ID: ADC039636B3E4AAB
9 changed files with 119 additions and 26 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.get_current(), 'gpws': 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

@ -4,7 +4,7 @@
<!----> <!---->
{% load static tailwind_tags wysiwyg %} {% block content %} {% load static tailwind_tags wysiwyg %} {% block content %}
<div class="flex flex-col gap-8 justify-center lg:flex-row"> <div class="flex flex-col gap-8 justify-center lg:flex-row">
<article class="p-8 bg-white rounded-md shadow-md prose"> <article class="p-8 w-full max-w-screen-md bg-white rounded-md shadow-md prose">
{% if focus.show_title %} {% if focus.show_title %}
<h1 class="font-medium text-center">{{ focus.title }}</h1> <h1 class="font-medium text-center">{{ focus.title }}</h1>
{% endif %} {% endif %}

View File

@ -1,14 +1,26 @@
{% 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 gap-8 justify-center lg:flex-row"> <div class="flex flex-col gap-8 justify-center lg:flex-row">
<article <div
class="p-4 mb-auto max-w-screen-sm bg-white rounded-md shadow-md basis-1/2 prose" class="flex flex-col gap-4 items-center basis-1/2"
> >
{% content gpw %} {% for gpw in gpws %}
<div class="flex flex-wrap gap-4 justify-center items-center"> <article
{% buttons gpw.buttons %} class="p-4 py-4 w-full max-w-full bg-white rounded-md shadow-md prose"
</div> >
</article> {% if gpw.show_title %}
<h2 class="font-medium">{{ gpw.title }}</h2>
{% endif %}
<div>{% readmore gpw %}</div>
<div class="flex flex-wrap gap-4 justify-center items-center">
{% buttons gpw.buttons %}
</div>
</article>
{% if not forloop.last %}
<hr class="w-36 border-b border-stone-200" />
{% endif %} {% endfor %}
</div>
<div class="flex flex-col gap-4 items-center basis-1/2"> <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"

BIN
db.sqlite3.bak 100644

Binary file not shown.

View File

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

View File

@ -0,0 +1,36 @@
# Generated by Django 4.1.7 on 2023-05-31 18:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0008_alter_grandprixw_options_alter_grandprixw_buttons_and_more'),
]
operations = [
migrations.AlterModelOptions(
name='grandprixw',
options={'ordering': ['ordering'], 'verbose_name': 'Grand Prix Województwa', 'verbose_name_plural': 'Grand Prix Województwa'},
),
migrations.RemoveField(
model_name='grandprixw',
name='current',
),
migrations.AddField(
model_name='grandprixw',
name='ordering',
field=models.IntegerField(default=0, verbose_name='Kolejność'),
),
migrations.AddField(
model_name='grandprixw',
name='show_title',
field=models.BooleanField(default=True, verbose_name='Pokaż tytuł'),
),
migrations.AlterField(
model_name='grandprixw',
name='year',
field=models.AutoField(primary_key=True, serialize=False),
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 4.1.7 on 2023-05-31 18:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0009_alter_grandprixw_options_remove_grandprixw_current_and_more'),
]
operations = [
migrations.AddField(
model_name='grandprixw',
name='title',
field=models.CharField(blank=True, default='', max_length=250, verbose_name='Tytuł'),
),
]

View File

@ -0,0 +1,28 @@
# Generated by Django 4.1.7 on 2023-05-31 18:55
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0010_grandprixw_title'),
]
operations = [
migrations.RenameField(
model_name='grandprixw',
old_name='year',
new_name='id',
),
migrations.AlterField(
model_name='grandprixw',
name='published',
field=models.BooleanField(default=False, verbose_name='Grand Prix opublikowane'),
),
migrations.AlterField(
model_name='post',
name='published',
field=models.BooleanField(default=False, verbose_name='Wpis opublikowany'),
),
]

View File

@ -10,7 +10,7 @@ from db.help import buttons_help_text
class Post(OrderableModel): class Post(OrderableModel):
published = models.BooleanField('Wpis opublikowany', default=True) published = models.BooleanField('Wpis opublikowany', default=False)
show_title = models.BooleanField('Pokaż tytuł', default=True) show_title = models.BooleanField('Pokaż tytuł', default=True)
title = models.CharField('Tytuł', default='', blank=True, max_length=250) title = models.CharField('Tytuł', default='', blank=True, max_length=250)
content = HTMLField('Treść', default='', blank=True) content = HTMLField('Treść', default='', blank=True)
@ -31,32 +31,27 @@ class Post(OrderableModel):
verbose_name_plural = 'Aktualności PodlZBS' verbose_name_plural = 'Aktualności PodlZBS'
class GrandPrixW(models.Model): class GrandPrixW(OrderableModel):
published = models.BooleanField('Grand Prix opublikowane', default=True) id = models.AutoField(primary_key=True)
year = models.IntegerField('Rok', primary_key=True, default=1) published = models.BooleanField('Grand Prix opublikowane', default=False)
title = models.CharField('Tytuł', default='', blank=True, max_length=250)
show_title = models.BooleanField('Pokaż tytuł', default=True)
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 @staticmethod
def get_current(): def get_current():
return GrandPrixW.objects.filter(current=True, published=True).first() return GrandPrixW.objects.filter(published=True)
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 f'Grand Prix Województwa {self.year}' return self.title or '-'
@property @property
def link(self): def link(self):
href = reverse_lazy('gpw-reverse', args=[self.year]) href = reverse_lazy('gpw-reverse', args=[self.id])
return mark_safe(f'<a href="{href}" target="_blank">{href}</a>') return mark_safe(f'<a href="{href}" target="_blank">{href}</a>')
class Meta: class Meta(OrderableModel.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']