diff --git a/senate/migrations/0004_senatehomepage_candidates_second_round.py b/senate/migrations/0004_senatehomepage_candidates_second_round.py new file mode 100644 index 0000000000000000000000000000000000000000..883447fcaff27b853b60764acdf74d7c9861b0db --- /dev/null +++ b/senate/migrations/0004_senatehomepage_candidates_second_round.py @@ -0,0 +1,68 @@ +# Generated by Django 3.1.1 on 2020-10-06 09:21 + +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.images.blocks +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("senate", "0003_auto_20200702_1831"), + ] + + operations = [ + migrations.AddField( + model_name="senatehomepage", + name="candidates_second_round", + field=wagtail.core.fields.StreamField( + [ + ( + "item", + wagtail.core.blocks.StructBlock( + [ + ("name", wagtail.core.blocks.CharBlock(label="jméno")), + ( + "district", + wagtail.core.blocks.CharBlock(label="obvod"), + ), + ( + "info", + wagtail.core.blocks.CharBlock( + label="info o nominaci" + ), + ), + ( + "phone", + wagtail.core.blocks.CharBlock( + label="telefon", required=False + ), + ), + ( + "email", + wagtail.core.blocks.EmailBlock( + label="email", required=False + ), + ), + ( + "web", + wagtail.core.blocks.URLBlock( + label="web", required=False + ), + ), + ( + "photo", + wagtail.images.blocks.ImageChooserBlock( + label="fotka" + ), + ), + ] + ), + ) + ], + blank=True, + verbose_name="kandidáti do 2. kola", + ), + ), + ] diff --git a/senate/models.py b/senate/models.py index 7e21a67247c31bc9edd0b4f4aa2c06fc24db3d4f..7dea69db01b86ec5ca64dbed8ee4b95ca365dbff 100644 --- a/senate/models.py +++ b/senate/models.py @@ -39,6 +39,9 @@ class SenateHomePage(MetadataPageMixin, Page): candidates = StreamField( [("item", PersonBlock())], verbose_name="kandidáti", blank=True ) + candidates_second_round = StreamField( + [("item", PersonBlock())], verbose_name="kandidáti do 2. kola", blank=True + ) matomo_id = models.IntegerField( "Matomo ID pro sledování návštěvnosti", blank=True, null=True ) @@ -48,6 +51,7 @@ class SenateHomePage(MetadataPageMixin, Page): content_panels = Page.content_panels + [ StreamFieldPanel("senators"), StreamFieldPanel("candidates"), + StreamFieldPanel("candidates_second_round"), ] promote_panels = [ diff --git a/senate/templates/senate/senate_home_page.html b/senate/templates/senate/senate_home_page.html index be3dba3f813bdaa64f2bb9f85e41ede3c9581a76..7069d5ac9c4829c00b9140221ff546d17fff5a6b 100644 --- a/senate/templates/senate/senate_home_page.html +++ b/senate/templates/senate/senate_home_page.html @@ -8,24 +8,37 @@ <div class="container my-5"> <div class="row"> <div class="col-lg-12"> - <h2 class="headline-normal">Kandidáti do Senátu</h2> - <div class="row"> - {% for person in page.candidates %} - {% include "senate/person_snippet.html" %} - {% endfor %} - </div> + {% if page.candidates_second_round %} + <h2 class="headline-normal">Kandidáti postupující do 2. kola senátních voleb</h2> + <div class="row"> + {% for person in page.candidates_second_round %} + {% include "senate/person_snippet.html" %} + {% endfor %} + </div> + <hr class="my-4"> + {% endif %} - <hr class="my-4"> - <h2 class="headline-normal">Naši Senátoři</h2> + {% if page.candidates %} + <h2 class="headline-normal">Kandidáti do Senátu</h2> + <div class="row"> + {% for person in page.candidates %} + {% include "senate/person_snippet.html" %} + {% endfor %} + </div> + <hr class="my-4"> + {% endif %} - <div class="row"> - {% for person in page.senators %} - {% include "senate/person_snippet.html" %} - {% endfor %} - </div> + {% if page.senators %} + <h2 class="headline-normal">Naši Senátoři</h2> + <div class="row"> + {% for person in page.senators %} + {% include "senate/person_snippet.html" %} + {% endfor %} + </div> + <hr class="my-4"> + {% endif %} - <hr class="my-4"> </div> </div> </div>