[func] arrange and reorder buttons on the homepage

main
yaemiku 2022-07-25 23:16:10 +02:00
parent 6fd27f0f2b
commit 60d0a9fcd3
Signed by: podlaskizbs
GPG Key ID: ADC039636B3E4AAB
11 changed files with 108 additions and 13 deletions

10
.worktime 100644
View File

@ -0,0 +1,10 @@
08.06.2022 - 1h 37 mins
09.06.2022 - 1h
12.06.2022 - 1h 15 mins
15.06.2022 - 1h 30 mins
23.06.2022 - 1h 30 mins
07.07.2022 - 2h 30 mins
15.07.2022 - 3h
24.07.2022 - 3h 30 mins
25.07.2022 - 3h 30 mins
26.07.2022 - 1h 30 mins

View File

@ -2,8 +2,20 @@ from django.apps import apps as _apps
from django.contrib import admin from django.contrib import admin
from django.contrib.admin.sites import AlreadyRegistered from django.contrib.admin.sites import AlreadyRegistered
from .models import *
from admin_ordering.admin import OrderableAdmin
# Register your models here. # Register your models here.
@admin.register(Button)
class ButtonModelAdmin(OrderableAdmin, admin.ModelAdmin):
list_display = ['__str__', 'ordering']
list_editable = ['ordering']
ordering_field_hide_input = True
exclude = ['ordering']
apps = [ apps = [
'main', 'main',
'administration', 'administration',

View File

@ -4,4 +4,4 @@ from django.apps import AppConfig
class CoreConfig(AppConfig): class CoreConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField' default_auto_field = 'django.db.models.BigAutoField'
name = 'core' name = 'core'
verbose_name = 'Baza danych' verbose_name = '0. Konfiguracja'

View File

@ -0,0 +1,6 @@
from .models import *
def load_config(request):
config = {'nav': Button.objects.all()}
return {'config': config}

View File

@ -0,0 +1,31 @@
# Generated by Django 4.0.5 on 2022-07-25 21:08
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('core', '0009_delete_administrationannouncement_and_more'),
]
operations = [
migrations.CreateModel(
name='Button',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('ordering', models.IntegerField(default=0, verbose_name='Kolejność')),
('title', models.CharField(max_length=50, verbose_name='Tekst na przycisku')),
('href', models.CharField(max_length=50, verbose_name='Link')),
('blank', models.BooleanField(verbose_name='Otwórz w nowej karcie')),
],
options={
'verbose_name': 'Przycisk na stronie głównej',
'verbose_name_plural': 'Przyciski na stronie głównej',
'ordering': ['ordering'],
'abstract': False,
},
),
]

19
core/models.py 100644
View File

@ -0,0 +1,19 @@
from django.db import models
from tinymce.models import HTMLField
from admin_ordering.models import OrderableModel
from core.utils import SingletonModel
# Create your models here.
class Button(OrderableModel):
title = models.CharField('Tekst na przycisku', max_length=50)
href = models.CharField('Link', max_length=50)
blank = models.BooleanField('Otwórz w nowej karcie')
def __str__(self):
return self.title or '-'
class Meta(OrderableModel.Meta):
verbose_name = 'Przycisk na stronie głównej'
verbose_name_plural = 'Przyciski na stronie głównej'

View File

@ -26,18 +26,17 @@
<div class="mb-4 mx-auto p-2 text-center"> <div class="mb-4 mx-auto p-2 text-center">
<h1 class="text-4xl">Podlaski Związek <br> Brydża Sportowego</h1> <h1 class="text-4xl">Podlaski Związek <br> Brydża Sportowego</h1>
</div> </div>
{% if config.nav %}
<nav> <nav>
<ul class="flex flex-wrap justify-center lg:items-end gap-3 text-[15px] leading-5 m-2"> <ul class="flex flex-wrap justify-center lg:items-end gap-3 text-[15px] leading-5 m-2">
<li class="nav-item {{ home }}"><a href="{% url 'home' %}">Strona&nbsp;główna</a></li> {% for button in config.nav %}
<li class="nav-item {% if 'zarzad' in request.path %}active{% endif %}"><a href="{% url 'administration' %}">Zarząd</a></li> <li class="nav-item {% if request.path == '/' %}{{ home }}{% elif button.href in request.path %}active{% endif %}">
<li class="nav-item"><a href="http://rejestr.labs.lomza.pl/">BridgeRegister</a></li> <a href="{{ button.href }}">{{ button.title }}</a>
<li class="nav-item {% if 'liga' in request.path %}active{% endif %}"><a href="{% url 'league' %}">III&nbsp;Liga</a></li> </li>
<li class="nav-item {% if 'kalendarz' in request.path %}active{% endif %}"><a href="{% url 'calendar' %}">Kalendarz</a></li> {% endfor %}
<li class="nav-item {% if 'grandprix' in request.path %}active{% endif %}"><a href="{% url 'gpx' %}">GPB</a></li>
<li class="nav-item {% if 'inneturnieje' in request.path %}active{% endif %}"><a href="{% url 'tournaments' %}">Inne&nbsp;turnieje</a></li>
<li class="nav-item {% if 'skladki' in request.path %}active{% endif %}"><a href="{% url 'membership' %}">Składki&nbsp;członkowskie</a></li>
</ul> </ul>
</nav> </nav>
{% endif %}
</div> </div>
<nav class="flex flex-wrap justify-center items-center gap-6 mt-8"> <nav class="flex flex-wrap justify-center items-center gap-6 mt-8">
<div title="Cezar"> <div title="Cezar">

View File

@ -14,7 +14,7 @@ urlpatterns = [
name='administration_rodos'), name='administration_rodos'),
path('liga', LeagueView.as_view(), name='league'), path('liga', LeagueView.as_view(), name='league'),
path('kalendarz', CalendarView.as_view(), name='calendar'), path('kalendarz', CalendarView.as_view(), name='calendar'),
path('grandprix', GrandPrixView.as_view(), name='gpx'), path('grandprixbialegostoku', GrandPrixView.as_view(), name='gpx'),
path('inneturnieje', TournamentView.as_view(), name='tournaments'), path('inneturnieje', TournamentView.as_view(), name='tournaments'),
path('skladki', MembershipView.as_view(), name='membership'), path('skladki', MembershipView.as_view(), name='membership'),
path('atu', AtuView.as_view(), name='atu'), path('atu', AtuView.as_view(), name='atu'),

View File

@ -0,0 +1,17 @@
# Generated by Django 4.0.5 on 2022-07-25 21:14
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('league', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='league',
options={'ordering': ['-year'], 'verbose_name': 'Wyniki ligi', 'verbose_name_plural': 'Wyniki ligi'},
),
]

View File

@ -8,9 +8,9 @@ class League(models.Model):
link = models.CharField('Link do wyników', max_length=512) link = models.CharField('Link do wyników', max_length=512)
def __str__(self): def __str__(self):
return f'III Liga {self.year}' return f'Liga {self.year}'
class Meta: class Meta:
verbose_name = 'Wyniki III Ligi' verbose_name = 'Wyniki ligi'
verbose_name_plural = 'Wyniki III Ligi' verbose_name_plural = 'Wyniki ligi'
ordering = ['-year'] ordering = ['-year']

View File

@ -89,6 +89,7 @@ TEMPLATES = [
'django.template.context_processors.request', 'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth', 'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages', 'django.contrib.messages.context_processors.messages',
'core.context_processors.load_config'
], ],
}, },
}, },