diff options
Diffstat (limited to 'archaeological_warehouse/forms.py')
| -rw-r--r-- | archaeological_warehouse/forms.py | 16 | 
1 files changed, 11 insertions, 5 deletions
diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py index f045fac1e..d56df8139 100644 --- a/archaeological_warehouse/forms.py +++ b/archaeological_warehouse/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-2016  É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,12 +22,13 @@ from django.conf import settings  from django.utils.translation import ugettext_lazy as _  from ishtar_common.models import Person, valid_id -from archaeological_finds.models import TreatmentType +from archaeological_finds.models import TreatmentType, FindBasket  import models  from ishtar_common import widgets  from ishtar_common.forms import name_validator, reverse_lazy, \      get_form_selection, TableSelect -from archaeological_finds.forms import FindMultipleFormSelection +from archaeological_finds.forms import FindMultipleFormSelection, \ +    SelectFindBasketForm  def get_warehouse_field(label=_(u"Warehouse"), required=True): @@ -66,6 +67,8 @@ class WarehouseForm(forms.Form):                                     required=False)      def __init__(self, *args, **kwargs): +        if 'limits' in kwargs: +            kwargs.pop('limits')          super(WarehouseForm, self).__init__(*args, **kwargs)          self.fields['warehouse_type'].choices = \              models.WarehouseType.get_types() @@ -99,6 +102,8 @@ class ContainerForm(forms.Form):                                widget=forms.Textarea, required=False)      def __init__(self, *args, **kwargs): +        if 'limits' in kwargs: +            kwargs.pop('limits')          super(ContainerForm, self).__init__(*args, **kwargs)          self.fields['container_type'].choices = \              models.ContainerType.get_types() @@ -135,11 +140,12 @@ ContainerFormSelection = get_form_selection(      new_message=_(u"Add a new container")) -class BasePackagingForm(forms.Form): +class BasePackagingForm(SelectFindBasketForm):      form_label = _(u"Packaging")      associated_models = {'treatment_type': TreatmentType,                           'person': Person, -                         'location': models.Warehouse} +                         'location': models.Warehouse, +                         'basket': FindBasket}      treatment_type = forms.IntegerField(label="", widget=forms.HiddenInput)      person = forms.IntegerField(          label=_(u"Packager"),  | 
