diff --git a/district/migrations/0056_alter_districtprogrampage_content.py b/district/migrations/0056_alter_districtprogrampage_content.py new file mode 100644 index 0000000000000000000000000000000000000000..5f3f8304ff1f4ceda9d2b60cc6936859ee742b3e --- /dev/null +++ b/district/migrations/0056_alter_districtprogrampage_content.py @@ -0,0 +1,159 @@ +# Generated by Django 4.0.3 on 2022-04-21 09:25 + +import wagtail.core.blocks +import wagtail.core.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("district", "0055_alter_districtarticlepage_content_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="districtprogrampage", + name="content", + field=wagtail.core.fields.StreamField( + [ + ( + "static_program_block", + wagtail.core.blocks.StructBlock( + [ + ( + "headline", + wagtail.core.blocks.CharBlock( + label="Titulek bloku", required=True + ), + ), + ( + "perex", + wagtail.core.blocks.TextBlock( + label="Krátký text pod nadpisem", required=True + ), + ), + ( + "person", + wagtail.core.blocks.PageChooserBlock( + label="Garant", + page_type=["district.DistrictPersonPage"], + ), + ), + ( + "completion_percentage", + wagtail.core.blocks.IntegerBlock( + label="Procento dokončení", required=True + ), + ), + ( + "program_items", + wagtail.core.blocks.ListBlock( + wagtail.core.blocks.StructBlock( + [ + ( + "title", + wagtail.core.blocks.CharBlock( + label="Název", required=True + ), + ), + ( + "completion_percentage", + wagtail.core.blocks.IntegerBlock( + label="Procento dokončení", + required=True, + ), + ), + ( + "issue_link", + wagtail.core.blocks.URLBlock( + label="Odkaz na Redmine issue", + required=False, + ), + ), + ] + ), + label="Seznam bodů", + ), + ), + ] + ), + ), + ( + "redmine_program_block", + wagtail.core.blocks.StructBlock( + [ + ( + "headline", + wagtail.core.blocks.CharBlock( + label="Titulek bloku", required=True + ), + ), + ( + "perex", + wagtail.core.blocks.TextBlock( + label="Krátký text pod nadpisem", required=True + ), + ), + ( + "person", + wagtail.core.blocks.PageChooserBlock( + label="Garant", + page_type=["district.DistrictPersonPage"], + ), + ), + ( + "redmine_issue", + wagtail.core.blocks.IntegerBlock( + label="Číslo Redmine issue", required=True + ), + ), + ( + "completion_percentage", + wagtail.core.blocks.IntegerBlock( + help_text="Hodnota se automaticky načte s Redmine", + label="Procento dokončení - bude doplněno automaticky", + required=False, + ), + ), + ( + "program_items", + wagtail.core.blocks.ListBlock( + wagtail.core.blocks.StructBlock( + [ + ( + "title", + wagtail.core.blocks.CharBlock( + label="Název", required=True + ), + ), + ( + "completion_percentage", + wagtail.core.blocks.IntegerBlock( + label="Procento dokončení", + required=True, + ), + ), + ( + "issue_link", + wagtail.core.blocks.URLBlock( + label="Odkaz na Redmine issue", + required=False, + ), + ), + ] + ), + help_text="Hodnota se automaticky načte s Redmine", + label="Seznam bodů - bude doplněno automaticky", + required=False, + ), + ), + ] + ), + ), + ], + blank=True, + verbose_name="obsah stránky", + ), + ), + ] diff --git a/district/templates/district/blocks/program_block.html b/district/templates/district/blocks/program_block.html index caf0108a0f838d8b40bd437980b1e4e6f70eea51..ecffe0b8c95e6861b3b26ea5525ad9c471c673e1 100644 --- a/district/templates/district/blocks/program_block.html +++ b/district/templates/district/blocks/program_block.html @@ -18,10 +18,17 @@ <div class="content-block"> <div class="space-y-4 mt-8"> <div> - <a href="https://redmine.pirati.cz/issues/28177" class="contact-line icon-link content-block--nostyle"> - <i class="ico--info"></i> - <span>Plnění programu: {{ self.completion_percentage | default_if_none:'' }}%</span> - </a> + {% if self.redmine_issue %} + <a href="https://redmine.pirati.cz/issues/{{ self.redmine_issue }}" class="contact-line icon-link content-block--nostyle"> + <i class="ico--info"></i> + <span>Plnění programu: {{ self.completion_percentage | default_if_none:'' }}%</span> + </a> + {% else %} + <span class="contact-line content-block--nostyle"> + <i class="ico--info"></i> + <span>Plnění programu: {{ self.completion_percentage | default_if_none:'' }}%</span> + </span> + {% endif %} </div> </div> </div> @@ -42,9 +49,15 @@ {% for item in self.program_items %} <tr> <td> - <a href="{{ item.issue_link }}" target="_blank"> - {{ item.title | default_if_none:'' }} - </a> + {% if item.issue_link %} + <a href="{{ item.issue_link }}" target="_blank"> + {{ item.title | default_if_none:'' }} + </a> + {% else %} + <span> + {{ item.title | default_if_none:'' }} + </span> + {% endif %} </td> <td>{{ item.completion_percentage | default_if_none:'' }} %</td> </tr> diff --git a/redmine_utils/functions.py b/redmine_utils/functions.py index f4e12ec890f5bf46324daba4a75a07d63893ef34..b7e2ae62dbc0d6f1de0ba7164191b5300bf665d8 100644 --- a/redmine_utils/functions.py +++ b/redmine_utils/functions.py @@ -40,6 +40,9 @@ def fill_program_items_from_redmine(program_block_value: dict, issue_id: int): { "completion_percentage": issue.get("done_ratio", None), "title": issue.get("subject", ""), + "issue_link": "https://redmine.pirati.cz/issues/{}".format( + issue.get("id", "") + ), } ) program_block_value["program_items"].append(sv) diff --git a/region/migrations/0031_alter_regionprogrampage_content.py b/region/migrations/0031_alter_regionprogrampage_content.py new file mode 100644 index 0000000000000000000000000000000000000000..702e1582b9b14f1b2ed7081de5066014cc4ef326 --- /dev/null +++ b/region/migrations/0031_alter_regionprogrampage_content.py @@ -0,0 +1,159 @@ +# Generated by Django 4.0.3 on 2022-04-21 09:25 + +import wagtail.core.blocks +import wagtail.core.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("region", "0030_alter_regionarticlepage_content_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="regionprogrampage", + name="content", + field=wagtail.core.fields.StreamField( + [ + ( + "static_program_block", + wagtail.core.blocks.StructBlock( + [ + ( + "headline", + wagtail.core.blocks.CharBlock( + label="Titulek bloku", required=True + ), + ), + ( + "perex", + wagtail.core.blocks.TextBlock( + label="Krátký text pod nadpisem", required=True + ), + ), + ( + "person", + wagtail.core.blocks.PageChooserBlock( + label="Garant", + page_type=["region.RegionPersonPage"], + ), + ), + ( + "completion_percentage", + wagtail.core.blocks.IntegerBlock( + label="Procento dokončení", required=True + ), + ), + ( + "program_items", + wagtail.core.blocks.ListBlock( + wagtail.core.blocks.StructBlock( + [ + ( + "title", + wagtail.core.blocks.CharBlock( + label="Název", required=True + ), + ), + ( + "completion_percentage", + wagtail.core.blocks.IntegerBlock( + label="Procento dokončení", + required=True, + ), + ), + ( + "issue_link", + wagtail.core.blocks.URLBlock( + label="Odkaz na Redmine issue", + required=False, + ), + ), + ] + ), + label="Seznam bodů", + ), + ), + ] + ), + ), + ( + "redmine_program_block", + wagtail.core.blocks.StructBlock( + [ + ( + "headline", + wagtail.core.blocks.CharBlock( + label="Titulek bloku", required=True + ), + ), + ( + "perex", + wagtail.core.blocks.TextBlock( + label="Krátký text pod nadpisem", required=True + ), + ), + ( + "person", + wagtail.core.blocks.PageChooserBlock( + label="Garant", + page_type=["region.RegionPersonPage"], + ), + ), + ( + "redmine_issue", + wagtail.core.blocks.IntegerBlock( + label="Číslo Redmine issue", required=True + ), + ), + ( + "completion_percentage", + wagtail.core.blocks.IntegerBlock( + help_text="Hodnota se automaticky načte s Redmine", + label="Procento dokončení - bude doplněno automaticky", + required=False, + ), + ), + ( + "program_items", + wagtail.core.blocks.ListBlock( + wagtail.core.blocks.StructBlock( + [ + ( + "title", + wagtail.core.blocks.CharBlock( + label="Název", required=True + ), + ), + ( + "completion_percentage", + wagtail.core.blocks.IntegerBlock( + label="Procento dokončení", + required=True, + ), + ), + ( + "issue_link", + wagtail.core.blocks.URLBlock( + label="Odkaz na Redmine issue", + required=False, + ), + ), + ] + ), + help_text="Hodnota se automaticky načte s Redmine", + label="Seznam bodů - bude doplněno automaticky", + required=False, + ), + ), + ] + ), + ), + ], + blank=True, + verbose_name="obsah stránky", + ), + ), + ] diff --git a/shared/blocks.py b/shared/blocks.py index ecb3382a18e0cd4028ff2e4c8757860b955a809f..4a3ba423329820af96f9a0595c19af0faab977df 100644 --- a/shared/blocks.py +++ b/shared/blocks.py @@ -63,6 +63,7 @@ class ProgramItemBlock(blocks.StructBlock): completion_percentage = blocks.IntegerBlock( label="Procento dokončení", required=True ) + issue_link = blocks.URLBlock(label="Odkaz na Redmine issue", required=False) class YouTubeVideoBlock(blocks.StructBlock):