src/catedit/views/forms.py
author durandn
Wed, 15 Apr 2015 14:56:07 +0200
changeset 123 1e1c8f98f3a8
child 131 7684ea24c330
permissions -rw-r--r--
Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
123
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
     1
"""
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
     2
forms.py
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
     3
Module that groups custom forms used in CatEdit
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
     4
"""
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
     5
from flask_wtf import Form
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
     6
from wtforms import StringField, TextAreaField, FormField, \
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
     7
                    FieldList, HiddenField
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
     8
from wtforms.validators import DataRequired, Optional, AnyOf
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
     9
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    10
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    11
class CommitForm(Form):
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    12
    """
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    13
        Custom form class for commiting changes
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    14
    """
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    15
    commit_message = StringField(
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    16
        "Message de soumission (obligatoire)",
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    17
        validators=[DataRequired()]
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    18
    )
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    19
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    20
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    21
class PropertyForm(Form):
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    22
    """
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    23
        Form of a given property, each one is a couple of hidden fields that
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    24
        can be Javascript-generated in the template
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    25
    """
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    26
    property_predicate = HiddenField()
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    27
    property_object = HiddenField(
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    28
        validators=[DataRequired()]
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    29
    )
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    30
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    31
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    32
class CategoryForm(Form):
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    33
    """
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    34
        Custom form class for creating a category with the absolute minimal
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    35
        attributes (label and description)
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    36
    """
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    37
    label = StringField(
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    38
        "Nom de la categorie (obligatoire)",
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    39
        validators=[DataRequired()]
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    40
    )
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    41
    description = TextAreaField(
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    42
        "Description de la categorie (obligatoire)",
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    43
        validators=[DataRequired()]
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    44
    )
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    45
    properties = FieldList(FormField(PropertyForm), validators=[Optional()])
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    46
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    47
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    48
class CommentForm(Form):
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    49
    """
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    50
        Custom form class for commiting changes
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    51
    """
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    52
    comment_field = TextAreaField(
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    53
        "Poster un commentaire: ",
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    54
        validators=[DataRequired()]
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    55
    )
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    56
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    57
class NewDiscussionForm(Form):
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    58
    """
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    59
        Custom form class for commiting changes
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    60
    """
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    61
    discussion_title = StringField(
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    62
        "Titre de la discussion: ",
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    63
        validators=[DataRequired()]
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    64
    )
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    65
    comment_field = TextAreaField(
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    66
        "Commentaire d'ouverture (facultatif): "
1e1c8f98f3a8 Fixed cache registry handling + added forms.py (didn't commit last time) + moved forms in views/social.py into views/forms.py + small tweaks to timezone support
durandn
parents:
diff changeset
    67
    )