diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2014-12-22 12:55:56 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-05-06 15:34:36 +0200 |
commit | 16fbb32b8ba00325a7b813825f288cb097699c98 (patch) | |
tree | 0d369c66f0fb06db3d99e55523623468db02d619 /archaeological_files_pdl | |
parent | 6dfd3fcc84950ac8a86824fad7b0e9acb407091e (diff) | |
download | Ishtar-16fbb32b8ba00325a7b813825f288cb097699c98.tar.bz2 Ishtar-16fbb32b8ba00325a7b813825f288cb097699c98.zip |
Workon alternate administrativ wizard
* reorganization of address fields
* add a main town field
* reorganize parcel wizard
* workon new administrativ wizard
Diffstat (limited to 'archaeological_files_pdl')
-rw-r--r-- | archaeological_files_pdl/forms.py | 44 | ||||
-rw-r--r-- | archaeological_files_pdl/views.py | 21 | ||||
-rw-r--r-- | archaeological_files_pdl/wizards.py | 27 |
3 files changed, 80 insertions, 12 deletions
diff --git a/archaeological_files_pdl/forms.py b/archaeological_files_pdl/forms.py index 87221f24c..aedf60ba1 100644 --- a/archaeological_files_pdl/forms.py +++ b/archaeological_files_pdl/forms.py @@ -27,14 +27,13 @@ from ishtar_common.models import Person from archaeological_files import models from ishtar_common.forms import get_now +from ishtar_common.forms_common import get_town_field from ishtar_common import widgets class FileFormGeneral(forms.Form): form_label = _("General") - associated_models = {'in_charge':Person, - 'related_file':models.File, - 'file_type':models.FileType} + associated_models = {'file_type':models.FileType} file_type = forms.ChoiceField(label=_("File type"), choices=[]) year = forms.IntegerField(label=_("Year"), initial=lambda:datetime.datetime.now().year, @@ -49,3 +48,42 @@ class FileFormGeneral(forms.Form): super(FileFormGeneral, self).__init__(*args, **kwargs) self.fields['file_type'].choices = models.FileType.get_types() self.fields['file_type'].help_text = models.FileType.get_help() + +class FileFormPreventiveType(forms.Form): + form_label = u"Saisine" + 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=[]) + def __init__(self, *args, **kwargs): + super(FileFormPreventiveType, self).__init__(*args, **kwargs) + self.fields['saisine_type'].choices = models.SaisineType.get_types() + self.fields['saisine_type'].help_text = models.SaisineType.get_help() + self.fields['permit_type'].choices = models.PermitType.get_types( + default='NP') + self.fields['permit_type'].help_text = models.PermitType.get_help() + + +class FileFormPlanning(forms.Form): + form_label = _(u"Planning") + associated_models = {'town':models.Town} + name = forms.CharField(label=_(u"Planning name"), required=False, + max_length=100) + main_town = get_town_field(required=False) + locality = forms.CharField(label=_(u"Locality"), max_length=100, + required=False) + address = forms.CharField(label=_(u"Address (number/street)"), + widget=forms.Textarea, required=False) + postal_code = forms.CharField(label=_(u"Postal code"), max_length=10, + required=False) + total_surface = forms.IntegerField(required=False, + widget=widgets.AreaWidget, + label=_(u"Total surface (m²)"), + validators=[validators.MinValueValidator(0), + validators.MaxValueValidator(999999999)]) + total_developed_surface = forms.IntegerField(widget=widgets.AreaWidget, + label=_(u"Total developed surface (m²)"), + required=False, validators=[validators.MinValueValidator(0), + validators.MaxValueValidator(999999999)]) diff --git a/archaeological_files_pdl/views.py b/archaeological_files_pdl/views.py index 7d51c8ec5..1dd69b50c 100644 --- a/archaeological_files_pdl/views.py +++ b/archaeological_files_pdl/views.py @@ -19,10 +19,9 @@ from django.utils.translation import ugettext_lazy as _ -from archaeological_files.wizards import FileWizard +from archaeological_files_pdl.wizards import FileWizard from archaeological_operations.wizards import is_preventive, is_not_preventive -from ishtar_common.forms_common import TownFormset from archaeological_files_pdl import forms from archaeological_files import forms as ref_forms from archaeological_operations.forms import ParcelFormSet @@ -30,16 +29,20 @@ from archaeological_operations.forms import ParcelFormSet from archaeological_files import models file_creation_wizard = FileWizard.as_view([ - ('general-file_creation', forms.FileFormGeneral), - ('towns-file_creation', TownFormset), - ('parcels-file_creation', ParcelFormSet), - ('preventive-file_creation', ref_forms.FileFormPreventive), - ('research-file_creation', ref_forms.FileFormResearch), - ('final-file_creation', ref_forms.FinalForm)], + ('general-file_creation', forms.FileFormGeneral), + ('preventivetype-file_creation', forms.FileFormPreventiveType), + ('preventiveplanning-file_creation', forms.FileFormPlanning), + ('parcelspdl-file_creation', ParcelFormSet), + ('preventive-file_creation', ref_forms.FileFormPreventive), + ('research-file_creation', ref_forms.FileFormResearch), + ('final-file_creation', ref_forms.FinalForm)], label=_(u"New file"), condition_dict={ + 'preventivetype-file_creation':\ + is_preventive('general-file_creation', models.FileType, + type_key='file_type'), 'preventive-file_creation':\ - is_preventive( 'general-file_creation', models.FileType, + is_preventive('general-file_creation', models.FileType, type_key='file_type'), 'research-file_creation':\ is_not_preventive('general-file_creation', models.FileType, diff --git a/archaeological_files_pdl/wizards.py b/archaeological_files_pdl/wizards.py new file mode 100644 index 000000000..679b0823f --- /dev/null +++ b/archaeological_files_pdl/wizards.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (C) 2014 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# See the file COPYING for details. + +from archaeological_files.wizards import FileWizard as BaseFileWizard + +class FileWizard(BaseFileWizard): + parcel_step_key = 'parcelspdl-' + town_step_key = 'preventiveplanning-' + town_input_id = 'main_town' + multi_towns = False + |