From 0fb6a394915591ac828c364bffe40e01419e4c5e Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 17 Mar 2025 19:40:24 +0100 Subject: ✨ administrative act: intented to is now many (refs #6210) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- archaeological_operations/forms.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'archaeological_operations/forms.py') diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index a5c9d5b1b..72d2eaf35 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -1497,9 +1497,9 @@ class AdministrativeActOpeSelect(DocumentItemSelect): def __init__(self, *args, **kwargs): super(AdministrativeActOpeSelect, self).__init__(*args, **kwargs) self.fields['act_type'].choices = models.ActType.get_types( - dct={'intented_to': 'O'}) + dct={"intented_to_operation": True}) self.fields['act_type'].help_text = models.ActType.get_help( - dct={'intented_to': 'O'}) + dct={"intented_to_operation": True}) if settings.ISHTAR_DPTS: k = 'operation__towns__numero_insee__startswith' self.fields[k].choices = [ @@ -1546,7 +1546,7 @@ class AdministrativeActForm(CustomForm, ManageOldType): TYPES = [ FieldType('act_type', models.ActType, - extra_args={"dct": {'intented_to': 'O'}}), + extra_args={"dct": {"intented_to_operation": True}}), ] @@ -1617,10 +1617,19 @@ class DocumentGenerationAdminActForm(IshtarForm): if 'obj' in kwargs: self.obj = kwargs.pop('obj') super(DocumentGenerationAdminActForm, self).__init__(*args, **kwargs) + filtr = { + 'associated_model__klass': 'archaeological_operations.models.AdministrativeAct', + } + if self.document_type == "O": + filtr["acttypes__intented_to_operation"] = True + elif self.document_type == "F": + filtr["acttypes__intented_to_file"] = True + elif self.document_type == "T": + filtr["acttypes__intented_to_treatment"] = True + elif self.document_type == "TF": + filtr["acttypes__intented_to_treatment_request"] = True self.fields['document_template'].choices = DocumentTemplate.get_tuples( - dct={'associated_model__klass': - 'archaeological_operations.models.AdministrativeAct', - 'acttypes__intented_to': self.document_type}) + dct=filtr) def clean(self): if not self.obj: -- cgit v1.2.3