Example #1
0
def create_face_picture(url, facebook_id, x, y, width, height):
    global FacePictures
    raw = get_raw_picture_by(facebook_id)
    face_id = uuid.uuid4().hex
    doc = {
        _FACE_ID: face_id,
        'url': url,
        'face_x': x,
        'face_y': y,
        'face_width': width,
        'face_height': height,
        'source_width': raw.get('width'),
        'source_height': raw.get('height'),
        'facebook_id': facebook_id,
        'datetime': datetime.datetime.now(),
        'nb_votes': 0,
        'nb_votes_total': 0,
        'tag': NOTTAGGED,
        'tags': {},
        'views': 0,
        'views_total': 0,
        'score': 0,
        'score_total': 0,
        'nb_favorited': 0,
        'favorite_votes': 0,
        'favorite_votes_total': 0,
        'bonusmalus': [],
        'bonusmalus_total': [],
        'has_won': False
    }
    FacePictures.insert(doc)
    return get_face_from(face_id)
Example #2
0
def create_face_picture(url, facebook_id, x, y, width, height):
    global FacePictures
    raw = get_raw_picture_by(facebook_id)
    face_id = uuid.uuid4().hex
    doc = {_FACE_ID: face_id,
           'url': url,
           'face_x': x,
           'face_y': y,
           'face_width': width,
           'face_height': height,
           'source_width': raw.get('width'),
           'source_height': raw.get('height'),
           'facebook_id': facebook_id,
           'datetime': datetime.datetime.now(),
           'nb_votes': 0,
           'nb_votes_total': 0,
           'tag': NOTTAGGED,
           'tags': {},
           'views': 0,
           'views_total': 0,
           'score': 0,
           'score_total': 0,
           'nb_favorited': 0,
           'favorite_votes': 0,
           'favorite_votes_total': 0,
           'bonusmalus': [],
           'bonusmalus_total': [],
           'has_won': False}
    FacePictures.insert(doc)
    return get_face_from(face_id)
Example #3
0
def get_raw_picture_for_facing(facebook_id=None):
    ''' Get details of picture for facing or pick one if no request '''
    global RawPictures
    # this will either return the request picture or the first one avail.
    picture = get_raw_picture_by(facebook_id,
                                 extra_query={'type': FACE_PICTURE},
                                 select=['url', _FACEBOOK_ID, 'type'])
    if not picture is None:
        faces = get_faces_for_raw_picture(picture.get(_FACEBOOK_ID))
    else:
        faces = []
    return (picture, faces)
Example #4
0
def get_raw_picture_for_facing(facebook_id=None):
    ''' Get details of picture for facing or pick one if no request '''
    global RawPictures
    # this will either return the request picture or the first one avail.
    picture = get_raw_picture_by(facebook_id,
                                 extra_query={'type': FACE_PICTURE},
                                 select=['url', _FACEBOOK_ID, 'type'])
    if not picture is None:
        faces = get_faces_for_raw_picture(picture.get(_FACEBOOK_ID))
    else:
        faces = []
    return (picture, faces)
Example #5
0
def create_single_face(facebook_id, x, y, width, height):
    raw_picture = get_raw_picture_by(facebook_id)
    picture = create_face_picture(raw_picture.get('url'), facebook_id, x, y,
                                  width, height)
    return picture
Example #6
0
def create_single_face(facebook_id, x, y, width, height):
    raw_picture = get_raw_picture_by(facebook_id)
    picture = create_face_picture(raw_picture.get('url'),
                                  facebook_id, x, y, width, height)
    return picture