summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_warehouse/forms.py18
-rw-r--r--ishtar_common/models.py4
2 files changed, 14 insertions, 8 deletions
diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py
index f020864ff..f98adc33a 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
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 626770011..4db445c41 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -23,6 +23,7 @@ Models description
from cStringIO import StringIO
import copy
import datetime
+import inspect
from PIL import Image
import logging
import os
@@ -1686,7 +1687,8 @@ class CustomForm(models.Model):
# not very clean... but do not treat inappropriate items
continue
form = getattr(app_form, form)
- if not issubclass(form, CustomForm) \
+ if not inspect.isclass(form) \
+ or not issubclass(form, CustomForm) \
or not getattr(form, 'form_slug', None):
continue
cls._register[form.form_slug] = form