many gpws
parent
de9a718bb0
commit
aa65cb09a8
|
|
@ -16,7 +16,7 @@ def load_config(request):
|
|||
return {
|
||||
'nav': Button.objects.filter(published=True),
|
||||
'uppernav': UpperButton.objects.filter(published=True),
|
||||
'gpw': GrandPrixW.get_current(),
|
||||
'gpws': GrandPrixW.get_current(),
|
||||
'posts': Post.objects.filter(published=True),
|
||||
'daneadresowe': Data.load(),
|
||||
'czlonkowie': Member.objects.all(),
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<!---->
|
||||
{% 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">
|
||||
<article class="p-8 w-full max-w-screen-md bg-white rounded-md shadow-md prose">
|
||||
{% if focus.show_title %}
|
||||
<h1 class="font-medium text-center">{{ focus.title }}</h1>
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,26 @@
|
|||
{% extends 'base.html' %} {% block title %}Strona główna | pdlzbs{% endblock %}
|
||||
{% load static tailwind_tags wysiwyg %} {% block content %}
|
||||
<div class="flex flex-col gap-8 justify-center lg:flex-row">
|
||||
<article
|
||||
class="p-4 mb-auto max-w-screen-sm bg-white rounded-md shadow-md basis-1/2 prose"
|
||||
<div
|
||||
class="flex flex-col gap-4 items-center basis-1/2"
|
||||
>
|
||||
{% content gpw %}
|
||||
{% for gpw in gpws %}
|
||||
<article
|
||||
class="p-4 py-4 w-full max-w-full bg-white rounded-md shadow-md prose"
|
||||
>
|
||||
{% 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">
|
||||
<h1
|
||||
class="text-[2.25rem] font-medium w-full text-center bg-white shadow-md rounded-md px-4 py-2"
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -14,5 +14,9 @@ class PostModelAdmin(OrderableAdmin, admin.ModelAdmin):
|
|||
|
||||
|
||||
@admin.register(GrandPrixW)
|
||||
class GrandPrixWAdmin(admin.ModelAdmin):
|
||||
list_display = ('__str__', 'link', 'published', 'current')
|
||||
class GrandPrixWAdmin(OrderableAdmin, admin.ModelAdmin):
|
||||
list_display = ('__str__', 'link', 'published', 'ordering')
|
||||
list_editable = ['ordering']
|
||||
ordering_field_hide_input = True
|
||||
exclude = ['ordering']
|
||||
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
),
|
||||
]
|
||||
|
|
@ -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ł'),
|
||||
),
|
||||
]
|
||||
|
|
@ -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'),
|
||||
),
|
||||
]
|
||||
|
|
@ -10,7 +10,7 @@ from db.help import buttons_help_text
|
|||
|
||||
|
||||
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)
|
||||
title = models.CharField('Tytuł', default='', blank=True, max_length=250)
|
||||
content = HTMLField('Treść', default='', blank=True)
|
||||
|
|
@ -31,32 +31,27 @@ class Post(OrderableModel):
|
|||
verbose_name_plural = 'Aktualności PodlZBS'
|
||||
|
||||
|
||||
class GrandPrixW(models.Model):
|
||||
published = models.BooleanField('Grand Prix opublikowane', default=True)
|
||||
year = models.IntegerField('Rok', primary_key=True, default=1)
|
||||
class GrandPrixW(OrderableModel):
|
||||
id = models.AutoField(primary_key=True)
|
||||
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)
|
||||
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)
|
||||
return GrandPrixW.objects.filter(published=True)
|
||||
|
||||
def __str__(self):
|
||||
return f'Grand Prix Województwa {self.year}'
|
||||
return self.title or '-'
|
||||
|
||||
@property
|
||||
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>')
|
||||
|
||||
class Meta:
|
||||
class Meta(OrderableModel.Meta):
|
||||
verbose_name = 'Grand Prix Województwa'
|
||||
verbose_name_plural = 'Grand Prix Województwa'
|
||||
ordering = ['-year']
|
||||
|
|
|
|||
Loading…
Reference in New Issue