summaryrefslogtreecommitdiff
path: root/archaeological_files_pdl/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-01-05 15:06:12 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-01-05 15:06:12 +0100
commit2ea08e20ee52f2d6df08460536cd95224a7ae07d (patch)
treecacfd44d18db9263030377d95868122625ad0ada /archaeological_files_pdl/forms.py
parentcdfdea70ba35aa9b1d02a93896eadcdb733fdabd (diff)
parent7c0b2e7f72308ea543b9fb15e4d25b7d9b4eddb7 (diff)
downloadIshtar-2ea08e20ee52f2d6df08460536cd95224a7ae07d.tar.bz2
Ishtar-2ea08e20ee52f2d6df08460536cd95224a7ae07d.zip
Merge branch 'develop' into develop-bootstrap
Diffstat (limited to 'archaeological_files_pdl/forms.py')
-rw-r--r--archaeological_files_pdl/forms.py50
1 files changed, 34 insertions, 16 deletions
diff --git a/archaeological_files_pdl/forms.py b/archaeological_files_pdl/forms.py
index 82d6cb684..bc9b0c1e6 100644
--- a/archaeological_files_pdl/forms.py
+++ b/archaeological_files_pdl/forms.py
@@ -29,13 +29,16 @@ from ishtar_common.models import Person, Town, Department, valid_id, \
organization_type_pk_lazy
from archaeological_files import models
-from ishtar_common.forms import get_now, reverse_lazy, ManageOldType
+from ishtar_common.forms import get_now, reverse_lazy, ManageOldType, \
+ CustomForm, FieldType
from ishtar_common import widgets
-class FileFormGeneral(ManageOldType, forms.Form):
+class FileFormGeneral(CustomForm, ManageOldType, forms.Form):
form_label = _("General")
+ form_admin_name = _(u"Archaeological file - 010 - General")
+ form_slug = "file-010-general"
associated_models = {'file_type': models.FileType}
file_type = forms.ChoiceField(label=_("File type"), choices=[])
year = forms.IntegerField(label=_("Year"),
@@ -47,11 +50,9 @@ class FileFormGeneral(ManageOldType, forms.Form):
reception_date = forms.DateField(
label=_(u"Reception date"), initial=get_now, widget=widgets.JQueryDate)
- def __init__(self, *args, **kwargs):
- super(FileFormGeneral, self).__init__(*args, **kwargs)
- self.fields['file_type'].choices = models.FileType.get_types(
- initial=self.init_data.get('file_type'))
- self.fields['file_type'].help_text = models.FileType.get_help()
+ TYPES = [
+ FieldType('file_type', models.FileType),
+ ]
def clean_reception_date(self):
value = self.cleaned_data.get('reception_date', None)
@@ -61,27 +62,31 @@ class FileFormGeneral(ManageOldType, forms.Form):
return value
-class FileFormPreventiveType(ManageOldType, forms.Form):
+class FileFormPreventiveType(CustomForm, ManageOldType, forms.Form):
form_label = u"Saisine"
+ form_admin_name = _(u"Archaeological file - 013 - Preventive - Saisine")
+ form_slug = "file-013-preventivesaisine"
associated_models = {'saisine_type': models.SaisineType,
'permit_type': models.PermitType}
permit_type = forms.ChoiceField(label=_(u"Permit type"), required=False,
choices=[])
saisine_type = forms.ChoiceField(label=_(u"Saisine type"),
choices=[])
+ TYPES = [
+ FieldType('saisine_type', models.SaisineType),
+ ]
def __init__(self, *args, **kwargs):
super(FileFormPreventiveType, self).__init__(*args, **kwargs)
- self.fields['saisine_type'].choices = models.SaisineType.get_types(
- initial=self.init_data.get('saisine_type'))
- self.fields['saisine_type'].help_text = models.SaisineType.get_help()
self.fields['permit_type'].choices = models.PermitType.get_types(
default='NP', initial=self.init_data.get('permit_type'))
self.fields['permit_type'].help_text = models.PermitType.get_help()
-class FileFormPlanning(forms.Form):
+class FileFormPlanning(CustomForm, forms.Form):
form_label = _(u"Planning")
+ form_admin_name = _(u"Archaeological file - 017 - Preventive - Planning")
+ form_slug = "file-017-preventiveplanning"
base_models = ['town', 'department']
associated_models = {'town': Town, 'department': Department}
name = forms.CharField(label=_(u"Planning name"), required=False,
@@ -112,8 +117,10 @@ class FileFormPlanning(forms.Form):
validators.MaxValueValidator(999999999)])
-class FileFormResearchAddress(forms.Form):
+class FileFormResearchAddress(CustomForm, forms.Form):
form_label = _(u"Address")
+ form_admin_name = _(u"Archaeological file - 015 - Research - Address")
+ form_slug = "file-015-researchplanning"
base_models = ['town', 'department']
associated_models = {'town': Town, 'department': Department}
name = forms.CharField(label=_(u"Project name"), required=False,
@@ -228,8 +235,11 @@ class PersonOrgaForm(forms.Form):
validators=[valid_id(models.Organization)])
-class FileFormGeneralContractor(PersonOrgaForm):
+class FileFormGeneralContractor(CustomForm, PersonOrgaForm):
form_label = _(u"General contractor")
+ form_admin_name = _("Archaeological file - 030 - General contrator")
+ form_slug = "file-030-generalcontractor"
+
associated_models = {'general_contractor': models.Person,
'corporation_general_contractor': models.Organization}
corporation_general_contractor = forms.IntegerField(
@@ -323,6 +333,10 @@ class FileFormGeneralContractor(PersonOrgaForm):
if status not in ('natural', 'corporation'):
status = DEFAULT_STATUS
+ user = None
+ if 'user' in kwargs:
+ user = kwargs.pop('user')
+
super(PersonOrgaForm, self).__init__(*args, **kwargs)
# distinct widget for natural and corporation
@@ -344,8 +358,10 @@ class FileFormGeneralContractor(PersonOrgaForm):
self.fields.pop(self.ORGA_FIELD)
-class FileFormPlanningService(forms.Form):
+class FileFormPlanningService(CustomForm, forms.Form):
form_label = _(u"Planning service")
+ form_admin_name = _("Archaeological file - 040 - Planning service")
+ form_slug = "file-040-planningservice"
associated_models = {'responsible_town_planning_service': models.Person,
'planning_service': models.Organization}
@@ -387,8 +403,10 @@ class FileFormPlanningService(forms.Form):
)
-class FileFormInstruction(forms.Form):
+class FileFormInstruction(CustomForm, forms.Form):
form_label = u"Instruction SRA"
+ form_admin_name = _("Archaeological file - 050 - Instruction")
+ form_slug = "file-050-instruction"
associated_models = {'in_charge': models.Person,
'related_file': models.File}
in_charge = forms.IntegerField(