summaryrefslogtreecommitdiff
path: root/archaeological_files_pdl/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_files_pdl/forms.py')
-rw-r--r--archaeological_files_pdl/forms.py54
1 files changed, 32 insertions, 22 deletions
diff --git a/archaeological_files_pdl/forms.py b/archaeological_files_pdl/forms.py
index 99dc97137..5c92f689a 100644
--- a/archaeological_files_pdl/forms.py
+++ b/archaeological_files_pdl/forms.py
@@ -24,15 +24,12 @@ from django.core import validators
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
-from ishtar_common.models import Person, Town, Department, valid_id
+from ishtar_common.models import Person, Town, Department, valid_id, \
+ person_type_pk_lazy, person_type_pks_lazy, organization_type_pks_lazy, \
+ organization_type_pk_lazy, organization_type_lazy, person_type_lazy
from archaeological_files import models
from ishtar_common.forms import get_now, reverse_lazy, ManageOldType
-from archaeological_files.forms import GENERAL_CONTRACTOR, \
- GENERAL_CONTRACTOR_ORGA, RESPONSIBLE_PLANNING_SERVICE, \
- RESPONSIBLE_PLANNING_SERVICE_ORGA
-
-from archaeological_operations.forms import SRA_AGENT
from ishtar_common import widgets
@@ -135,10 +132,10 @@ class FileFormResearchAddress(forms.Form):
class PersonOrgaForm(forms.Form):
PERSON_FIELD = 'TO BE DEFINED'
- PERSON_TYPE = GENERAL_CONTRACTOR
+ PERSON_TYPE = person_type_lazy('general_contractor')
PERSON_LABEL = ""
ORGA_FIELD = 'TO BE DEFINED'
- ORGA_TYPE = GENERAL_CONTRACTOR_ORGA
+ ORGA_TYPE = organization_type_lazy('general_contractor')
ORGA_LABEL = ""
def _media(self):
@@ -238,12 +235,15 @@ class FileFormGeneralContractor(PersonOrgaForm):
required=False,
widget=widgets.JQueryPersonOrganization(
reverse_lazy('autocomplete-organization',
- args=[GENERAL_CONTRACTOR_ORGA.pk]),
+ args=[
+ organization_type_pks_lazy(['general_contractor'])]
+ ),
reverse_lazy('organization_create'),
model=models.Organization,
limit={
- 'organization_type': [GENERAL_CONTRACTOR_ORGA.pk]
- },
+ 'organization_type': [
+ organization_type_pk_lazy('general_contractor')
+ ]},
js_template='ishtar/blocks/JQueryCorporationPerson.js',
new=True),
validators=[valid_id(models.Organization)]
@@ -253,9 +253,13 @@ class FileFormGeneralContractor(PersonOrgaForm):
required=False,
widget=widgets.JQueryAutoComplete(
reverse_lazy('autocomplete-person',
- args=[GENERAL_CONTRACTOR.pk]),
+ args=[
+ person_type_pks_lazy(['general_contractor'])
+ ]),
associated_model=Person,
- limit={'person_types': [GENERAL_CONTRACTOR.pk]},
+ limit={'person_types': [
+ person_type_pk_lazy(['general_contractor'])
+ ]},
dynamic_limit=['general_contractor'],
url_new='new-person-noorga',
new=True),
@@ -263,10 +267,10 @@ class FileFormGeneralContractor(PersonOrgaForm):
)
PERSON_FIELD = 'general_contractor'
- PERSON_TYPE = GENERAL_CONTRACTOR
+ PERSON_TYPE = person_type_lazy('general_contractor')
PERSON_LABEL = _(u"General contractor")
ORGA_FIELD = 'corporation_general_contractor'
- ORGA_TYPE = GENERAL_CONTRACTOR_ORGA
+ ORGA_TYPE = organization_type_lazy('general_contractor')
ORGA_LABEL = _(u"General contractor")
def __init__(self, *args, **kwargs):
@@ -349,12 +353,14 @@ class FileFormPlanningService(forms.Form):
label=_("Planning service"),
required=False,
widget=widgets.JQueryPersonOrganization(
- reverse_lazy('autocomplete-organization',
- args=[RESPONSIBLE_PLANNING_SERVICE_ORGA.pk]),
+ reverse_lazy(
+ 'autocomplete-organization',
+ args=[organization_type_pks_lazy(['planning_service'])]),
reverse_lazy('organization_create'),
model=models.Organization,
limit={
- 'organization_type': [RESPONSIBLE_PLANNING_SERVICE_ORGA.pk]
+ 'organization_type':
+ [organization_type_pk_lazy(['planning_service'])],
},
js_template='ishtar/blocks/JQueryCorporationPerson.js',
new=True),
@@ -365,9 +371,13 @@ class FileFormPlanningService(forms.Form):
required=False,
widget=widgets.JQueryAutoComplete(
reverse_lazy('autocomplete-person',
- args=[RESPONSIBLE_PLANNING_SERVICE.pk]),
+ args=[
+ person_type_pks_lazy(
+ ['responsible_planning_service'])]),
associated_model=Person,
- limit={'person_types': [RESPONSIBLE_PLANNING_SERVICE.pk]},
+ limit={'person_types': [
+ person_type_pk_lazy('responsible_planning_service')
+ ]},
dynamic_limit=['planning_service'],
url_new='new-person-noorga',
new=True),
@@ -384,10 +394,10 @@ class FileFormInstruction(forms.Form):
widget=widgets.JQueryAutoComplete(
reverse_lazy(
'autocomplete-person',
- args=[SRA_AGENT.pk]),
+ args=[person_type_pks_lazy(["sra_agent"])]),
limit={
'person_types': [
- SRA_AGENT.pk]
+ person_type_pk_lazy('sra_agent')]
},
associated_model=Person, new=True),
validators=[valid_id(Person)])