diff --git a/contracts/admin.py b/contracts/admin.py index 22e0dd8bafbf988fa3ed1fa71a8a037306759157..e2bb97cae131f3988964e04399cb87660127a4bb 100644 --- a/contracts/admin.py +++ b/contracts/admin.py @@ -240,6 +240,7 @@ class ContractAdmin( { "fields": [ "paper_form_state", + "paper_form_person_responsible", "filing_area", ] }, diff --git a/contracts/migrations/0062_contract_paper_form_person_responsible.py b/contracts/migrations/0062_contract_paper_form_person_responsible.py new file mode 100644 index 0000000000000000000000000000000000000000..c73e9cc47cea36375525bec36e908df843f4ed65 --- /dev/null +++ b/contracts/migrations/0062_contract_paper_form_person_responsible.py @@ -0,0 +1,18 @@ +# Generated by Django 4.1.4 on 2023-06-06 17:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('contracts', '0061_alter_contract_id_number'), + ] + + operations = [ + migrations.AddField( + model_name='contract', + name='paper_form_person_responsible', + field=models.CharField(blank=True, max_length=256, null=True, verbose_name='Osoba zodpovědná za doručení'), + ), + ] diff --git a/contracts/models.py b/contracts/models.py index e717261023e8ecbae4ecdf699444289b14bf8782..6e4a7a5bb4cfb2050d709be4e6eada49fef2c843 100644 --- a/contracts/models.py +++ b/contracts/models.py @@ -592,6 +592,13 @@ class Contract(NameStrMixin, models.Model): verbose_name="Stav fyzického dokumentu", ) + paper_form_person_responsible = models.CharField( + max_length=256, + blank=True, + null=True, + verbose_name="Osoba zodpovědná za doručení", + ) + tender_url = SubdomainValidatedURLField( max_length=256, blank=True, @@ -739,6 +746,22 @@ class Contract(NameStrMixin, models.Model): } ) + if ( + self.paper_form_state not in ( + self.PaperFormStates.STORED, + self.PaperFormStates.SHREDDED, + self.PaperFormStates.LOST + ) + and not self.paper_form_person_responsible + ): + raise ValidationError( + { + "paper_form_person_responsible": ( + "Musí být vyplněno, pokud smlouva není uložená / skartovaná / ztracená." + ) + } + ) + if ( self.valid_start_date and self.valid_end_date diff --git a/contracts/templates/contracts/includes/pagination.html b/contracts/templates/contracts/includes/pagination.html index d562a598a632a6e233b88da1e4bdcb946b8ea7e4..44789bf9b884fdb18b7dcd7825f90fd4efaff6a5 100644 --- a/contracts/templates/contracts/includes/pagination.html +++ b/contracts/templates/contracts/includes/pagination.html @@ -25,7 +25,7 @@ </a> {% endif %} - {% if page.has_previous and page.previous_page_number != 2 %} + {% if page.has_previous and page.previous_page_number > 2 %} <span class="text-grey-500 hidden md:flex flex-col px-2 justify-center">...</span> {% endif %} diff --git a/contracts/templates/contracts/view_contract.html b/contracts/templates/contracts/view_contract.html index 99e3b1c79cdd65f95a5471352a2e21582f9ab36c..5dd22bbece2f734c4a4c7da89c1c76df4a16965b 100644 --- a/contracts/templates/contracts/view_contract.html +++ b/contracts/templates/contracts/view_contract.html @@ -173,7 +173,13 @@ <tr> <td class="w-1/5 !p-2.5">Stav</td> - <td class="w-4/5 !p-2.5">{{ contract.get_paper_form_state_display }}</td> + <td class="w-4/5 !p-2.5"> + {{ contract.get_paper_form_state_display }} + + {% if contract.paper_form_person_responsible %} + (zodpovídá {{ contract.paper_form_person_responsible }}) + {% endif %} + </td> </tr> <tr> <td class="w-1/5 !p-2.5">Spisovna</td> diff --git a/registry/settings/base.py b/registry/settings/base.py index 8755276a36ebacca4e2e513a808b93bda53978f9..4a468c34cdcf4807397d4929536cc5347e76cd32 100644 --- a/registry/settings/base.py +++ b/registry/settings/base.py @@ -16,7 +16,6 @@ import pathlib import dj_database_url import environ import sentry_sdk - from sentry_sdk.integrations.django import DjangoIntegration # Build paths inside the project like this: BASE_DIR / 'subdir'. diff --git a/static_src/admin/contract_form.js b/static_src/admin/contract_form.js index dde148dc679cb5aae89770357e8c4dfd46372ba2..b4e91ab19566e00bb18f471fa2441bb2d47f7721 100644 --- a/static_src/admin/contract_form.js +++ b/static_src/admin/contract_form.js @@ -36,7 +36,21 @@ $(window).ready( ($("#id_cost_unit").find(":selected").val() === "other") ? "block": "none" ) - ) + ); + + $(".field-paper_form_person_responsible"). + css( + "display", + ( + ( + !["stored", "shredded"].includes( + $("#id_paper_form_state").find(":selected").val() + ) + ) ? + "block" : "none" + ) + ); + $("#id_cost_unit").on( "change", @@ -55,5 +69,29 @@ $(window).ready( if (!otherIsSelected) $(".field-cost_unit_other").val(""); } ); + + $("#id_paper_form_state").on( + "change", + event => { + const notStoredOrShredded = ( + !["stored", "shredded", "lost"].includes( + $(event.target).find(":selected").val() + ) + ); + + $(".field-paper_form_person_responsible"). + css( + "display", + ( + (notStoredOrShredded) ? + "block" : "none" + ) + ); + + if (!notStoredOrShredded) { + $("#id_paper_form_person_responsible").val(""); + } + } + ); } );