class EditArticleForm(Form): title = TextField(_(u'Title'), [validators.required(), validators.length(max=200)]) intro = TextField(_(u'Intro'), [validators.required()], widget=widgets.TextArea()) text = TextField(_(u'Text'), [validators.required()], widget=widgets.TextArea()) public = BooleanField(_(u'Published')) tags = AutocompleteField(_(u'Tags'), get_label='name', query_factory=lambda: Tag.query.autoflush(False)) author = QuerySelectField(_(u'Author'), [validators.required()], query_factory=lambda: User.query.autoflush(False), widget=widgets.Select())
class EditForumForm(Form): name = TextField(lazy_gettext(u'Name'), [validators.required(), validators.length(max=160)]) slug = TextField(lazy_gettext(u'Slug'), [validators.required(), validators.length(max=160)]) parent = QuerySelectField(lazy_gettext(u'Parent'), query_factory=lambda: Forum.query, get_label='name', allow_blank=True) description = TextField(lazy_gettext(u'Description'), [validators.required()], widget=widgets.TextArea()) tags = AutocompleteField(lazy_gettext(u'Tags'), get_label='name', query_factory=lambda: Tag.query, validators=[validators.length(min=1)]) def validate_parent(self, field): message = lazy_gettext( u"You can't choose the forum itself or one of its subforums as parent" ) forum = Forum.query.filter_by(slug=self.slug.data).first() forums = Forum.query.filter_by(slug=self.slug.data).subforums() if field.data in forums or field.data == forum: raise ValidationError(message)
class AskQuestionForm(Form): title = TextField(lazy_gettext(u'Title'), [validators.length(max=160), validators.required()]) text = TextField(lazy_gettext(u'Text'), [validators.required()], widget=widgets.TextArea()) tags = AutocompleteField(lazy_gettext(u'Tags'), get_label='name', query_factory=lambda: Tag.query)
class AddEventForm(Form): title = TextField(_(u'Title'), [validators.length(max=100), validators.required()]) text = TextField(_(u'Text'), [validators.required()], widget=widgets.TextArea()) start = DateTimeField(_(u'Start'), [validators.required()]) end = DateTimeField(_(u'End'), [validators.required()]) tags = AutocompleteField(_(u'Tags'), get_label='name', query_factory=lambda: Tag.query.autoflush(False)) discussion_question = BooleanField(_(u'Create topic for discussion')) info_question = BooleanField(_(u'Create topic for further information'))
class ProfileForm(Form): # personal data real_name = TextField(lazy_gettext(u'Realname'), [validators.length(max=200)]) website = TextField( lazy_gettext(u'Website'), validators=[validators.optional(), validators.is_valid_url()]) location = TextField(lazy_gettext(u'Location'), [validators.length(max=200)]) interests = TextField(lazy_gettext(u'Interests'), [validators.length(max=200)]) occupation = TextField(lazy_gettext(u'Occupation'), [validators.length(max=200)]) signature = TextField(lazy_gettext(u'Signature'), widget=widgets.TextArea()) # communication channels jabber = TextField( lazy_gettext(u'Jabber ID'), validators=[validators.optional(), validators.is_valid_jabber()]) skype = TextField(lazy_gettext(u'Skype'), [validators.length(max=200)]) def __init__(self, *args, **kwargs): self.profile = profile = kwargs.pop('profile') if profile is not None: kwargs.update(model_to_dict(profile, exclude=['user', 'user_id'])) super(ProfileForm, self).__init__(*args, **kwargs) def save(self, commit=True): profile = UserProfile() if self.profile is None else self.profile profile = update_model(profile, self) if commit: db.session.commit() return profile
class AddPasteForm(Form): title = TextField(_(u'Title (optional)'), [validators.length(max=50)]) text = TextField(_(u'Text'), [validators.required()], widget=widgets.TextArea()) language = SelectField(_(u'Language'), choices=_get_pygments_lexers()) parent = HiddenIntegerField(validators=[validators.optional()])
class AnswerQuestionForm(Form): text = TextField(lazy_gettext(u'Text'), [validators.required()], widget=widgets.TextArea())
class EditCommentForm(Form): text = TextField(_(u'Text'), widget=widgets.TextArea(), description=Markup(_(u'To quote another comment use ' u'<em>@comment_number</em>. This is ' u'automatically used if you click “answer”.')))