Пример #1
0
def favour_propos_user(user_id):
    form = CheckAccessTokenForm()

    if not form.validate_on_submit():
        return generate_error_response(form.errors)

    return generate_data_response(json.dumps([p.as_dict() for p in User.get_favour_propos(user_id)]))
Пример #2
0
def propos_user(user_id):
    form = CheckAccessTokenForm()

    if not form.validate_on_submit():
        return generate_error_response(form.errors)

    user = User.query.filter(User.id == user_id).first()

    if user:
        propos = list((p.as_dict_without_author() for p in user.propositions))

        return generate_data_response(propos)
    else:
        return generate_error_response(text=errors.NOT_FOUND)
Пример #3
0
def get_user(user_id):
    form = CheckAccessTokenForm()

    if not form.validate_on_submit():
        return generate_error_response(form.errors)

    if not User.query.filter_by(access_token=form.access_token.data).first():
        return generate_error_response(text=errors.UNATHORIZED)

    user = User.query.filter(User.id == user_id).first()

    if user:
        return generate_data_response(user.as_dict())
    else:
        return generate_error_response(text=errors.NOT_FOUND)