summaryrefslogtreecommitdiff
path: root/archaeological_operations/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations/forms.py')
-rw-r--r--archaeological_operations/forms.py43
1 files changed, 21 insertions, 22 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py
index 691b0c90c..b1f2e053b 100644
--- a/archaeological_operations/forms.py
+++ b/archaeological_operations/forms.py
@@ -26,16 +26,13 @@ from itertools import groupby
from django import forms
from django.conf import settings
from django.core import validators
-from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Max
from django.forms.formsets import DELETION_FIELD_NAME, TOTAL_FORM_COUNT
-from django.shortcuts import render_to_response
-from django.template import RequestContext
from django.utils.translation import ugettext_lazy as _, pgettext_lazy
from django.utils.safestring import mark_safe
from ishtar_common.models import valid_id, PersonType, Person, Town, \
- DocumentTemplate, Organization, OrganizationType
+ DocumentTemplate, Organization, OrganizationType
from ishtar_common.wizards import MultiValueDict
@@ -48,15 +45,14 @@ import models
from widgets import ParcelWidget, SelectParcelWidget
from ishtar_common import widgets
-from ishtar_common.forms import BaseFormSet, FinalForm, FormSet, \
- ClosingDateFormSelection, formset_factory, get_now, reverse_lazy, \
- get_form_selection, TableSelect
-from ishtar_common.forms_common import TownForm, TownFormSet, TownFormset, \
- AuthorFormset, SourceForm, SourceSelect, \
- SourceDeletionForm, get_town_field
+from ishtar_common.forms import FinalForm, FormSet, formset_factory, get_now, \
+ reverse_lazy, get_form_selection, TableSelect
+from ishtar_common.forms_common import TownFormSet, SourceForm, SourceSelect, \
+ get_town_field
from archaeological_operations.utils import parse_parcels
+
class ParcelField(forms.MultiValueField):
def __init__(self, *args, **kwargs):
if 'widget' not in kwargs:
@@ -66,19 +62,22 @@ class ParcelField(forms.MultiValueField):
def compress(data_list):
return u"-".join(data_list)
+
class ParcelForm(forms.Form):
form_label = _("Parcels")
base_model = 'parcel'
- associated_models = {'parcel':models.Parcel, 'town':models.Town,}
+ associated_models = {'parcel': models.Parcel, 'town': models.Town, }
town = forms.ChoiceField(label=_("Town"), choices=(), required=False,
validators=[valid_id(models.Town)])
year = forms.IntegerField(label=_("Year"), required=False,
- validators=[validators.MinValueValidator(1900),
- validators.MaxValueValidator(2100)])
+ validators=[validators.MinValueValidator(1900),
+ validators.MaxValueValidator(2100)])
section = forms.CharField(label=_(u"Section"), required=False,
- validators=[validators.MaxLengthValidator(4)])
- parcel_number = forms.CharField(label=_(u"Parcel number"), required=False,
- validators=[validators.MaxLengthValidator(6)])
+ validators=[validators.MaxLengthValidator(4)])
+ parcel_number = forms.CharField(
+ label=_(u"Parcel number"), required=False,
+ validators=[validators.MaxLengthValidator(6)])
+
def __init__(self, *args, **kwargs):
towns = None
if 'data' in kwargs and 'TOWNS' in kwargs['data']:
@@ -524,12 +523,12 @@ class DashboardForm(forms.Form):
class OperationFormGeneral(forms.Form):
form_label = _(u"General")
base_model = 'archaeological_site'
- associated_models = {'scientist':Person,
- 'in_charge':Person,
- 'cira_rapporteur':Person,
- 'operator':Organization,
- 'operation_type':models.OperationType,
- 'archaeological_site':models.ArchaeologicalSite}
+ associated_models = {'scientist': Person,
+ 'in_charge': Person,
+ 'cira_rapporteur': Person,
+ 'operator': Organization,
+ 'operation_type': models.OperationType,
+ 'archaeological_site': models.ArchaeologicalSite}
pk = forms.IntegerField(required=False, widget=forms.HiddenInput)
scientist = forms.IntegerField(label=_("Head scientist"),
widget=widgets.JQueryAutoComplete(reverse_lazy('autocomplete-person',