diff --git a/.worktime b/.worktime new file mode 100644 index 0000000..0cc171a --- /dev/null +++ b/.worktime @@ -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 \ No newline at end of file diff --git a/core/admin.py b/core/admin.py index 75c2e50..464841f 100644 --- a/core/admin.py +++ b/core/admin.py @@ -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', diff --git a/core/apps.py b/core/apps.py index 1bbf2e1..e7540fa 100644 --- a/core/apps.py +++ b/core/apps.py @@ -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' diff --git a/core/context_processors.py b/core/context_processors.py new file mode 100644 index 0000000..20e3faa --- /dev/null +++ b/core/context_processors.py @@ -0,0 +1,6 @@ +from .models import * + + +def load_config(request): + config = {'nav': Button.objects.all()} + return {'config': config} diff --git a/core/migrations/0010_initial.py b/core/migrations/0010_initial.py new file mode 100644 index 0000000..76c5638 --- /dev/null +++ b/core/migrations/0010_initial.py @@ -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, + }, + ), + ] diff --git a/core/models.py b/core/models.py new file mode 100644 index 0000000..73f3023 --- /dev/null +++ b/core/models.py @@ -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' diff --git a/core/templates/base.html b/core/templates/base.html index ed14bae..6dabf52 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -26,18 +26,17 @@