summaryrefslogtreecommitdiff
path: root/ishtar_common/forms_common.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/forms_common.py')
-rw-r--r--ishtar_common/forms_common.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index 116c8c277..dadeefee0 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -35,7 +35,7 @@ import models
import widgets
from ishtar_common.templatetags.link_to_window import link_to_window
from forms import FinalForm, FormSet, reverse_lazy, name_validator, \
- TableSelect, ManageOldType
+ TableSelect, ManageOldType, CustomForm, FieldType
def get_town_field(label=_(u"Town"), required=True):
@@ -731,8 +731,11 @@ class TownFormSet(FormSet):
return self.check_duplicate(('town',),
_("There are identical towns."))
+
TownFormset = formset_factory(TownForm, can_delete=True, formset=TownFormSet)
TownFormset.form_label = _("Towns")
+TownFormset.form_admin_name = _(u"Towns")
+TownFormset.form_slug = "towns"
class MergeFormSet(BaseModelFormSet):
@@ -860,8 +863,11 @@ class MergeOrganizationForm(MergeForm):
######################
# Sources management #
######################
-class SourceForm(ManageOldType, forms.Form):
+class SourceForm(CustomForm, ManageOldType, forms.Form):
form_label = _(u"Documentation informations")
+ form_admin_name = _("Source - General")
+ form_slug = "source-general"
+
file_upload = True
associated_models = {'source_type': models.SourceType}
title = forms.CharField(label=_(u"Title"),
@@ -899,10 +905,9 @@ class SourceForm(ManageOldType, forms.Form):
'height': settings.IMAGE_MAX_SIZE[1]}),
max_length=255, required=False, widget=widgets.ImageFileInput())
- def __init__(self, *args, **kwargs):
- super(SourceForm, self).__init__(*args, **kwargs)
- self.fields['source_type'].choices = models.SourceType.get_types(
- initial=self.init_data.get('source_type'))
+ TYPES = [
+ FieldType('source_type', models.SourceType),
+ ]
class SourceSelect(TableSelect):
@@ -986,3 +991,5 @@ class AuthorFormSet(FormSet):
AuthorFormset = formset_factory(AuthorFormSelection, can_delete=True,
formset=AuthorFormSet)
AuthorFormset.form_label = _("Authors")
+AuthorFormset.form_admin_name = _(u"Authors")
+AuthorFormset.form_slug = "authors"