From: Jan Szejko Date: Tue, 25 Jul 2017 09:49:06 +0000 (+0200) Subject: TextileField X-Git-Tag: 0.2.6 X-Git-Url: https://git.mdrn.pl/fnpdjango.git/commitdiff_plain/3b009e3e675620c33423c624985726ee8db94e86 TextileField --- diff --git a/fnpdjango/utils/fields.py b/fnpdjango/utils/fields.py new file mode 100644 index 0000000..e638db5 --- /dev/null +++ b/fnpdjango/utils/fields.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from django.forms import CharField, ValidationError +from .text.textilepl import textile_pl + +try: + from markupfield.fields import MarkupField +except ImportError: + MarkupField = None +else: + def validate_textile(value): + try: + textile_pl(value) + except Exception: + raise ValidationError('Syntax error in markup.') + + + class TextileFormField(CharField): + default_validators = [validate_textile] + + + class TextileField(MarkupField): + def formfield(self, **kwargs): + defaults = {'form_class': TextileFormField} + defaults.update(kwargs) + return super(MarkupField, self).formfield(**defaults) diff --git a/setup.py b/setup.py index 0190709..2f9babe 100755 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ def whole_trees(package_dir, paths): setup( name='fnpdjango', - version='0.2.4', + version='0.2.6', author='Radek Czajka', author_email='radekczajka@nowoczesnapolska.org.pl', url='',