Esempio n. 1
0
 def validate_title(self, field):
     """
     If the title is already in use, refuse to add this one.
     """
     existing = set([simplify_text(c.title) for c in Category.query.all() if c != self.edit_obj])
     if simplify_text(field.data) in existing:
         raise wtf.ValidationError("You have an existing category with the same name")
Esempio n. 2
0
 def validate_title(self, field):
     """
     If the title is already in use, refuse to add this one.
     """
     existing = set([simplify_text(b.title) for b in
         Budget.query.filter_by(workspace=g.workspace).all() if b != self.edit_obj])
     if simplify_text(field.data) in existing:
         raise wtforms.ValidationError("You have an existing budget with the same name")
Esempio n. 3
0
 def validate_title(self, field):
     """
     If the title is already in use, refuse to add this one.
     """
     existing = set([
         simplify_text(c.title) for c in Category.query.all()
         if c != self.edit_obj
     ])
     if simplify_text(field.data) in existing:
         raise wtf.ValidationError(
             "You have an existing category with the same name")
Esempio n. 4
0
def get_word_bag(text):
    """
    Return a string containing all unique words in the given text, in alphabetical order.

    >>> get_word_bag("This is a piece\tof text with this extra bit!")
    'a bit extra is of piece text this with'
    """
    words = list(set(simplify_text(striptags(text)).split(' ')))
    words.sort()
    return " ".join(words)
Esempio n. 5
0
def get_word_bag(text):
    """
    Return a string containing all unique words in the given text, in alphabetical order.

    >>> get_word_bag("This is a piece\tof text with this extra bit!")
    'a bit extra is of piece text this with'
    """
    words = list(set(simplify_text(striptags(text)).split(' ')))
    words.sort()
    return " ".join(words)