From 14ccc8da7558a355896e91270153f5d40ebaa2d5 Mon Sep 17 00:00:00 2001 From: Pierre-antoine Comby Date: Tue, 3 Mar 2020 14:26:31 +0100 Subject: [PATCH] Add ImageForm --- apps/note/forms.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/apps/note/forms.py b/apps/note/forms.py index 2998887b..27050207 100644 --- a/apps/note/forms.py +++ b/apps/note/forms.py @@ -5,19 +5,34 @@ from dal import autocomplete from django import forms from django.utils.translation import gettext_lazy as _ +from crispy_forms.helper import FormHelper +from crispy_forms.bootstrap import Div +from crispy_forms.layout import Layout, HTML + from .models import Transaction, TransactionTemplate, TemplateTransaction -from .models import Alias +from .models import Note, Alias class AliasForm(forms.ModelForm): class Meta: model = Alias fields = ("name",) + def __init__(self,*args,**kwargs): super().__init__(*args,**kwargs) self.fields["name"].label = False self.fields["name"].widget.attrs={"placeholder":_('New Alias')} - + +class ImageForm(forms.ModelForm): + class Meta: + model = Note + fields = ('display_image',) + + def __init__(self,*args,**kwargs): + super().__init__(*args,**kwargs) + self.fields["display_image"].label = _("select an image") + self.fields["display_image"].widget.attrs={"help_text":_('Maximal size: 2MB')} + class TransactionTemplateForm(forms.ModelForm): class Meta: model = TransactionTemplate