diff options
Diffstat (limited to 'archaeological_warehouse/forms.py')
-rw-r--r-- | archaeological_warehouse/forms.py | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py index dcd16963e..4d4348b70 100644 --- a/archaeological_warehouse/forms.py +++ b/archaeological_warehouse/forms.py @@ -30,7 +30,8 @@ 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, ManageOldType, FinalForm, FormSet + get_form_selection, TableSelect, ManageOldType, FinalForm, FormSet, \ + CustomForm, FieldType from archaeological_finds.forms import FindMultipleFormSelection, \ SelectFindBasketForm @@ -67,9 +68,12 @@ class DivisionFormSet(FormSet): return self.check_duplicate(('division',), _("There are identical divisions.")) + SelectedDivisionFormset = formset_factory( SelectedDivisionForm, can_delete=True, formset=DivisionFormSet) SelectedDivisionFormset.form_label = _(u"Divisions") +SelectedDivisionFormset.form_admin_name = _(u"Warehouse - 020 - Divisions") +SelectedDivisionFormset.form_slug = "warehouse-020-divisions" class WarehouseSelect(TableSelect): @@ -97,8 +101,10 @@ class WarehouseFormSelection(forms.Form): validators=[valid_id(models.Warehouse)]) -class WarehouseForm(ManageOldType, forms.Form): +class WarehouseForm(CustomForm, ManageOldType, forms.Form): form_label = _(u"Warehouse") + form_admin_name = _(u"Warehouse - 010 - General") + form_slug = "warehouse-010-general" associated_models = {'warehouse_type': models.WarehouseType, 'person_in_charge': Person} @@ -127,16 +133,14 @@ class WarehouseForm(ManageOldType, forms.Form): phone = forms.CharField(label=_(u"Phone"), max_length=18, required=False) mobile_phone = forms.CharField(label=_(u"Mobile phone"), max_length=18, required=False) + TYPES = [ + FieldType('warehouse_type', models.WarehouseType) + ] 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( - initial=self.init_data.get('warehouse_type')) - self.fields['warehouse_type'].help_text = \ - models.WarehouseType.get_help() def save(self, user): dct = self.cleaned_data @@ -156,8 +160,10 @@ class WarehouseDeletionForm(FinalForm): confirm_end_msg = _(u"Would you like to delete this warehouse?") -class ContainerForm(ManageOldType, forms.Form): +class ContainerForm(CustomForm, ManageOldType, forms.Form): form_label = _(u"Container") + form_admin_name = _(u"Container - 010 - General") + form_slug = "container-010-general" file_upload = True associated_models = {'container_type': models.ContainerType, 'location': models.Warehouse, @@ -187,16 +193,14 @@ class ContainerForm(ManageOldType, forms.Form): max_length=255, required=False, widget=widgets.ImageFileInput()) comment = forms.CharField(label=_(u"Comment"), widget=forms.Textarea, required=False) + TYPES = [ + FieldType('container_type', models.ContainerType), + ] 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( - initial=self.init_data.get('container_type')) - self.fields['container_type'].help_text = \ - models.ContainerType.get_help() def save(self, user): dct = self.cleaned_data @@ -284,7 +288,9 @@ class FindPackagingFormSelection(FindMultipleFormSelection): form_label = _(u"Packaged finds") -class LocalisationForm(forms.Form): +class LocalisationForm(CustomForm, forms.Form): + form_admin_name = _(u"Container - 020 - Localisation") + form_slug = "container-020-localisation" form_label = _(u"Localisation") def __init__(self, *args, **kwargs): |