Skip to content

Commit

Permalink
MarkdownField uses MarkdownComposite
Browse files Browse the repository at this point in the history
  • Loading branch information
asldevi committed Sep 23, 2013
1 parent 1fe1a46 commit e08bfbb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion baseframe/forms.py
Expand Up @@ -11,6 +11,7 @@
import wtforms
from flask.ext.wtf import Form as BaseForm
from coaster import make_name, get_email_domain
from coaster.sqlalchemy import MarkdownComposite
from . import b__ as __

# Default tags and attributes to allow in HTML sanitization
Expand Down Expand Up @@ -58,13 +59,18 @@ def __call__(self, form, field):


class MarkdownField(wtforms.TextAreaField):
""" TextArea field, which has class='markdown'
""" TextArea field, which has class='markdown' and
whose contents are transformed into a MarkdownComposite obj.
"""
def __call__(self, **kwargs):
c = kwargs.pop('class', '') or kwargs.pop('class_', '')
kwargs['class'] = "%s %s" % (c, 'markdown')
return super(MarkdownField, self).__call__(**kwargs)

def populate_obj(self, obj, name):
md = MarkdownComposite(self.data)
setattr(obj, name, md)


class RichText(wtforms.widgets.TextArea):
"""
Expand Down

0 comments on commit e08bfbb

Please sign in to comment.