Ejemplo n.º 1
0
def handler(event, context):
    session = SessionFacade.get_session_from_event(event)

    team = TeamRequestFacade.get_team_by_oid(session.real_user.team.oid)
    if team is not None and team.leader.oid == session.user.oid:
        requests = TeamRequestFacade.get_requests_by_oid_team(session.real_user.team.oid)
    else:
        requests = TeamRequestFacade.get_requests_by_oid_user(session.user.oid)

    return buid_default_response(status=200, body=json.dumps(requests, cls=SWMJSONEncoder))
Ejemplo n.º 2
0
def handler(event, context):
    session = SessionFacade.get_session_from_event(event)
    user = session.real_user

    json_body = user.to_dict()
    json_body.pop('password')
    json_body.pop('oid_team')
    json_body['team'] = user.team

    return buid_default_response(status=200,
                                 body=json.dumps(json_body,
                                                 cls=SWMJSONEncoder))
Ejemplo n.º 3
0
def handler(event, context):
    path_params = get_path_params(event)
    if not path_params:
        raise RequestException("Request inválido!")

    oid_request_team = path_params.get('oid')
    if not oid_request_team:
        raise RequestException("Solicitação de entrada no time não informado")

    session = SessionFacade.get_session_from_event(event)

    team_request = TeamRequestFacade.approve_request(session.real_user, oid_request_team)

    return buid_default_response(status=200, body=json.dumps(team_request, cls=SWMJSONEncoder))
Ejemplo n.º 4
0
def handler(event, context):
    path_parameters = get_path_params(event)
    oid_pitch = path_parameters.get('oid')

    session = SessionFacade.get_session_from_event(event)

    PitchFacade.vote_pitch(oid_pitch, session)

    return buid_default_response(
        status=200,
        body=json.dumps(
            {'vote': True},
            cls=SWMJSONEncoder
        )
    )
Ejemplo n.º 5
0
def handler(event, context):
    body = get_json_body(event)
    if not body:
        raise RequestException("Request inválido!")

    oid_team = body.get('oid_team')
    if not oid_team:
        raise RequestException("Time não informado")

    session = SessionFacade.get_session_from_event(event)

    team_request = TeamRequestFacade.create_new_request(
        session.real_user, oid_team)

    return buid_default_response(status=201,
                                 body=json.dumps(team_request,
                                                 cls=SWMJSONEncoder))
Ejemplo n.º 6
0
def handler(event, context):
    body = event.get('body')
    if not body:
        raise RequestException("Request inválido!")

    path_params = get_path_params(event)
    oid = path_params.get('oid', None)
    if not oid:
        print(json.dumps(path_params))
        raise RequestException("ID inválido")

    session = SessionFacade.get_session_from_event(event)

    user_photo = UserPhotoFacade.update_user_photo(session, oid, body)

    return buid_default_response(status=200,
                                 body=json.dumps(user_photo,
                                                 cls=SWMJSONEncoder))
Ejemplo n.º 7
0
def handler(event, context):
    path_params = get_path_params(event)
    oid = path_params.get('oid', None)
    if not oid:
        print(json.dumps(path_params))
        raise RequestException("ID inválido")

    session = SessionFacade.get_session_from_event(event)

    user_photo = UserPhotoFacade.get_user_photo(session, oid)

    if user_photo:
        return buid_default_response(status=200,
                                     body=user_photo.data,
                                     headers={'Content-Type': 'image/jpeg'},
                                     base64encoded=True)
    else:
        return buid_default_response(status=404,
                                     body=json.dumps(
                                         {'message': 'Imagem não encontrada'},
                                         cls=SWMJSONEncoder))