From a2927f761606ce5df50a484d365a2f65252946ac Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Thu, 20 May 2021 14:02:10 +0200 Subject: [PATCH] Add required param `renderer` to MarkDownWidget --- orchestra/contrib/issues/forms.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/orchestra/contrib/issues/forms.py b/orchestra/contrib/issues/forms.py index 30de94f6..292c85aa 100644 --- a/orchestra/contrib/issues/forms.py +++ b/orchestra/contrib/issues/forms.py @@ -13,7 +13,7 @@ from .models import Queue, Ticket class MarkDownWidget(forms.Textarea): """ MarkDown textarea widget with syntax preview """ - + markdown_url = static('issues/markdown_syntax.html') markdown_help_text = ( 'markdown format' % (markdown_url, markdown_url) ) markdown_help_text = 'HTML not allowed, you can use %s' % markdown_help_text - - def render(self, name, value, attrs): + + def render(self, name, value, attrs, renderer=None): widget_id = attrs['id'] if attrs and 'id' in attrs else 'id_%s' % name textarea = super(MarkDownWidget, self).render(name, value, attrs) preview = ('preview'\ @@ -35,18 +35,18 @@ class MessageInlineForm(forms.ModelForm): """ Add message form """ created_on = forms.CharField(label="Created On", required=False) content = forms.CharField(widget=MarkDownWidget(), required=False) - + class Meta: fields = ('author', 'author_name', 'created_on', 'content') - + def __init__(self, *args, **kwargs): super(MessageInlineForm, self).__init__(*args, **kwargs) self.fields['created_on'].widget = SpanWidget(display='') - + def clean_content(self): """ clean HTML tags """ return strip_tags(self.cleaned_data['content']) - + def save(self, *args, **kwargs): if self.instance.pk is None: self.instance.author = self.user @@ -58,7 +58,7 @@ class UsersIterator(forms.models.ModelChoiceIterator): def __init__(self, *args, **kwargs): self.ticket = kwargs.pop('ticket', False) super(forms.models.ModelChoiceIterator, self).__init__(*args, **kwargs) - + def __iter__(self): yield ('', '---------') users = get_user_model().objects.exclude(is_active=False).order_by('name') @@ -73,14 +73,14 @@ class UsersIterator(forms.models.ModelChoiceIterator): class TicketForm(forms.ModelForm): display_description = forms.CharField(label=_("Description"), required=False) description = forms.CharField(widget=MarkDownWidget(attrs={'class':'vLargeTextField'})) - + class Meta: model = Ticket fields = ( 'creator', 'creator_name', 'owner', 'queue', 'subject', 'description', 'priority', 'state', 'cc', 'display_description' ) - + def __init__(self, *args, **kwargs): super(TicketForm, self).__init__(*args, **kwargs) ticket = kwargs.get('instance', False) @@ -101,7 +101,7 @@ class TicketForm(forms.ModelForm): description = '
%s
' % description widget = SpanWidget(display=description) self.fields['display_description'].widget = widget - + def clean_description(self): """ clean HTML tags """ return strip_tags(self.cleaned_data['description'])