diff options
Diffstat (limited to 'ishtar_common/forms_common.py')
-rw-r--r-- | ishtar_common/forms_common.py | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index 134e7ceb1..854fe2a71 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -1184,61 +1184,3 @@ AuthorFormset = formset_factory(AuthorFormSelection, can_delete=True, AuthorFormset.form_label = _("Authors") AuthorFormset.form_admin_name = _(u"Authors") AuthorFormset.form_slug = "authors" - - -class BaseImageForm(ManageOldType): - form_label = _(u"Images") - base_model = 'image' - associated_models = {'licence': models.LicenseType, - 'authors': models.Author} - - pk = forms.IntegerField(label=" ", widget=forms.HiddenInput, - required=False) - image = forms.ImageField( - label=_(u"Image"), help_text=mark_safe(get_image_help()), - max_length=255, required=False, widget=widgets.ImageFileInput()) - name = forms.CharField(label=_(u"Name"), max_length=250, required=False) - authors = widgets.Select2MultipleField( - model=models.Author, remote=True, label=_(u"Authors"), - required=False, long_widget=True, new=True - ) - description = forms.CharField(label=_(u"Description"), required=False, - widget=forms.Textarea) - creation_date = forms.DateField( - label=_(u"Creation date"), required=False, widget=DatePicker) - licence = widgets.Select2MultipleField( - label=_(u"Licence"), required=False - ) - reference = forms.CharField(label=_(u"Ref."), max_length=250, - required=False) - internal_reference = forms.CharField(label=_(u"Internal ref."), - max_length=250, required=False) - is_main = forms.BooleanField(label=_(u"Main image"), required=False, - initial=False) - - TYPES = [ - FieldType('licence', models.LicenseType, True), - ] - - def count_valid_fields(self, data): - if not data: - return 0 - return len(get_data_from_formset(data)) - - -class BaseImageFormset(FormSet): - def clean(self): - """ - Verify that no two images are main image - """ - if any(self.errors): - return - have_main = False - for form in self.forms: - is_main = form.cleaned_data.get('is_main', False) - if not is_main: - continue - if is_main and have_main: - raise forms.ValidationError(_(u"Only one image can be a main " - u"image")) - have_main = True
\ No newline at end of file |