Beispiel #1
0
def route_user_add():
    with postgres.get_db_conn() as conn:
        auth.check_auth_token(conn,
                              auth.header_auth_token(request),
                              check_is_admin=True)
        user_id = user.form_user_id(request)
        user.verify_not_exists(conn, user_id)
        auth_token = user.add(conn, user_id, user.form_password(request))
        return jsonify(auth_token=auth_token)
Beispiel #2
0
def route_number_set():
    with postgres.get_db_conn() as conn:
        user_id = auth.check_auth_token(conn,
                                        auth.header_auth_token(request),
                                        check_is_admin=True)
        number_id = number.form_id(request)
        number.verify_user_added(conn, number_id, user_id)
        number.update(conn, number_id, number.form_new(request))
        return ""
Beispiel #3
0
def route_number_remove():
    with postgres.get_db_conn() as conn:
        auth.check_auth_token(conn,
                              auth.header_auth_token(request),
                              check_is_admin=True)
        number_id = number.form_id(request)
        number.verify_exists(conn, number_id)
        number.remove(conn, number_id)
        return ""
Beispiel #4
0
def route_number_add_user():
    with postgres.get_db_conn() as conn:
        auth.check_auth_token(conn,
                              auth.header_auth_token(request),
                              check_is_admin=True)
        number_id = number.form_id(request)
        number.verify_exists(conn, number_id)
        user_id = user.form_user_id(request)
        user.verify_exists(conn, user_id)
        number.verify_user_not_added(conn, number_id, user_id)
        number.add_user(conn, number_id, user_id)
        return ""
Beispiel #5
0
def route_number_get_next():
    with postgres.get_db_conn() as conn:
        user_id = auth.check_auth_token(conn, auth.header_auth_token(request))
        number_id = number.form_id(request)
        number.verify_user_added(conn, number_id, user_id)
        return str(number.get_next(conn, number_id))