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())
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)
def get_categories(): """ Gets the list of categories. """ # TODO: pagination return jsonify(Category.all())
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)