diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-12-02 12:57:43 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-12-02 12:57:43 +0100 |
commit | 9b79b24f8d598ca8f25db6832b8e31b2f7216ddd (patch) | |
tree | c8d3a53e5e3fa5d0ac63596a6788878674c1f80b /archaeological_files_pdl/forms.py | |
parent | 33d0b526ac77f63573f7b8c8f10dd22138083362 (diff) | |
download | Ishtar-9b79b24f8d598ca8f25db6832b8e31b2f7216ddd.tar.bz2 Ishtar-9b79b24f8d598ca8f25db6832b8e31b2f7216ddd.zip |
Archaeological files: fix default labels
Diffstat (limited to 'archaeological_files_pdl/forms.py')
-rw-r--r-- | archaeological_files_pdl/forms.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/archaeological_files_pdl/forms.py b/archaeological_files_pdl/forms.py index 7ada27be8..9974c184a 100644 --- a/archaeological_files_pdl/forms.py +++ b/archaeological_files_pdl/forms.py @@ -21,6 +21,7 @@ import datetime from django import forms from django.core import validators +from django.utils.functional import lazy from django.utils.safestring import mark_safe from ishtar_common.utils import ugettext_lazy as _ @@ -266,7 +267,7 @@ class FileFormGeneralContractor(CustomForm, ManageOldType): organization_type_pk_lazy('general_contractor') ] }, - tips=get_orga_general_contractor_label, + tips=lazy(get_orga_general_contractor_label), associated_model=models.Organization, new=True, detail=True, modify=True @@ -284,7 +285,7 @@ class FileFormGeneralContractor(CustomForm, ManageOldType): limit={'person_types': [ person_type_pk_lazy('general_contractor') ]}, - tips=get_general_contractor_label, + tips=lazy(get_general_contractor_label), detail=True, modify=True, new=True), @@ -300,7 +301,8 @@ class FileFormGeneralContractor(CustomForm, ManageOldType): person = models.Person.objects.get(pk=general_contractor) except models.Person.DoesNotExist: raise forms.ValidationError(_("Non existing person.")) - if person.attached_to.pk != corporation_general_contractor: + if not person.attached_to or \ + person.attached_to.pk != corporation_general_contractor: raise forms.ValidationError(_( "The organization of the person in charge differs from the " "general contractor.")) @@ -327,7 +329,7 @@ class FileFormPlanningService(CustomForm, IshtarForm): 'organization_type': [organization_type_pk_lazy(['planning_service'])], }, - tips=get_orga_planning_service_label, + tips=lazy(get_orga_planning_service_label), new=True, detail=True, modify=True, @@ -347,7 +349,7 @@ class FileFormPlanningService(CustomForm, IshtarForm): person_type_pk_lazy('responsible_planning_service') ]}, dynamic_limit=['planning_service'], - tips=get_responsible_planning_service_label, + tips=lazy(get_responsible_planning_service_label), detail=True, modify=True, new=True), @@ -364,7 +366,7 @@ class FileFormPlanningService(CustomForm, IshtarForm): person = models.Person.objects.get(pk=responsible) except models.Person.DoesNotExist: raise forms.ValidationError(_("Non existing person.")) - if person.attached_to.pk != orga: + if not person.attached_to or person.attached_to.pk != orga: raise forms.ValidationError(_( "The organization of the person in charge differs from the " "planning service.")) @@ -388,7 +390,7 @@ class FileFormInstruction(CustomForm, IshtarForm): 'person_types': [ person_type_pk_lazy('sra_agent')] }, - tips=get_sra_agent_label, + tips=lazy(get_sra_agent_label), associated_model=Person, new=True, ), validators=[valid_id(Person)]) |