示例#1
0
def _make_response(form, include_user=True, include_auth_token=False):
    has_errors = len(form.errors) > 0

    if has_errors:
        api.abort(400, message=form.errors)
    else:
        response = dict()
        if include_user:
            response['user_id'] = form.user.id
        if include_auth_token:
            token = form.user.get_auth_token()
            response['authentication_token'] = token

    return response
示例#2
0
文件: views.py 项目: amorwilliams/gst
def _make_response(form, include_user=True, include_auth_token=False):
    has_errors = len(form.errors) > 0

    if has_errors:
        api.abort(400, message=form.errors)
    else:
        response = dict()
        if include_user:
            response["user_id"] = form.user.id
        if include_auth_token:
            token = form.user.get_auth_token()
            response["authentication_token"] = token

    return response
示例#3
0
 def get(self, id):
     posts = Post.query.filter_by(id=id).first()
     if not posts:
         api.abort(404)
     return posts
示例#4
0
文件: views.py 项目: amorwilliams/gst
 def get(self, id):
     posts = Post.query.filter_by(id=id).first()
     if not posts:
         api.abort(404)
     return posts