X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/dbf3690fd7b8d30f603f3ef333290c22f4e5d63f..45bec7a49efdc851db66b7fdb0207a9d465b615e:/apps/wiki/forms.py diff --git a/apps/wiki/forms.py b/apps/wiki/forms.py index 08e5aea4..d526bfc6 100644 --- a/apps/wiki/forms.py +++ b/apps/wiki/forms.py @@ -7,6 +7,7 @@ from django import forms from django.utils.translation import ugettext_lazy as _ from catalogue.models import Chunk +from catalogue.xml_tools import remove_empty_elements class DocumentPubmarkForm(forms.Form): @@ -77,6 +78,12 @@ class DocumentTextSaveForm(forms.Form): self.fields['author_name'].required = False self.fields['author_email'].required = False self.fields['for_cybernauts'].initial = self.chunk.book.for_cybernauts + self.fields['publishable'].initial = self.chunk.head.publishable + + def clean_text(self): + text = self.cleaned_data.get('text', '') + # remove_empty_elements returns None on SyntaxError or when there's no change + return remove_empty_elements(text) or text def save(self): if self.user.is_authenticated():