Пример #1
0
def confirm_raw_picture():
    ''' Moves a RawPicture from UNKNOWN to FACE_PICTURE '''
    facebook_id = request.form.get('facebook_id', None)
    try:
        picture_width = int(request.form.get('picture_width', None))
        picture_height = int(request.form.get('picture_height', None))
    except ValueError:
        return error_response("incorrect picture sizes")

    if not facebook_id:
        return error_response(u"`facebook_id` not found")

    return success_response(
        mark_raw_picture_confirmed(facebook_id, picture_width, picture_height))
Пример #2
0
def confirm_raw_picture():
    ''' Moves a RawPicture from UNKNOWN to FACE_PICTURE '''
    facebook_id = request.form.get('facebook_id', None)
    try:
        picture_width = int(request.form.get('picture_width', None))
        picture_height = int(request.form.get('picture_height', None))
    except ValueError:
        return error_response("incorrect picture sizes")

    if not facebook_id:
        return error_response(u"`facebook_id` not found")

    return success_response(mark_raw_picture_confirmed(facebook_id,
                                                       picture_width,
                                                       picture_height))
Пример #3
0
def detach_face():
    face_id = request.form.get('face_id')
    if not face_id:
        return error_response(u"`face_id` not found")

    delete_face(face_id)
    return success_response()
Пример #4
0
def detach_face():
    face_id = request.form.get('face_id')
    if not face_id:
        return error_response(u"`face_id` not found")

    delete_face(face_id)
    return success_response()
Пример #5
0
def face_refresh(user):
    face_id = request.form.get('face_id')
    if not face_id:
        return error_response("No `face_id`.")

    response = do_face_refresh(face_id, user)

    return success_response(response)
Пример #6
0
def face_refresh(user):
    face_id = request.form.get('face_id')
    if not face_id:
        return error_response("No `face_id`.")

    response = do_face_refresh(face_id, user)

    return success_response(response)
Пример #7
0
def complete_raw_picture():
    ''' Moves a RawPicture from FACE_PICTURE to FACE_DONE '''
    facebook_id = request.form.get('facebook_id')
    if not facebook_id:
        return error_response(u"`facebook_id` not found")

    mark_raw_picture_complete(facebook_id)
    return success_response()
Пример #8
0
def complete_raw_picture():
    ''' Moves a RawPicture from FACE_PICTURE to FACE_DONE '''
    facebook_id = request.form.get('facebook_id')
    if not facebook_id:
        return error_response(u"`facebook_id` not found")

    mark_raw_picture_complete(facebook_id)
    return success_response()
Пример #9
0
def tag_face(user):
    face_id = request.form.get('face_id', None)
    tag_id = request.form.get('tag_id', None)
    if not face_id or not tag_id:
        return error_response("Missing `tag_id` or `face_id")

    add_tag_to_face(face_id, tag_id, user)

    return success_response(do_face_refresh(face_id, user))
Пример #10
0
    def test_error_message(self):
        response = error_response('test message error', 500)
        data = json.loads(response[0].data.decode())
        self.assertEqual(response[1], 500)
        self.assertEqual('fail', data['status'])
        self.assertEqual('test message error', data['message'])

        #Al final del archivo, escribimos una condición para que se pueda ejecutar la herramienta de prueba nativa de Python
        if __name__ == '__main__':
        unittest.main()
Пример #11
0
def detach_raw_picture():
    ''' Moves a RawPicture from UNKNOWN to BAD_PICTURE '''
    facebook_ids = request.form.getlist('facebook_ids[]')
    if not facebook_ids:
        return error_response(u"`facebook_ids` not found")

    # print(facebook_ids)
    for facebook_id in facebook_ids:
        if not facebook_id:
            continue
        mark_bad_raw_picture(facebook_id)

    return success_response()
Пример #12
0
def detach_raw_picture():
    ''' Moves a RawPicture from UNKNOWN to BAD_PICTURE '''
    facebook_ids = request.form.getlist('facebook_ids[]')
    if not facebook_ids:
        return error_response(u"`facebook_ids` not found")

    # print(facebook_ids)
    for facebook_id in facebook_ids:
        if not facebook_id:
            continue
        mark_bad_raw_picture(facebook_id)

    return success_response()
Пример #13
0
def add_single_face():
    facebook_id = request.form.get('facebook_id', None)
    x = request.form.get('face_x', None)
    y = request.form.get('face_y', None)
    width = request.form.get('face_width', None)
    height = request.form.get('face_height', None)

    for v in (x, y, width, height):
        try:
            v = int(v)
        except ValueError:
            pass

    if facebook_id is None or x is None or y is None or width is None or height is None:
        return error_response("incorrect parameters")

    face = create_single_face(facebook_id, x, y, width, height)
    return success_response(face)
Пример #14
0
def add_single_face():
    facebook_id = request.form.get('facebook_id', None)
    x = request.form.get('face_x', None)
    y = request.form.get('face_y', None)
    width = request.form.get('face_width', None)
    height = request.form.get('face_height', None)

    for v in (x, y, width, height):
        try:
            v = int(v)
        except ValueError:
            pass

    if facebook_id is None or x is None or y is None or width is None or height is None:
        return error_response("incorrect parameters")

    face = create_single_face(facebook_id, x, y, width, height)
    return success_response(face)
Пример #15
0
def process_user_stream():
    ''' Retrieves User's facebook wall pictures

        params (GET):
            token: facebook token

        returns: success '''
    token = request.args.get('token', None)
    if not token:
        return error_response(u"No TOKEN!", silent=True)
    print(token)

    user_infos = get_data_from_fql('/me', token, as_fql=False)

    user = get_create_user_from(user_infos.get('id'), user_type=LOGGED_IN)
    user = update_user_details(user, user_infos)
    from pprint import pprint as pp ; pp(user)

    execute_facebook_stream_processing.apply_async([token])

    session_id = create_session(user.get('ident'), user.get('type'))

    return session_response(session_id)
Пример #16
0
def process_user_stream():
    ''' Retrieves User's facebook wall pictures

        params (GET):
            token: facebook token

        returns: success '''
    token = request.args.get('token', None)
    if not token:
        return error_response(u"No TOKEN!", silent=True)
    print(token)

    user_infos = get_data_from_fql('/me', token, as_fql=False)

    user = get_create_user_from(user_infos.get('id'), user_type=LOGGED_IN)
    user = update_user_details(user, user_infos)
    from pprint import pprint as pp
    pp(user)

    execute_facebook_stream_processing.apply_async([token])

    session_id = create_session(user.get('ident'), user.get('type'))

    return session_response(session_id)
Пример #17
0
 def test_error_message(self):
     response = error_response('test message error', 500)
     data = json.loads(response[0].data.decode())
     self.assertEqual(response[1], 500)
     self.assertEqual('fail', data['status'])
     self.assertEqual('test message error', data['message'])
Пример #18
0
def vote_face(user):
    face_id = request.form.get('face_id', None)
    if not face_id:
        return error_response("No face_id to vote for.")

    return success_response(vote_for_face(face=face_id, user=user))
Пример #19
0
def add_face_to_favorite(user):
    face_id = request.form.get('face_id', None)
    if not face_id:
        return error_response("No face_id to fav.")
    create_favorite_for(user, face_id)
    return success_response(do_face_refresh(face_id, user))