def category_json(request, category_id): category = Category.get_by_id(category_id) if not category: return render_json_response({ 'api':{ 'success': False, 'msg': 'Category %s not found' % category_id } }, status=400) if request.method == 'GET': return get_category(category) if request.method == 'DELETE': return delete_category(request, category) if request.method == 'PUT': return put_category(request, category) return render_json_response({ 'api':{ 'success':False, 'msg': 'Request method %s not supported' % request.method } }, status=400)
def category_create(request): return put_category(request, None, True)