Example #1
0
def set_category_sort():
    """
    Sets the order of the categories.
    """
    if 'categories' not in request.json:
        return api_error('Invalid form.')
    categories = request.json['categories']
    for data in categories:
        category = Category.get(data['id'])
        category.sort_order = data['sort_order']
        category.save()
    return jsonify(Category.all())
Example #2
0
def set_category_sort():
    """
    Sets the order of the categories.
    """
    if 'categories' not in request.json:
        return api_error('Invalid form.')
    categories = request.json['categories']
    for data in categories:
        category = Category.get(data['id'])
        category.sort_order = data['sort_order']
        category.save()
    return jsonify(Category.all())
Example #3
0
 def __init__(self, *args, **kwargs):
     super(ServiceForm, self).__init__(*args, **kwargs)
     self.category.choices = [
         (category.id, category.name) for category in Category.all()
     ]
     self.validate_unique_name = kwargs.get('validate_unique_name', True)
Example #4
0
def get_categories():
    """
    Gets the list of categories.
    """
    # TODO: pagination
    return jsonify(Category.all())
Example #5
0
 def __init__(self, *args, **kwargs):
     super(ServiceForm, self).__init__(*args, **kwargs)
     self.category.choices = [(category.id, category.name)
                              for category in Category.all()]
     self.validate_unique_name = kwargs.get('validate_unique_name', True)
Example #6
0
def get_categories():
    """
    Gets the list of categories.
    """
    # TODO: pagination
    return jsonify(Category.all())