diff --git a/home/blocks.py b/home/blocks.py index f2f638320b2ab402df81bf3cf4492e26af12a11e..dc0c0502097a0294f7aa579825ea20b3b53d03a6 100644 --- a/home/blocks.py +++ b/home/blocks.py @@ -34,6 +34,7 @@ class DocumentBlock(StructBlock): class EventBlock(StructBlock): name = CharBlock(label="Jméno") + url = URLBlock(label="URL") date = DateBlock(label="Datum konání", required=False) location = CharBlock(label="Lokace", required=False) diff --git a/home/migrations/0001_initial.py b/home/migrations/0001_initial.py index 64228ec63f992ec4264b2576386ca69334727943..db06fd3f9cd3223d330bdb47174e154d28f4ce6e 100644 --- a/home/migrations/0001_initial.py +++ b/home/migrations/0001_initial.py @@ -1,31 +1,55 @@ -# -*- coding: utf-8 -*- +# Generated by Django 4.2.2 on 2023-07-23 12:14 + from django.db import migrations, models +import django.db.models.deletion +import wagtail.blocks +import wagtail.documents.blocks +import wagtail.fields class Migration(migrations.Migration): + + initial = True + dependencies = [ - ("wagtailcore", "0040_page_draft_title"), + ('wagtailcore', '0083_workflowcontenttype'), ] operations = [ migrations.CreateModel( - name="HomePage", + name='HomeArticlesPage', + fields=[ + ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')), + ('author', models.CharField(verbose_name='Autor')), + ('perex', wagtail.fields.RichTextField(verbose_name='Perex')), + ('content', wagtail.fields.RichTextField(verbose_name='Obsah')), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + migrations.CreateModel( + name='HomePage', fields=[ - ( - "page_ptr", - models.OneToOneField( - on_delete=models.CASCADE, - parent_link=True, - auto_created=True, - primary_key=True, - serialize=False, - to="wagtailcore.Page", - ), - ), + ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')), + ('heading_text', wagtail.fields.RichTextField(verbose_name='Hlavní text stránky')), + ('events', wagtail.fields.StreamField([('event', wagtail.blocks.StructBlock([('name', wagtail.blocks.CharBlock(label='Jméno')), ('url', wagtail.blocks.URLBlock(label='URL')), ('date', wagtail.blocks.DateBlock(label='Datum konání', required=False)), ('location', wagtail.blocks.CharBlock(label='Lokace', required=False))]))], blank=True, null=True, use_json_field=True, verbose_name='Události')), + ('documents', wagtail.fields.StreamField([('document', wagtail.blocks.StructBlock([('name', wagtail.blocks.CharBlock(label='Jméno')), ('date_added', wagtail.blocks.DateBlock(label='Datum přidání', required=False)), ('url', wagtail.blocks.URLBlock(label='URL (místo dokumentu)', required=False)), ('file', wagtail.documents.blocks.DocumentChooserBlock(label='Dokument', required=False))]))], blank=True, null=True, use_json_field=True, verbose_name='Dokumenty')), + ('donation_text', wagtail.fields.RichTextField(verbose_name='Text pro dary')), + ('address', models.CharField(verbose_name='Sídlo')), + ('branch', models.CharField(verbose_name='Pobočka')), + ('email', models.EmailField(max_length=254, verbose_name='Email')), + ('ds_id', models.CharField(verbose_name='Datová schránka')), + ('director', wagtail.fields.StreamField([('person', wagtail.blocks.StructBlock([('name', wagtail.blocks.CharBlock(label='Jméno')), ('position', wagtail.blocks.TextBlock(label='Pracovní pozice', required=False)), ('email', wagtail.blocks.EmailBlock(label='E-mailová adresa', required=False))]))], blank=True, null=True, use_json_field=True, verbose_name='Ředitel')), + ('controller', wagtail.fields.StreamField([('person', wagtail.blocks.StructBlock([('name', wagtail.blocks.CharBlock(label='Jméno')), ('position', wagtail.blocks.TextBlock(label='Pracovní pozice', required=False)), ('email', wagtail.blocks.EmailBlock(label='E-mailová adresa', required=False))]))], blank=True, null=True, use_json_field=True, verbose_name='Kontrolor')), + ('council_members', wagtail.fields.StreamField([('person', wagtail.blocks.StructBlock([('name', wagtail.blocks.CharBlock(label='Jméno')), ('position', wagtail.blocks.TextBlock(label='Pracovní pozice', required=False)), ('email', wagtail.blocks.EmailBlock(label='E-mailová adresa', required=False))]))], blank=True, null=True, use_json_field=True, verbose_name='Správní rada')), + ('volunteers', wagtail.fields.StreamField([('person', wagtail.blocks.StructBlock([('name', wagtail.blocks.CharBlock(label='Jméno')), ('position', wagtail.blocks.TextBlock(label='Pracovní pozice', required=False)), ('email', wagtail.blocks.EmailBlock(label='E-mailová adresa', required=False))]))], blank=True, null=True, use_json_field=True, verbose_name='Dobrovolníci')), + ('employees', wagtail.fields.StreamField([('person', wagtail.blocks.StructBlock([('name', wagtail.blocks.CharBlock(label='Jméno')), ('position', wagtail.blocks.TextBlock(label='Pracovní pozice', required=False)), ('email', wagtail.blocks.EmailBlock(label='E-mailová adresa', required=False))]))], blank=True, null=True, use_json_field=True, verbose_name='Zaměstnanci')), ], options={ - "abstract": False, + 'abstract': False, }, - bases=("wagtailcore.page",), + bases=('wagtailcore.page',), ), ] diff --git a/home/migrations/0002_create_homepage.py b/home/migrations/0002_create_homepage.py deleted file mode 100644 index fdb0906456ea855cd40f37ce9ae7146cce853f25..0000000000000000000000000000000000000000 --- a/home/migrations/0002_create_homepage.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -from django.db import migrations - - -def create_homepage(apps, schema_editor): - # Get models - ContentType = apps.get_model("contenttypes.ContentType") - Page = apps.get_model("wagtailcore.Page") - Site = apps.get_model("wagtailcore.Site") - HomePage = apps.get_model("home.HomePage") - - # Delete the default homepage - # If migration is run multiple times, it may have already been deleted - Page.objects.filter(id=2).delete() - - # Create content type for homepage model - homepage_content_type, __ = ContentType.objects.get_or_create( - model="homepage", app_label="home" - ) - - # Create a new homepage - homepage = HomePage.objects.create( - title="Home", - draft_title="Home", - slug="home", - content_type=homepage_content_type, - path="00010001", - depth=2, - numchild=0, - url_path="/home/", - ) - - # Create a site with the new homepage set as the root - Site.objects.create(hostname="localhost", root_page=homepage, is_default_site=True) - - -def remove_homepage(apps, schema_editor): - # Get models - ContentType = apps.get_model("contenttypes.ContentType") - HomePage = apps.get_model("home.HomePage") - - # Delete the default homepage - # Page and Site objects CASCADE - HomePage.objects.filter(slug="home", depth=2).delete() - - # Delete content type for homepage model - ContentType.objects.filter(model="homepage", app_label="home").delete() - - -class Migration(migrations.Migration): - run_before = [ - ("wagtailcore", "0053_locale_model"), - ] - - dependencies = [ - ("home", "0001_initial"), - ] - - operations = [ - migrations.RunPython(create_homepage, remove_homepage), - ] diff --git a/home/migrations/0002_homearticlepage_remove_homearticlespage_author_and_more.py b/home/migrations/0002_homearticlepage_remove_homearticlespage_author_and_more.py new file mode 100644 index 0000000000000000000000000000000000000000..2a0d5b31b1a90e72232e10d6c344ee1890bc881d --- /dev/null +++ b/home/migrations/0002_homearticlepage_remove_homearticlespage_author_and_more.py @@ -0,0 +1,37 @@ +# Generated by Django 4.2.2 on 2023-07-23 12:29 + +from django.db import migrations, models +import django.db.models.deletion +import wagtail.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0083_workflowcontenttype'), + ('home', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='HomeArticlePage', + fields=[ + ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')), + ('author', models.CharField(verbose_name='Autor')), + ('perex', wagtail.fields.RichTextField(verbose_name='Perex')), + ('content', wagtail.fields.RichTextField(verbose_name='Obsah')), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + migrations.RemoveField( + model_name='homearticlespage', + name='author', + ), + migrations.RemoveField( + model_name='homearticlespage', + name='perex', + ), + ] diff --git a/home/migrations/0003_alter_homearticlespage_content.py b/home/migrations/0003_alter_homearticlespage_content.py new file mode 100644 index 0000000000000000000000000000000000000000..c02570ff89454bda2d019286f9c69d016ed9ac90 --- /dev/null +++ b/home/migrations/0003_alter_homearticlespage_content.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.2 on 2023-07-23 12:31 + +from django.db import migrations +import wagtail.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0002_homearticlepage_remove_homearticlespage_author_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='homearticlespage', + name='content', + field=wagtail.fields.RichTextField(blank=True, null=True, verbose_name='Obsah'), + ), + ] diff --git a/home/migrations/0003_homepage_controller_homepage_council_members_and_more.py b/home/migrations/0003_homepage_controller_homepage_council_members_and_more.py deleted file mode 100644 index 9897138d219e641ec6237a2372e3a841412ddf10..0000000000000000000000000000000000000000 --- a/home/migrations/0003_homepage_controller_homepage_council_members_and_more.py +++ /dev/null @@ -1,154 +0,0 @@ -# Generated by Django 4.2.2 on 2023-06-29 13:26 - -import wagtail.blocks -import wagtail.fields -from django.db import migrations - - -class Migration(migrations.Migration): - dependencies = [ - ("home", "0002_create_homepage"), - ] - - operations = [ - migrations.AddField( - model_name="homepage", - name="controller", - field=wagtail.fields.StreamField( - [ - ( - "person", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "position", - wagtail.blocks.TextBlock(label="Pracovní pozice"), - ), - ( - "email", - wagtail.blocks.EmailBlock(label="E-mailová adresa"), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Kontrolor", - ), - ), - migrations.AddField( - model_name="homepage", - name="council_members", - field=wagtail.fields.StreamField( - [ - ( - "person", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "position", - wagtail.blocks.TextBlock(label="Pracovní pozice"), - ), - ( - "email", - wagtail.blocks.EmailBlock(label="E-mailová adresa"), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Správní rada", - ), - ), - migrations.AddField( - model_name="homepage", - name="director", - field=wagtail.fields.StreamField( - [ - ( - "person", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "position", - wagtail.blocks.TextBlock(label="Pracovní pozice"), - ), - ( - "email", - wagtail.blocks.EmailBlock(label="E-mailová adresa"), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Ředitel", - ), - ), - migrations.AddField( - model_name="homepage", - name="employees", - field=wagtail.fields.StreamField( - [ - ( - "person", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "position", - wagtail.blocks.TextBlock(label="Pracovní pozice"), - ), - ( - "email", - wagtail.blocks.EmailBlock(label="E-mailová adresa"), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Zaměstnanci", - ), - ), - migrations.AddField( - model_name="homepage", - name="volunteers", - field=wagtail.fields.StreamField( - [ - ( - "person", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "position", - wagtail.blocks.TextBlock(label="Pracovní pozice"), - ), - ( - "email", - wagtail.blocks.EmailBlock(label="E-mailová adresa"), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Dobrovolníci", - ), - ), - ] diff --git a/home/migrations/0004_alter_homepage_controller_and_more.py b/home/migrations/0004_alter_homepage_controller_and_more.py deleted file mode 100644 index dffb8a9ef234a2e2b1f4eb907a6e3e6b6d76c582..0000000000000000000000000000000000000000 --- a/home/migrations/0004_alter_homepage_controller_and_more.py +++ /dev/null @@ -1,174 +0,0 @@ -# Generated by Django 4.2.2 on 2023-06-29 13:39 - -import wagtail.blocks -import wagtail.fields -from django.db import migrations - - -class Migration(migrations.Migration): - dependencies = [ - ("home", "0003_homepage_controller_homepage_council_members_and_more"), - ] - - operations = [ - migrations.AlterField( - model_name="homepage", - name="controller", - field=wagtail.fields.StreamField( - [ - ( - "person", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "position", - wagtail.blocks.TextBlock( - blank=True, label="Pracovní pozice", null=True - ), - ), - ( - "email", - wagtail.blocks.EmailBlock( - blank=True, label="E-mailová adresa", null=True - ), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Kontrolor", - ), - ), - migrations.AlterField( - model_name="homepage", - name="council_members", - field=wagtail.fields.StreamField( - [ - ( - "person", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "position", - wagtail.blocks.TextBlock( - blank=True, label="Pracovní pozice", null=True - ), - ), - ( - "email", - wagtail.blocks.EmailBlock( - blank=True, label="E-mailová adresa", null=True - ), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Správní rada", - ), - ), - migrations.AlterField( - model_name="homepage", - name="director", - field=wagtail.fields.StreamField( - [ - ( - "person", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "position", - wagtail.blocks.TextBlock( - blank=True, label="Pracovní pozice", null=True - ), - ), - ( - "email", - wagtail.blocks.EmailBlock( - blank=True, label="E-mailová adresa", null=True - ), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Ředitel", - ), - ), - migrations.AlterField( - model_name="homepage", - name="employees", - field=wagtail.fields.StreamField( - [ - ( - "person", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "position", - wagtail.blocks.TextBlock( - blank=True, label="Pracovní pozice", null=True - ), - ), - ( - "email", - wagtail.blocks.EmailBlock( - blank=True, label="E-mailová adresa", null=True - ), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Zaměstnanci", - ), - ), - migrations.AlterField( - model_name="homepage", - name="volunteers", - field=wagtail.fields.StreamField( - [ - ( - "person", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "position", - wagtail.blocks.TextBlock( - blank=True, label="Pracovní pozice", null=True - ), - ), - ( - "email", - wagtail.blocks.EmailBlock( - blank=True, label="E-mailová adresa", null=True - ), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Dobrovolníci", - ), - ), - ] diff --git a/home/migrations/0004_homearticlepage_date.py b/home/migrations/0004_homearticlepage_date.py new file mode 100644 index 0000000000000000000000000000000000000000..fb92742eb3f3c25685f7cace3fb9c8966d0d1070 --- /dev/null +++ b/home/migrations/0004_homearticlepage_date.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.2 on 2023-07-23 12:37 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0003_alter_homearticlespage_content'), + ] + + operations = [ + migrations.AddField( + model_name='homearticlepage', + name='date', + field=models.DateField(default=django.utils.timezone.now, verbose_name='Datum vytvoření'), + ), + ] diff --git a/home/migrations/0005_homepage_address_homepage_branch_homepage_ds_id_and_more.py b/home/migrations/0005_homepage_address_homepage_branch_homepage_ds_id_and_more.py deleted file mode 100644 index 9a09852866238597f873415bac8e33702ff220a9..0000000000000000000000000000000000000000 --- a/home/migrations/0005_homepage_address_homepage_branch_homepage_ds_id_and_more.py +++ /dev/null @@ -1,198 +0,0 @@ -# Generated by Django 4.2.2 on 2023-06-29 13:58 - -import wagtail.blocks -import wagtail.fields -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("home", "0004_alter_homepage_controller_and_more"), - ] - - operations = [ - migrations.AddField( - model_name="homepage", - name="address", - field=models.CharField(default="", verbose_name="Sídlo"), - preserve_default=False, - ), - migrations.AddField( - model_name="homepage", - name="branch", - field=models.CharField(default="", verbose_name="Pobočka"), - preserve_default=False, - ), - migrations.AddField( - model_name="homepage", - name="ds_id", - field=models.CharField(default="", verbose_name="Datová schránka"), - preserve_default=False, - ), - migrations.AddField( - model_name="homepage", - name="email", - field=models.EmailField(default="", max_length=254, verbose_name="Email"), - preserve_default=False, - ), - migrations.AlterField( - model_name="homepage", - name="controller", - field=wagtail.fields.StreamField( - [ - ( - "person", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "position", - wagtail.blocks.TextBlock( - label="Pracovní pozice", required=False - ), - ), - ( - "email", - wagtail.blocks.EmailBlock( - label="E-mailová adresa", required=False - ), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Kontrolor", - ), - ), - migrations.AlterField( - model_name="homepage", - name="council_members", - field=wagtail.fields.StreamField( - [ - ( - "person", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "position", - wagtail.blocks.TextBlock( - label="Pracovní pozice", required=False - ), - ), - ( - "email", - wagtail.blocks.EmailBlock( - label="E-mailová adresa", required=False - ), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Správní rada", - ), - ), - migrations.AlterField( - model_name="homepage", - name="director", - field=wagtail.fields.StreamField( - [ - ( - "person", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "position", - wagtail.blocks.TextBlock( - label="Pracovní pozice", required=False - ), - ), - ( - "email", - wagtail.blocks.EmailBlock( - label="E-mailová adresa", required=False - ), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Ředitel", - ), - ), - migrations.AlterField( - model_name="homepage", - name="employees", - field=wagtail.fields.StreamField( - [ - ( - "person", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "position", - wagtail.blocks.TextBlock( - label="Pracovní pozice", required=False - ), - ), - ( - "email", - wagtail.blocks.EmailBlock( - label="E-mailová adresa", required=False - ), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Zaměstnanci", - ), - ), - migrations.AlterField( - model_name="homepage", - name="volunteers", - field=wagtail.fields.StreamField( - [ - ( - "person", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "position", - wagtail.blocks.TextBlock( - label="Pracovní pozice", required=False - ), - ), - ( - "email", - wagtail.blocks.EmailBlock( - label="E-mailová adresa", required=False - ), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Dobrovolníci", - ), - ), - ] diff --git a/home/migrations/0005_tag_alter_homearticlepage_options_and_more.py b/home/migrations/0005_tag_alter_homearticlepage_options_and_more.py new file mode 100644 index 0000000000000000000000000000000000000000..49e443c5161dc3b927fed64ce4fd463eb6a0c39b --- /dev/null +++ b/home/migrations/0005_tag_alter_homearticlepage_options_and_more.py @@ -0,0 +1,38 @@ +# Generated by Django 4.2.2 on 2023-07-23 13:41 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0004_homearticlepage_date'), + ] + + operations = [ + migrations.CreateModel( + name='Tag', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(verbose_name='Jméno')), + ], + options={ + 'verbose_name': 'Štítek', + 'verbose_name_plural': 'Štítky', + }, + ), + migrations.AlterModelOptions( + name='homearticlepage', + options={'ordering': ['-date']}, + ), + migrations.AlterField( + model_name='homearticlepage', + name='perex', + field=models.TextField(verbose_name='Perex'), + ), + migrations.AddField( + model_name='homearticlepage', + name='tags', + field=models.ManyToManyField(to='home.tag', verbose_name='Štítky'), + ), + ] diff --git a/home/migrations/0006_homepage_donation_text.py b/home/migrations/0006_homepage_donation_text.py deleted file mode 100644 index ca73bbab740a78cad347df33718cfafb72b69be9..0000000000000000000000000000000000000000 --- a/home/migrations/0006_homepage_donation_text.py +++ /dev/null @@ -1,21 +0,0 @@ -# Generated by Django 4.2.2 on 2023-07-18 11:06 - -import wagtail.fields -from django.db import migrations - - -class Migration(migrations.Migration): - dependencies = [ - ("home", "0005_homepage_address_homepage_branch_homepage_ds_id_and_more"), - ] - - operations = [ - migrations.AddField( - model_name="homepage", - name="donation_text", - field=wagtail.fields.RichTextField( - default="", verbose_name="Text pro dary" - ), - preserve_default=False, - ), - ] diff --git a/home/migrations/0007_homepage_documents.py b/home/migrations/0007_homepage_documents.py deleted file mode 100644 index e800113702e56081d665396c147b4dccfd28d296..0000000000000000000000000000000000000000 --- a/home/migrations/0007_homepage_documents.py +++ /dev/null @@ -1,45 +0,0 @@ -# Generated by Django 4.2.2 on 2023-07-18 11:21 - -import wagtail.blocks -import wagtail.documents.blocks -import wagtail.fields -from django.db import migrations - - -class Migration(migrations.Migration): - dependencies = [ - ("home", "0006_homepage_donation_text"), - ] - - operations = [ - migrations.AddField( - model_name="homepage", - name="documents", - field=wagtail.fields.StreamField( - [ - ( - "document", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "date_added", - wagtail.blocks.DateBlock(label="Datum přidání"), - ), - ( - "file", - wagtail.documents.blocks.DocumentChooserBlock( - label="Dokument" - ), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Dokumenty", - ), - ), - ] diff --git a/home/migrations/0008_homepage_events_alter_homepage_documents.py b/home/migrations/0008_homepage_events_alter_homepage_documents.py deleted file mode 100644 index cecee2c4ea651c25c3c301ad3ad28ad51147f2e9..0000000000000000000000000000000000000000 --- a/home/migrations/0008_homepage_events_alter_homepage_documents.py +++ /dev/null @@ -1,85 +0,0 @@ -# Generated by Django 4.2.2 on 2023-07-18 12:41 - -import wagtail.blocks -import wagtail.documents.blocks -import wagtail.fields -from django.db import migrations - - -class Migration(migrations.Migration): - dependencies = [ - ("home", "0007_homepage_documents"), - ] - - operations = [ - migrations.AddField( - model_name="homepage", - name="events", - field=wagtail.fields.StreamField( - [ - ( - "event", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "date_ran", - wagtail.blocks.DateBlock( - label="Datum konání", required=False - ), - ), - ( - "location", - wagtail.blocks.CharBlock( - label="Lokace", required=False - ), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Události", - ), - ), - migrations.AlterField( - model_name="homepage", - name="documents", - field=wagtail.fields.StreamField( - [ - ( - "document", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "date_added", - wagtail.blocks.DateBlock( - label="Datum přidání", required=False - ), - ), - ( - "url", - wagtail.blocks.URLBlock( - label="URL (místo dokumentu)", required=False - ), - ), - ( - "file", - wagtail.documents.blocks.DocumentChooserBlock( - label="Dokument", required=False - ), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Dokumenty", - ), - ), - ] diff --git a/home/migrations/0009_alter_homepage_events.py b/home/migrations/0009_alter_homepage_events.py deleted file mode 100644 index 2c04ef13cde022dbe70d0a99234571e248efbf95..0000000000000000000000000000000000000000 --- a/home/migrations/0009_alter_homepage_events.py +++ /dev/null @@ -1,46 +0,0 @@ -# Generated by Django 4.2.2 on 2023-07-18 13:08 - -import wagtail.blocks -import wagtail.fields -from django.db import migrations - - -class Migration(migrations.Migration): - dependencies = [ - ("home", "0008_homepage_events_alter_homepage_documents"), - ] - - operations = [ - migrations.AlterField( - model_name="homepage", - name="events", - field=wagtail.fields.StreamField( - [ - ( - "event", - wagtail.blocks.StructBlock( - [ - ("name", wagtail.blocks.CharBlock(label="Jméno")), - ( - "date", - wagtail.blocks.DateBlock( - label="Datum konání", required=False - ), - ), - ( - "location", - wagtail.blocks.CharBlock( - label="Lokace", required=False - ), - ), - ] - ), - ) - ], - blank=True, - null=True, - use_json_field=True, - verbose_name="Události", - ), - ), - ] diff --git a/home/migrations/0010_homepage_heading_text.py b/home/migrations/0010_homepage_heading_text.py deleted file mode 100644 index 0cf73d44cc6ed5d683211bbd9aa11f4ddcc60353..0000000000000000000000000000000000000000 --- a/home/migrations/0010_homepage_heading_text.py +++ /dev/null @@ -1,21 +0,0 @@ -# Generated by Django 4.2.2 on 2023-07-18 13:28 - -import wagtail.fields -from django.db import migrations - - -class Migration(migrations.Migration): - dependencies = [ - ("home", "0009_alter_homepage_events"), - ] - - operations = [ - migrations.AddField( - model_name="homepage", - name="heading_text", - field=wagtail.fields.RichTextField( - default="", verbose_name="Hlavní text stránky" - ), - preserve_default=False, - ), - ] diff --git a/home/models.py b/home/models.py index 74d754bc25e4d87c2115c9e7b9078ea3596f467c..819e73b27c8b564f51c927b7b43cede26126fbf9 100644 --- a/home/models.py +++ b/home/models.py @@ -1,4 +1,5 @@ from django.db import models +from django.utils import timezone from wagtail.admin.panels import FieldPanel from wagtail.fields import RichTextField, StreamField from wagtail.models import Page @@ -82,6 +83,10 @@ class HomePage(Page): null=True, ) + subpage_types = [ + "home.HomeArticlesPage" + ] + content_panels = Page.content_panels + [ FieldPanel("heading_text", icon="pilcrow"), FieldPanel("events", icon="calendar-alt"), @@ -97,3 +102,92 @@ class HomePage(Page): FieldPanel("volunteers", icon="group"), FieldPanel("employees", icon="group"), ] + + @property + def articles_page(self) -> "HomeArticlesPage": + return ( + HomeArticlesPage + .objects + .live() + .first() + ) + + @property + def latest_articles(self): + return ( + HomeArticlePage + .objects + .live() + .all() + [:3] + ) + + +class HomeArticlesPage(Page): + content = RichTextField(verbose_name="Obsah", blank=True, null=True) + + parent_page_type = [ + "home.HomePage" + ] + subpage_types = [ + "home.HomeArticlePage" + ] + + content_panels = Page.content_panels + [ + FieldPanel("content", icon="pilcrow"), + ] + + @property + def articles(self): + return ( + HomeArticlePage + .objects + .live() + .all() + ) + + +class HomeArticlePage(Page): + tags = models.ManyToManyField( + "Tag", + verbose_name="Štítky" + ) + + author = models.CharField(verbose_name="Autor") + + date = models.DateField( + verbose_name="Datum vytvoření", + default=timezone.now + ) + + perex = models.TextField(verbose_name="Perex") + content = RichTextField(verbose_name="Obsah") + + parent_page_type = [ + "home.HomeArticlesPage" + ] + + content_panels = Page.content_panels + [ + FieldPanel("author", icon="user"), + FieldPanel("date", icon="calendar"), + FieldPanel("perex", icon="pilcrow"), + FieldPanel("content", icon="pilcrow"), + ] + + @property + def shortened_perex(self) -> str: + if len(self.perex) > 310: + return self.perex[:300] + "..." + + return self.perex + + class Meta: + ordering = ["-date"] + + +class Tag(models.Model): + name = models.CharField(verbose_name="Jméno") + + class Meta: + verbose_name = "Štítek" + verbose_name_plural = "Štítky" diff --git a/home/templates/home/blocks/document_block.html b/home/templates/home/blocks/document_block.html index 38a0358d76fe3cf5de12273b4266c9fe01fa79dc..bd3eb5e70ab7bf802ef0a8b5f984f6bd40b43dc1 100644 --- a/home/templates/home/blocks/document_block.html +++ b/home/templates/home/blocks/document_block.html @@ -1,6 +1,6 @@ <li> <a - href="{% if self.url %}{{ self.url }}{% else %}{{ self.document.url }}{% endif %}" + href="{% if self.url %}{{ self.url }}{% else %}{{ self.file.url }}{% endif %}" target="_blank" > <h3 class="font-serif leading-4"> diff --git a/home/templates/home/blocks/event_block.html b/home/templates/home/blocks/event_block.html index 1f4009aa4927eb77b4f62c8d707c93d1971b6ba2..660d32504102028adef02b5e933f530cad7e59f9 100644 --- a/home/templates/home/blocks/event_block.html +++ b/home/templates/home/blocks/event_block.html @@ -1,8 +1,18 @@ <a href="{{ self.url }}" target="_blank"> <li class="flex flex-col"> - <small class="text-pii-cyan uppercase"> - {{ self.date.day }}. {{ self.date.month }}. {{ self.date.year }} | {{ self.location }} - </small> + {% if self.date or self.location %} + <small class="text-pii-cyan uppercase"> + {% if self.date %} + {{ self.date.day }}. {{ self.date.month }}. {{ self.date.year }} + {% endif %} + {% if self.location %} + {% if self.date %} + | + {% endif %} + {{ self.location }} + {% endif %} + </small> + {% endif %} <span class="font-bold font-serif text-xl" diff --git a/home/templates/home/blocks/person_block.html b/home/templates/home/blocks/person_block.html index 81fa5af97a3ee597f19dc4733de36927e19eeed0..c651e1d96057d8556de4d67a711b4d19115f0d07 100644 --- a/home/templates/home/blocks/person_block.html +++ b/home/templates/home/blocks/person_block.html @@ -1,14 +1,19 @@ <li> <div class="flex gap-2"> - {% if self.position %} - <strong>{{ self.name }}</strong> - {% else %} - {{ self.name }} + {% if self.email %} + <a class="flex gap-2" href="mailto:{{ self.email }}"> {% endif %} + {% if self.position %} + <strong>{{ self.name }}</strong> + {% else %} + {{ self.name }} + {% endif %} + {% if self.email %} - <a href="mailto:{{ self.email }}" class="flex items-center"> - <i class="ico--at text-xl text-pii-cyan"></i> + <div class="flex items-center"> + <i class="ico--at text-xl text-pii-cyan"></i> + </div> </a> {% endif %} </div> diff --git a/home/templates/home/home_article_page.html b/home/templates/home/home_article_page.html new file mode 100644 index 0000000000000000000000000000000000000000..2a4a8039b780ae43b5c445705afbbb98e848b117 --- /dev/null +++ b/home/templates/home/home_article_page.html @@ -0,0 +1,23 @@ +{% extends "base.html" %} +{% load static wagtailcore_tags %} + +{% block content %} +<main class="flex flex-col items-center gap-10 pt-14"> + <div class="container"> + <h1 class="font-bebas text-4xl">{{ page.title }}</h1> + + <small class="flex gap-2"> + <div>{{ page.date }}</div> + {% if page.author %} + <div>| {{ page.author }}</div> + {% endif %} + </small> + + <div class="mt-5 prose max-w-screen-md font-serif"> + <p class="mb-3">{{ page.perex }}</p> + + {{ page.content|richtext }} + </div> + </div> +</main> +{% endblock content %} diff --git a/home/templates/home/home_articles_page.html b/home/templates/home/home_articles_page.html new file mode 100644 index 0000000000000000000000000000000000000000..0d0bb6ecf9aac84019a5923268d80c04e292a8c3 --- /dev/null +++ b/home/templates/home/home_articles_page.html @@ -0,0 +1,34 @@ +{% extends "base.html" %} +{% load static wagtailcore_tags %} + +{% block content %} +<main class="flex flex-col items-center gap-10 pt-14"> + <div class="container"> + <ul class="flex gap-4 lg:h-96 lg:flex-nowrap flex-wrap"> + {% for article in page.articles %} + <li class="bg-pii-cyan text-white p-7 lg:w-80"> + <a + class="flex flex-col gap-2 h-full" + href="{{ article.url }}" + > + <small class="text-pii-cyan uppercase font-bold"> + {% for tag in article.tags.all %} + {{ tag.name }} + {% endfor %} + </small> + <h3 class="font-serif text-xl leading-6 font-bold">{{ article.title }}</h3> + + <p class="font-serif leading-5 grow"> + {{ article.shortened_perex }} + </p> + + <small class="font-serif"> + Přidáno {{ article.date }} + </small> + </a> + </li> + {% endfor %} + </ul> + </div> +</main> +{% endblock content %} diff --git a/home/templates/home/home_page.html b/home/templates/home/home_page.html index fceb9dadd1b000f86690d94d3113001fc8efcb0c..1cfc5c3fd2e0af3a98e8f9a440a3d62244edf78c 100644 --- a/home/templates/home/home_page.html +++ b/home/templates/home/home_page.html @@ -2,38 +2,9 @@ {% load static wagtailcore_tags %} {% block content %} - -<nav class="bg-grey-800 py-8 flex justify-center"> - <div class="flex gap-7 container text-white items-center"> - <a - href="/" - > - <img - class="h-9" - src="{% static 'images/logo.png' %}" - alt="Logo" - > - </a> - - <div - class="w-px h-6 bg-white" - ></div> - - <div class="flex gap-4"> - <a class="nav__item" href="#uvod">Úvod</a> - <a class="nav__item" href="#aktualne">Aktuálně</a> - <a class="nav__item" href="#akce">Akce</a> - <a class="nav__item" href="#dokumenty">Dokumenty</a> - <a class="nav__item" href="#dary">Dary</a> - <a class="nav__item" href="#kontakty">Kontakty</a> - <a class="nav__item" href="#lide">Lidé</a> - </div> - </div> -</nav> - <main class="flex flex-col items-center gap-10 pt-14"> <div class="container flex gap-10"> - <figure class="w-32 flex flex-col gap-2"> + <figure class="w-32 flex-col gap-2 hidden lg:flex"> <img src="{% static 'images/logo_big.png' %}" alt="Logo" @@ -44,7 +15,7 @@ </small> </figcaption> </figure> - <section class="prose font-serif leading-6 text-black" id="uvod"> + <section class="prose font-leadingserif -6 text-black w-full max-w-full lg:max-w-prose" id="uvod"> {{ page.heading_text|richtext }} </section> </div> @@ -53,76 +24,40 @@ <div class="container flex flex-col gap-2"> <h2 class="font-bebas text-white text-3xl uppercase leading-7">Aktuálně</h2> - <ul class="flex gap-4 h-96"> - <li class="bg-white p-7 w-80"> - <a class="flex flex-col gap-2 h-full"> - <small class="text-pii-cyan uppercase font-bold">Společnost</small> - <h3 class="font-serif text-xl leading-6 font-bold">Současný stranický systém v ČR</h3> - - <p class="font-serif leading-5 grow"> - Prvního března 2023 proběhla - v Pirátském centru v Praze diskuse, - organizovaná Institutem Π - a věnovaná Pirátům na politické - mapě ČR. A to jak ve smyslu - geograficko-demografickém, tak ve - smyslu čistě politickém - </p> - - <small class="font-serif"> - Přidáno 23. srpna 2022 - </small> - </a> - </li> - - <li class="bg-white p-7 w-80"> - <a class="flex flex-col gap-2 h-full"> - <small class="text-pii-cyan uppercase font-bold">Společnost</small> - <h3 class="font-serif text-xl leading-6 font-bold">Současný stranický systém v ČR</h3> - - <p class="font-serif leading-5 grow"> - Prvního března 2023 proběhla - v Pirátském centru v Praze diskuse, - organizovaná Institutem Π - a věnovaná Pirátům na politické - mapě ČR. A to jak ve smyslu - geograficko-demografickém, tak ve - smyslu čistě politickém - </p> - - <small class="font-serif"> - Přidáno 23. srpna 2022 - </small> - </a> - </li> - - <li class="bg-white p-7 w-80"> - <a class="flex flex-col gap-2 h-full"> - <small class="text-pii-cyan uppercase font-bold">Společnost</small> - <h3 class="font-serif text-xl leading-6 font-bold">Současný stranický systém v ČR</h3> - - <p class="font-serif leading-5 grow"> - Prvního března 2023 proběhla - v Pirátském centru v Praze diskuse, - organizovaná Institutem Π - a věnovaná Pirátům na politické - mapě ČR. A to jak ve smyslu - geograficko-demografickém, tak ve - smyslu čistě politickém - </p> - - <small class="font-serif"> - Přidáno 23. srpna 2022 - </small> - </a> - </li> + <ul class="flex gap-4 lg:h-96 lg:flex-nowrap flex-wrap"> + {% for article in page.latest_articles %} + <li class="bg-white p-7 lg:w-80"> + <a + class="flex flex-col gap-2 h-full" + href="{{ article.url }}" + > + <small class="text-pii-cyan uppercase font-bold"> + {% for tag in article.tags.all %} + {{ tag.name }} + {% endfor %} + </small> + <h3 class="font-serif text-xl leading-6 font-bold">{{ article.title }}</h3> + + <p class="font-serif leading-5 grow"> + {{ article.shortened_perex }} + </p> + + <small class="font-serif"> + Přidáno {{ article.date }} + </small> + </a> + </li> + {% endfor %} </ul> <div class="mt-3"> - <button class="flex gap-2 font-bebas text-white text-2xl uppercase"> + <a + class="flex gap-2 font-bebas text-white text-2xl uppercase" + href="{{ page.articles_page.url }}" + > <i class="ico--chevron-right"></i> <div>Načíst další články</div> - </button> + </a> </div> </div> </section> @@ -136,21 +71,23 @@ {% include_block block %} {% endfor %} </div> - {% if page.events|length > 4 %} - <div class="flex flex-col gap-3 border-l-2 pl-14 border-pii-cyan"> - {% for block in page.events|slice:"4:8" %} - {% include_block block %} - {% endfor %} - </div> - {% endif %} + <div class="hidden lg:block"> + {% if page.events|length > 4 %} + <div class="flex flex-col gap-3 border-l-2 pl-14 border-pii-cyan"> + {% for block in page.events|slice:"4:8" %} + {% include_block block %} + {% endfor %} + </div> + {% endif %} + </div> </ul> </section> - <section class="flex justify-center bg-grey-50 p-10 w-full" id="dokumenty"> + <section class="flex justify-center bg-grey-50 p-10 w-full lg:flex-nowrap flex-wrap" id="dokumenty"> <div class="container flex flex-col gap-3"> <h2 class="font-bebas text-3xl uppercase leading-7">Dokumenty</h2> - <ul class="grid grid-cols-3 grid-rows-2 gap-y-3 gap-x-6 grid-flow-col"> + <ul class="flex flex-col lg:grid lg:grid-cols-3 lg:grid-rows-2 gap-y-3 gap-x-6 grid-flow-col"> {% for block in page.documents %} {% include_block block %} {% endfor %} @@ -174,7 +111,7 @@ <div class="container flex flex-col gap-3"> <h2 class="font-bebas text-3xl uppercase leading-7">Kontakty</h2> - <ul class="grid grid-cols-3 grid-rows-2 gap-y-3 grid-flow-col gap-20"> + <ul class="flex flex-col lg:grid lg:grid-cols-3 lg:grid-rows-2 lg:grid-flow-col gap-y-3 gap-x-20"> <li> <h3 class="text-pii-cyan uppercase leading-3 text-sm">Sídlo</h3> <span class="font-serif">{{ page.address }}</span> @@ -207,7 +144,7 @@ <section class="container flex flex-col gap-3" id="lide"> <h2 class="font-bebas text-3xl uppercase leading-7">Lidé</h2> - <div class="grid grid-cols-3 gap-20 min-h-screen"> + <div class="flex flex-col lg:grid lg:grid-cols-3 gap-20 min-h-screen"> <div class="flex flex-col gap-5 font-serif"> <section class="flex flex-col gap-4"> <h3 class="text-2xl font-bold">Ředitel</h3> @@ -295,7 +232,7 @@ <section class="flex flex-col gap-3 mb-16"> <h3 class="font-bold font-serif text-2xl">Zaměstnanci</h3> - <ul class="grid grid-cols-3 grid-rows-3 gap-y-2 gap-x-4 grid-flow-col font-serif"> + <ul class="flex flex-col lg:grid lg:grid-cols-3 lg:grid-rows-3 gap-y-2 gap-x-4 grid-flow-col font-serif"> <p class="leading-5"> Zaměstnanci poskytují administrativní,<br> organizační a expertní podporu pro<br> @@ -309,5 +246,4 @@ </section> </section> </main> - {% endblock content %} diff --git a/institut/templates/base.html b/institut/templates/base.html index ca4e8528c23a0e31f647c8c526e19520f7418a48..2c96891896275e309958369ea88cb9b5223a5aa0 100644 --- a/institut/templates/base.html +++ b/institut/templates/base.html @@ -41,6 +41,34 @@ <body> {% wagtailuserbar %} + <nav class="bg-grey-800 py-8 flex justify-center"> + <div class="flex gap-7 container text-white items-center"> + <a + href="/" + > + <img + class="h-9" + src="{% static 'images/logo.png' %}" + alt="Logo" + > + </a> + + <div + class="w-px h-6 bg-white hidden md:block" + ></div> + + <div class="gap-4 hidden md:flex"> + <a class="nav__item" href="/#uvod">Úvod</a> + <a class="nav__item" href="/#aktualne">Aktuálně</a> + <a class="nav__item" href="/#akce">Akce</a> + <a class="nav__item" href="/#dokumenty">Dokumenty</a> + <a class="nav__item" href="/#dary">Dary</a> + <a class="nav__item" href="/#kontakty">Kontakty</a> + <a class="nav__item" href="/#lide">Lidé</a> + </div> + </div> + </nav> + {% block content %}{% endblock %} {% block extra_js %}{% endblock %}