diff --git a/shared/migrations/0016_auto_20210107_1025.py b/shared/migrations/0016_auto_20210107_1025.py new file mode 100644 index 0000000000000000000000000000000000000000..3557b89616d1699e20ddccc4b716a2ebe9c2a1df --- /dev/null +++ b/shared/migrations/0016_auto_20210107_1025.py @@ -0,0 +1,21 @@ +# Generated by Django 3.1.3 on 2021-01-07 09:25 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("shared", "0015_auto_20210106_1029"), + ] + + operations = [ + migrations.RemoveField( + model_name="personpage", + name="profile_id", + ), + migrations.RemoveField( + model_name="personpage", + name="username", + ), + ] diff --git a/shared/migrations/0017_person.py b/shared/migrations/0017_person.py new file mode 100644 index 0000000000000000000000000000000000000000..b259f24ed1ec67a83efe3cc275059a6c91524bb3 --- /dev/null +++ b/shared/migrations/0017_person.py @@ -0,0 +1,49 @@ +# Generated by Django 3.1.3 on 2021-01-07 09:58 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("shared", "0016_auto_20210107_1025"), + ] + + operations = [ + migrations.CreateModel( + name="Person", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("username", models.TextField(verbose_name="UĹľivatelskĂ© jmĂ©no osoby")), + ( + "profile_id", + models.IntegerField( + blank=True, + default=0, + validators=[ + django.core.validators.MinValueValidator(0), + django.core.validators.MaxValueValidator(2), + ], + verbose_name="ÄŚĂslo medailonku (0..2) z lide.pirati.cz", + ), + ), + ( + "perex", + models.TextField(blank=True, verbose_name="Defaultni perex osoby"), + ), + ], + options={ + "verbose_name": "Pirat", + "verbose_name_plural": "Pirati", + }, + ), + ] diff --git a/shared/migrations/0018_auto_20210107_1101.py b/shared/migrations/0018_auto_20210107_1101.py new file mode 100644 index 0000000000000000000000000000000000000000..ec027a2eb6aafca059b5657a8250c690446c0cb1 --- /dev/null +++ b/shared/migrations/0018_auto_20210107_1101.py @@ -0,0 +1,17 @@ +# Generated by Django 3.1.3 on 2021-01-07 10:01 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("shared", "0017_person"), + ] + + operations = [ + migrations.AlterModelOptions( + name="person", + options={"verbose_name": "Pirát", "verbose_name_plural": "Piráti"}, + ), + ] diff --git a/shared/models.py b/shared/models.py index 07013d908883ea4bfc0340a8c547e92db95f10ba..f239da832b8985fb246b687ca1f30cf33abb90be 100644 --- a/shared/models.py +++ b/shared/models.py @@ -87,8 +87,8 @@ class Article(ArticleMixin, Page, SharedSubpageMixin, MetadataPageMixin): ] -class PersonPage(SharedSubpageMixin, MetadataPageMixin, Page): - """Stranka Pirata. +class Person(models.Model): + """Informace o Piratovi. Slouzi prevazne jako cache informaci o osobe pro uziti v ramci Majaku. Snaha je zadavat tady minimum informaci o osobe a zbytek vytahovat via API z jinych zdroju, neb nechceme dalsi databazi lidi. """ @@ -102,9 +102,9 @@ class PersonPage(SharedSubpageMixin, MetadataPageMixin, Page): validators=[MinValueValidator(0), MaxValueValidator(2)], ) - perex = models.TextField("Perex osoby", blank=True) + perex = models.TextField("Defaultni perex osoby", blank=True) - content_panels = Page.content_panels + [ + panels = [ FieldPanel("username"), FieldPanel("profile_id"), FieldPanel("perex"), @@ -154,6 +154,22 @@ class PersonPage(SharedSubpageMixin, MetadataPageMixin, Page): def facebook(self): return None # TODO + class Meta: + verbose_name_plural = "Piráti" + verbose_name = "Pirát" + + +class PersonPage(SharedSubpageMixin, MetadataPageMixin, Page): + """Stranka Pirata v kontextu jednoho webu""" + + # person = models.ForeignKey(Person, on_delete=models.PROTECT) + perex = models.TextField("Perex osoby", blank=True) + + content_panels = Page.content_panels + [ + # FieldPanel("person"), + FieldPanel("perex"), + ] + class Meta: verbose_name = "ÄŚlovÄ›k" # to zni hrde diff --git a/shared/wagtail_hooks.py b/shared/wagtail_hooks.py new file mode 100644 index 0000000000000000000000000000000000000000..a286602db30ef267f3b35f498aeb619a9bfdefbb --- /dev/null +++ b/shared/wagtail_hooks.py @@ -0,0 +1,17 @@ +from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register + +from .models import Person + + +class PersonAdmin(ModelAdmin): + model = Person + menu_label = "Pirati" + menu_icon = "group" + menu_order = 200 + add_to_settings_menu = False + exclude_from_explorer = False + list_display = ("username",) + search_fields = ("username",) + + +modeladmin_register(PersonAdmin)