Exemple #1
0
def not_authenticated_response():
    return JSONResponse(
        status_code=status.HTTP_400_BAD_REQUEST,
        content=fct.generate_error_dict(
            status=status.HTTP_400_BAD_REQUEST,
            key=NOT_AUTHENTICATED,
            message='Request requires valid authentication access token.'))
Exemple #2
0
def invalid_token_res():
    return JSONResponse(
        status_code=status.HTTP_400_BAD_REQUEST,
        content=fct.generate_error_dict(
            status=status.HTTP_400_BAD_REQUEST,
            key=INVALID_TOKEN,
            message='The submitted token could not be validated'))
Exemple #3
0
def no_permission_response():
    return JSONResponse(
        status_code=status.HTTP_400_BAD_REQUEST,
        content=fct.generate_error_dict(
            status=status.HTTP_400_BAD_REQUEST,
            key=NO_PERMISSION,
            message='User has no permission to access this action.'))
Exemple #4
0
def invalid_purpose_id_response(usage_purpose: str):
    return JSONResponse(status_code=status.HTTP_400_BAD_REQUEST,
                        content=fct.generate_error_dict(
                            status=status.HTTP_400_BAD_REQUEST,
                            key=INVALID_PURPOSE_ID,
                            message=f'{usage_purpose} is invalid.'))
Exemple #5
0
def user_exists_response(username: str):
    return JSONResponse(status_code=status.HTTP_400_BAD_REQUEST,
                        content=fct.generate_error_dict(
                            status=status.HTTP_400_BAD_REQUEST,
                            key=USER_EXISTS,
                            message=f'{username} username already exists.'))
Exemple #6
0
def server_error_response():
    return JSONResponse(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
                        content=fct.generate_error_dict(
                            status=status.HTTP_500_INTERNAL_SERVER_ERROR,
                            key=SERVER_ERROR,
                            message='Something went wrong'))
Exemple #7
0
def malformed_date_res():
    return JSONResponse(status_code=status.HTTP_400_BAD_REQUEST,
                        content=fct.generate_error_dict(
                            status=status.HTTP_400_BAD_REQUEST,
                            key=MALFORMED_DATE,
                            message=f'Date format should be {db.DATE_FORMAT}'))
Exemple #8
0
def no_record_found_res():
    return JSONResponse(status_code=status.HTTP_400_BAD_REQUEST,
                        content=fct.generate_error_dict(
                            status=status.HTTP_400_BAD_REQUEST,
                            key=NO_RECORD_FOUND,
                            message='No record is available for this date'))
Exemple #9
0
def wrong_password_response():
    return JSONResponse(status_code=status.HTTP_400_BAD_REQUEST,
                        content=fct.generate_error_dict(
                            status=status.HTTP_400_BAD_REQUEST,
                            key=WRONG_PASSWORD,
                            message='The password is invalid'))
Exemple #10
0
def user_not_found_response(username: str):
    return JSONResponse(status_code=status.HTTP_400_BAD_REQUEST,
                        content=fct.generate_error_dict(
                            status=status.HTTP_400_BAD_REQUEST,
                            key=USER_NOT_FOUND,
                            message=f'{username} does not exist'))