summaryrefslogtreecommitdiff
path: root/archaeological_warehouse/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-01-05 15:06:12 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-01-05 15:06:12 +0100
commit2ea08e20ee52f2d6df08460536cd95224a7ae07d (patch)
treecacfd44d18db9263030377d95868122625ad0ada /archaeological_warehouse/forms.py
parentcdfdea70ba35aa9b1d02a93896eadcdb733fdabd (diff)
parent7c0b2e7f72308ea543b9fb15e4d25b7d9b4eddb7 (diff)
downloadIshtar-2ea08e20ee52f2d6df08460536cd95224a7ae07d.tar.bz2
Ishtar-2ea08e20ee52f2d6df08460536cd95224a7ae07d.zip
Merge branch 'develop' into develop-bootstrap
Diffstat (limited to 'archaeological_warehouse/forms.py')
-rw-r--r--archaeological_warehouse/forms.py34
1 files changed, 20 insertions, 14 deletions
diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py
index 5977f87a9..da0c1c195 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,
@@ -185,16 +191,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
@@ -282,7 +286,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):