diff options
| author | Étienne Loks <etienne.loks@peacefrogs.net> | 2014-03-02 19:12:07 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2014-03-02 19:12:07 +0100 | 
| commit | af42287a7a113da28f1f9aab54cfc2e96c9a6d90 (patch) | |
| tree | e2ef8db4d09dddaf2d6e7500575a1ee1fa87d2e1 /archaeological_files/forms.py | |
| parent | 9bafeee09b680bc599bfb1664ead9b69a5fd451e (diff) | |
| download | Ishtar-af42287a7a113da28f1f9aab54cfc2e96c9a6d90.tar.bz2 Ishtar-af42287a7a113da28f1f9aab54cfc2e96c9a6d90.zip | |
Specific form for research archaeology (refs #1682)
Diffstat (limited to 'archaeological_files/forms.py')
| -rw-r--r-- | archaeological_files/forms.py | 55 | 
1 files changed, 52 insertions, 3 deletions
| diff --git a/archaeological_files/forms.py b/archaeological_files/forms.py index 87f86d0d0..cf775bf08 100644 --- a/archaeological_files/forms.py +++ b/archaeological_files/forms.py @@ -1,6 +1,6 @@  #!/usr/bin/env python  # -*- coding: utf-8 -*- -# Copyright (C) 2010-2013  Étienne Loks  <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2010-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 @@ -33,8 +33,9 @@ from django.utils.translation import ugettext_lazy as _  from django.utils.safestring import mark_safe  from ishtar_common.models import Person, PersonType, Town, Organization, \ -                         OrganizationType, valid_id, is_unique -from archaeological_operations.models import ActType, AdministrativeAct +                         OrganizationType, valid_id, is_unique, Department +from archaeological_operations.models import ActType, AdministrativeAct, \ +                                             OperationType  import models  from ishtar_common.forms import FinalForm, FormSet, ClosingDateFormSelection, \      formset_factory, get_now, reverse_lazy, TableSelect @@ -205,6 +206,54 @@ class FileFormPreventive(forms.Form):                                                                default='NP')          self.fields['permit_type'].help_text = models.PermitType.get_help() +class FileFormResearch(forms.Form): +    form_label = _("Research informations") +    base_model = 'department' +    associated_models = {'scientist':Person, +                         'requested_operation_type':OperationType, +                         'organization':Organization, +                         'department':Department} +    department = widgets.MultipleAutocompleteField( +                                model=Department, +                                label=_("Departments"), +                                required=False) +    scientist = forms.IntegerField( +        widget=widgets.JQueryAutoComplete(reverse_lazy('autocomplete-person', +          args=["_".join( +         [unicode(PersonType.objects.get(txt_idx='head_scientist').pk), +          unicode(PersonType.objects.get(txt_idx='sra_agent').pk)])]), +        associated_model=Person), label=_(u"Scientist in charge")) +    requested_operation_type = forms.ChoiceField( +                    label=_(u"Requested operation type"), +                    choices=[]) +    organization = forms.IntegerField(label=_(u"Lead organization"), +            widget=widgets.JQueryAutoComplete( +                reverse_lazy('autocomplete-organization'), +                associated_model=Organization), +            validators=[valid_id(Organization)], required=False) +    if settings.COUNTRY == 'fr': +        cira_advised = forms.NullBooleanField(label=u"Passage en CIRA", +                                              required=False) +    research_comment = forms.CharField(label=_(u"Comment"), +                        widget=forms.Textarea, required=False) +    if settings.COUNTRY == 'fr': +        mh_register = forms.NullBooleanField( +                            label=u"Sur Monument Historique classé", +                            required=False) +        mh_listing = forms.NullBooleanField( +                            label=u"Sur Monument Historique inscrit", +                            required=False) +    classified_area = forms.NullBooleanField(label=_(u"Classified area"), +                                             required=False) +    protected_area = forms.NullBooleanField(label=_(u"Protected area"), +                                            required=False) +    def __init__(self, *args, **kwargs): +        super(FileFormResearch, self).__init__(*args, **kwargs) +        self.fields['requested_operation_type'].choices = \ +                    OperationType.get_types(dct={"preventive":False}) +        self.fields['requested_operation_type'].help_text = \ +                    OperationType.get_help() +  class FinalFileClosingForm(FinalForm):      confirm_msg = " "      confirm_end_msg = _(u"Would you like to close this archaeological file?") | 
