[func] arrange and reorder buttons on the homepage
parent
6fd27f0f2b
commit
60d0a9fcd3
|
|
@ -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
|
||||
|
|
@ -2,8 +2,20 @@ from django.apps import apps as _apps
|
|||
from django.contrib import admin
|
||||
from django.contrib.admin.sites import AlreadyRegistered
|
||||
|
||||
from .models import *
|
||||
from admin_ordering.admin import OrderableAdmin
|
||||
|
||||
# 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 = [
|
||||
'main',
|
||||
'administration',
|
||||
|
|
|
|||
|
|
@ -4,4 +4,4 @@ from django.apps import AppConfig
|
|||
class CoreConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'core'
|
||||
verbose_name = 'Baza danych'
|
||||
verbose_name = '0. Konfiguracja'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
from .models import *
|
||||
|
||||
|
||||
def load_config(request):
|
||||
config = {'nav': Button.objects.all()}
|
||||
return {'config': config}
|
||||
|
|
@ -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,
|
||||
},
|
||||
),
|
||||
]
|
||||
|
|
@ -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'
|
||||
|
|
@ -26,18 +26,17 @@
|
|||
<div class="mb-4 mx-auto p-2 text-center">
|
||||
<h1 class="text-4xl">Podlaski Związek <br> Brydża Sportowego</h1>
|
||||
</div>
|
||||
{% if config.nav %}
|
||||
<nav>
|
||||
<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 główna</a></li>
|
||||
<li class="nav-item {% if 'zarzad' in request.path %}active{% endif %}"><a href="{% url 'administration' %}">Zarząd</a></li>
|
||||
<li class="nav-item"><a href="http://rejestr.labs.lomza.pl/">BridgeRegister</a></li>
|
||||
<li class="nav-item {% if 'liga' in request.path %}active{% endif %}"><a href="{% url 'league' %}">III Liga</a></li>
|
||||
<li class="nav-item {% if 'kalendarz' in request.path %}active{% endif %}"><a href="{% url 'calendar' %}">Kalendarz</a></li>
|
||||
<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 turnieje</a></li>
|
||||
<li class="nav-item {% if 'skladki' in request.path %}active{% endif %}"><a href="{% url 'membership' %}">Składki członkowskie</a></li>
|
||||
{% for button in config.nav %}
|
||||
<li class="nav-item {% if request.path == '/' %}{{ home }}{% elif button.href in request.path %}active{% endif %}">
|
||||
<a href="{{ button.href }}">{{ button.title }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</nav>
|
||||
{% endif %}
|
||||
</div>
|
||||
<nav class="flex flex-wrap justify-center items-center gap-6 mt-8">
|
||||
<div title="Cezar">
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ urlpatterns = [
|
|||
name='administration_rodos'),
|
||||
path('liga', LeagueView.as_view(), name='league'),
|
||||
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('skladki', MembershipView.as_view(), name='membership'),
|
||||
path('atu', AtuView.as_view(), name='atu'),
|
||||
|
|
|
|||
|
|
@ -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'},
|
||||
),
|
||||
]
|
||||
|
|
@ -8,9 +8,9 @@ class League(models.Model):
|
|||
link = models.CharField('Link do wyników', max_length=512)
|
||||
|
||||
def __str__(self):
|
||||
return f'III Liga {self.year}'
|
||||
return f'Liga {self.year}'
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'Wyniki III Ligi'
|
||||
verbose_name_plural = 'Wyniki III Ligi'
|
||||
verbose_name = 'Wyniki ligi'
|
||||
verbose_name_plural = 'Wyniki ligi'
|
||||
ordering = ['-year']
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ TEMPLATES = [
|
|||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'core.context_processors.load_config'
|
||||
],
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue