diff options
Diffstat (limited to 'archaeological_files_pdl')
-rw-r--r-- | archaeological_files_pdl/forms.py | 43 | ||||
-rw-r--r-- | archaeological_files_pdl/templates/ishtar/wizard/wizard_planningservice.html | 38 | ||||
-rw-r--r-- | archaeological_files_pdl/views.py | 114 | ||||
-rw-r--r-- | archaeological_files_pdl/wizards.py | 3 |
4 files changed, 119 insertions, 79 deletions
diff --git a/archaeological_files_pdl/forms.py b/archaeological_files_pdl/forms.py index 393f53b8c..a0c5037e7 100644 --- a/archaeological_files_pdl/forms.py +++ b/archaeological_files_pdl/forms.py @@ -230,25 +230,44 @@ class FileFormGeneralContractor(PersonOrgaForm): label=" ", widget=forms.HiddenInput, required=False) -class FileFormPlanningService(PersonOrgaForm): +class FileFormPlanningService(forms.Form): form_label = _(u"Town planning service") associated_models = {'responsible_town_planning_service': models.Person, 'planning_service': models.Organization} reference_number = forms.IntegerField(label=_(u"File reference"), required=False) - PERSON_FIELD = 'responsible_town_planning_service' - PERSON_TYPE = RESPONSIBLE_PLANNING_SERVICE - PERSON_LABEL = _(u"Responsible town planning service") - ORGA_FIELD = 'planning_service' - ORGA_TYPE = RESPONSIBLE_PLANNING_SERVICE_ORGA - ORGA_LABEL = _(u"Planning service") - - # default initialisation before dynamic + planning_service = forms.IntegerField( + label=_("Planning service"), + required=False, + widget=widgets.JQueryAutoComplete( + reverse_lazy('autocomplete-organization', + args=[RESPONSIBLE_PLANNING_SERVICE_ORGA.pk]), + limit={ + 'organization_type': [RESPONSIBLE_PLANNING_SERVICE_ORGA.pk] + }, + associated_model=models.Organization, + new=True), + validators=[valid_id(models.Organization)] + ) responsible_town_planning_service = forms.IntegerField( - label=" ", widget=forms.HiddenInput, required=False) - planning_service = forms.IntegerField(label=" ", widget=forms.HiddenInput, - required=False) + label=_(u"In charge"), + required=False, + widget=widgets.JQueryAutoComplete( + reverse_lazy('autocomplete-person', + args=[RESPONSIBLE_PLANNING_SERVICE.pk]), + associated_model=Person, + limit={'person_types': [RESPONSIBLE_PLANNING_SERVICE.pk]}, + dynamic_limit=['planning_service'], + url_new='new-person-noorga', + new=True), + validators=[valid_id(Person)] + ) + + def is_valid(self, *args, **kwargs): + c = super(FileFormPlanningService, self).is_valid(*args, **kwargs) + print(self.cleaned_data) + return c class FileFormInstruction(forms.Form): diff --git a/archaeological_files_pdl/templates/ishtar/wizard/wizard_planningservice.html b/archaeological_files_pdl/templates/ishtar/wizard/wizard_planningservice.html index 6fd9eef71..85a1156aa 100644 --- a/archaeological_files_pdl/templates/ishtar/wizard/wizard_planningservice.html +++ b/archaeological_files_pdl/templates/ishtar/wizard/wizard_planningservice.html @@ -1,22 +1,44 @@ -{% extends "ishtar/wizard/wizard_person_orga.html" %} +{% extends "ishtar/wizard/default_wizard.html" %} +{% load i18n range table_form %} +{% block wizard_form %} +<form action="." method="post" name='wizard'{% if wizard.form.file_upload %} enctype="multipart/form-data"{% endif %}>{% csrf_token %} +<div class='form'> +{% if wizard.form.media %}{{ wizard.form.media }}{% endif %} +{{ wizard.management_form }} + +<table> + {% if wizard.form.non_field_errors %}<tr class='errors'> + <td colspan='3'>{{wizard.form.non_field_errors}}</td> + </tr>{%endif%} -{% block corporation %} <tr class='required'> <th>{{ wizard.form.planning_service.label_tag }}</th> <td> {{ wizard.form.planning_service.errors }}{{wizard.form.planning_service|safe}}</td> </tr> -{% endblock %} - -{% block natural %} - <tr class='required'> + <tr> <th>{{ wizard.form.responsible_town_planning_service.label_tag }}</th> <td> {{ wizard.form.responsible_town_planning_service.errors }}{{wizard.form.responsible_town_planning_service|safe}}</td> </tr> -{% endblock %} +</table> + -{% block otherfields %} +<div> +<table> <tr class='required'> <th>{{ wizard.form.reference_number.label_tag }}</th> <td> {{ wizard.form.reference_number.errors }}{{wizard.form.reference_number|safe}}</td> </tr> +</table> +</div> + +<input type="hidden" name="{{ step_field }}" value="{{ step0 }}" /> +{{ previous_fields|safe }} +{% block "validation_bar" %} +{% include 'ishtar/wizard/validation_bar.html' %} +{% endblock %} +</div> +</form> {% endblock %} + + + diff --git a/archaeological_files_pdl/views.py b/archaeological_files_pdl/views.py index bcb1c0211..8305bdab7 100644 --- a/archaeological_files_pdl/views.py +++ b/archaeological_files_pdl/views.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2014 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2015 É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 @@ -22,7 +22,8 @@ from django.utils.translation import ugettext_lazy as _ from archaeological_files_pdl.wizards import FileWizard, FileModificationWizard from archaeological_operations.wizards import is_preventive, is_not_preventive -from ishtar_common.views import OrganizationPersonCreate, OrganizationPersonEdit +from ishtar_common.views import OrganizationPersonCreate, \ + OrganizationPersonEdit from archaeological_files_pdl import forms from archaeological_files import forms as ref_forms @@ -31,69 +32,68 @@ from archaeological_operations.forms import ParcelFormSet from archaeological_files import models -file_creation_wizard_is_preventive = is_preventive('general-file_creation', - models.FileType, type_key='file_type') +file_creation_wizard_is_preventive = is_preventive( + 'general-file_creation', models.FileType, type_key='file_type') file_creation_wizard_is_not_preventive = is_not_preventive( - 'general-file_creation', models.FileType, type_key='file_type') + 'general-file_creation', models.FileType, type_key='file_type') file_creation_wizard = FileWizard.as_view([ - ('general-file_creation', forms.FileFormGeneral), - ('preventivetype-file_creation', forms.FileFormPreventiveType), - ('preventiveplanning-file_creation', forms.FileFormPlanning), - ('researchaddress-file_creation', forms.FileFormResearchAddress), - ('parcelspdl-file_creation', ParcelFormSet), - ('generalcontractor-file_creation', - forms.FileFormGeneralContractor), - ('planningservice-file_creation', - forms.FileFormPlanningService), - ('research-file_creation', ref_forms.FileFormResearch), - ('instruction-file_creation', - forms.FileFormInstruction), - ('final-file_creation', ref_forms.FinalForm)], - label=_(u"New file"), - condition_dict={ - 'preventivetype-file_creation':file_creation_wizard_is_preventive, - 'preventiveplanning-file_creation':file_creation_wizard_is_preventive, - 'generalcontractor-file_creation':file_creation_wizard_is_preventive, - 'planningservice-file_creation':file_creation_wizard_is_preventive, - 'researchaddress-file_creation':file_creation_wizard_is_not_preventive, - 'research-file_creation':file_creation_wizard_is_not_preventive - }, - url_name='file_creation',) - -file_modification_wizard_is_preventive = is_preventive('general-file_modification', - models.FileType, type_key='file_type') + ('general-file_creation', forms.FileFormGeneral), + ('preventivetype-file_creation', forms.FileFormPreventiveType), + ('preventiveplanning-file_creation', forms.FileFormPlanning), + ('researchaddress-file_creation', forms.FileFormResearchAddress), + ('parcelspdl-file_creation', ParcelFormSet), + ('generalcontractor-file_creation', forms.FileFormGeneralContractor), + ('planningservice-file_creation', forms.FileFormPlanningService), + ('research-file_creation', ref_forms.FileFormResearch), + ('instruction-file_creation', forms.FileFormInstruction), + ('final-file_creation', ref_forms.FinalForm)], + label=_(u"New file"), + condition_dict={ + 'preventivetype-file_creation': file_creation_wizard_is_preventive, + 'preventiveplanning-file_creation': file_creation_wizard_is_preventive, + 'generalcontractor-file_creation': file_creation_wizard_is_preventive, + 'planningservice-file_creation': file_creation_wizard_is_preventive, + 'researchaddress-file_creation': + file_creation_wizard_is_not_preventive, + 'research-file_creation': file_creation_wizard_is_not_preventive + }, + url_name='file_creation',) + +file_modification_wizard_is_preventive = is_preventive( + 'general-file_modification', models.FileType, type_key='file_type') file_modification_wizard_is_not_preventive = is_not_preventive( - 'general-file_modification', models.FileType, type_key='file_type') + 'general-file_modification', models.FileType, type_key='file_type') file_modification_wizard = FileModificationWizard.as_view([ - ('selec-file_modification', ref_forms.FileFormSelection), - - ('general-file_modification', forms.FileFormGeneral), - ('preventivetype-file_modification', forms.FileFormPreventiveType), - ('preventiveplanning-file_modification', forms.FileFormPlanning), - ('researchaddress-file_modification', forms.FileFormResearchAddress), - ('parcelspdl-file_modification', ParcelFormSet), - ('generalcontractor-file_modification', - forms.FileFormGeneralContractor), - ('planningservice-file_modification', - forms.FileFormPlanningService), - ('research-file_modification', ref_forms.FileFormResearch), - ('instruction-file_modification', - forms.FileFormInstruction), - ('final-file_modification', ref_forms.FinalForm)], - label=_(u"File modification"), - condition_dict={ - 'preventivetype-file_modification':file_modification_wizard_is_preventive, - 'preventiveplanning-file_modification':file_modification_wizard_is_preventive, - 'generalcontractor-file_modification':file_modification_wizard_is_preventive, - 'planningservice-file_modification':file_modification_wizard_is_preventive, - 'researchaddress-file_modification':file_modification_wizard_is_not_preventive, - 'research-file_modification':file_modification_wizard_is_not_preventive - }, - url_name='file_modification',) + ('selec-file_modification', ref_forms.FileFormSelection), + ('general-file_modification', forms.FileFormGeneral), + ('preventivetype-file_modification', forms.FileFormPreventiveType), + ('preventiveplanning-file_modification', forms.FileFormPlanning), + ('researchaddress-file_modification', forms.FileFormResearchAddress), + ('parcelspdl-file_modification', ParcelFormSet), + ('generalcontractor-file_modification', forms.FileFormGeneralContractor), + ('planningservice-file_modification', forms.FileFormPlanningService), + ('research-file_modification', ref_forms.FileFormResearch), + ('instruction-file_modification', forms.FileFormInstruction), + ('final-file_modification', ref_forms.FinalForm)], + label=_(u"File modification"), + condition_dict={ + 'preventivetype-file_modification': file_modification_wizard_is_preventive, + 'preventiveplanning-file_modification': + file_modification_wizard_is_preventive, + 'generalcontractor-file_modification': + file_modification_wizard_is_preventive, + 'planningservice-file_modification': + file_modification_wizard_is_preventive, + 'researchaddress-file_modification': + file_modification_wizard_is_not_preventive, + 'research-file_modification': file_modification_wizard_is_not_preventive + }, + url_name='file_modification',) class TownPlanningEdit(OrganizationPersonEdit): relative_label = _("File followed by") + class TownPlanningCreate(OrganizationPersonCreate): relative_label = _("File followed by") diff --git a/archaeological_files_pdl/wizards.py b/archaeological_files_pdl/wizards.py index c081d13d1..666de8155 100644 --- a/archaeological_files_pdl/wizards.py +++ b/archaeological_files_pdl/wizards.py @@ -42,8 +42,7 @@ class FileWizard(BaseFileWizard): def get_form_kwargs(self, *args, **kwargs): returned = super(FileWizard, self).get_form_kwargs(*args, **kwargs) - if args and (args[0].startswith('generalcontractor-') or - args[0].startswith('planningservice-')): + if args and args[0].startswith('generalcontractor-'): if 'status' in self.request.GET: returned['status'] = self.request.GET['status'] if args and args[0].startswith('instruction-'): |