moved forms in forms.py
authordurandn
Tue, 14 Apr 2015 16:25:20 +0200
changeset 121 70b206790ef6
parent 120 455be5fd93b5
child 122 cee0e7d7e6d2
moved forms in forms.py
src/catedit/views/categories.py
--- a/src/catedit/views/categories.py	Wed Apr 15 04:07:33 2015 +0200
+++ b/src/catedit/views/categories.py	Tue Apr 14 16:25:20 2015 +0200
@@ -13,11 +13,9 @@
 from io import StringIO
 
 from flask import render_template, request, redirect, url_for, abort, Blueprint, session
-from flask_wtf import Form
 from rdflib import Graph
-from wtforms import StringField, TextAreaField, FormField, \
-                    FieldList, HiddenField
-from wtforms.validators import DataRequired, Optional, AnyOf
+
+from catedit.views.forms import CommitForm, CategoryForm
 
 
 module = Blueprint('categories', __name__)
@@ -92,17 +90,7 @@
             discussion_list=discussion_list,
             current_repository=repository
         )
-
-
-class CommitForm(Form):
-    """
-        Custom form class for commiting changes
-    """
-    commit_message = StringField(
-        "Message de soumission (obligatoire)",
-        validators=[DataRequired()]
-    )
-
+        
 
 @module.route(
     '/<string:repository>/submit/delete-changes-<deleted_changes_id>',
@@ -204,34 +192,6 @@
             )
 
 
-
-class PropertyForm(Form):
-    """
-        Form of a given property, each one is a couple of hidden fields that
-        can be Javascript-generated in the template
-    """
-    property_predicate = HiddenField()
-    property_object = HiddenField(
-        validators=[DataRequired()]
-    )
-
-
-class CategoryForm(Form):
-    """
-        Custom form class for creating a category with the absolute minimal
-        attributes (label and description)
-    """
-    label = StringField(
-        "Nom de la categorie (obligatoire)",
-        validators=[DataRequired()]
-    )
-    description = TextAreaField(
-        "Description de la categorie (obligatoire)",
-        validators=[DataRequired()]
-    )
-    properties = FieldList(FormField(PropertyForm), validators=[Optional()])
-
-
 @module.route('/<string:repository>/editor',
               defaults={'cat_id': None},
               methods=['GET', 'POST'])