コード例 #1
0
ファイル: fetch.py プロジェクト: rafagonc/share
def fetch_user_request_impl(args):
    try:
        user = user_from_token(args['token'])
        user_to_fetch = user_from_id(args['user_id'])
        groups = json.loads(GroupSchema(many=True).dumps(groups_from_user(user_to_fetch)).data)
        posts = json.loads(PostSchema(many=True).dumps(posts_from_user_paginate(user, user_to_fetch)).data)
        marshal_user = json.loads(UserSchemaWithPostsAndGroups().dumps(user_to_fetch).data)
        response = dict(user=marshal_user, posts=posts, groups=groups)
        return Response(True, "User Searched", json.dumps(response)).output()
    except Exception as exception:
        return Response(False, str(exception), None).output()
コード例 #2
0
ファイル: login.py プロジェクト: rafagonc/share
def login_request_impl(args):
    try:
        user = user_from_facebook_id(args['facebook_id'])
        delete_last_token_from_facebook_id(args['facebook_id'])
        if user is not None:
            __set_values_for_user_from_args(user, args)
            __generate_token_for_user(user)

            #needs to call it to assign to builtin, we need to use it later on group hybrid property.
            user_from_token(user.user_token.token)

            user_groups = json.loads(GroupSchema(many=True).dumps(groups_from_user(user)).data)
            user_data = json.loads(MyselfSchema().dumps(user).data)
            return Response(True, "Login Succeed", json.dumps(dict(groups=user_groups, myself=user_data))).output()
        else:
            return signup_request_impl(args)
    except Exception as exception:
        return Response(False, str(exception), None).output()