コード例 #1
0
ファイル: categories.py プロジェクト: LazyPanda07/Flask
def get_category_by_id(id: int, user):
    categories_service = CategoriesService()

    try:
        return categories_service.get_category_by_id(id, user)
    except UnAuthorized:
        return json_response.unauthorized()
    except CategoryDoesntExist:
        return json_response.not_found()
コード例 #2
0
ファイル: categories.py プロジェクト: LazyPanda07/Flask
def get_categories(user):
    categories_service = CategoriesService()

    try:
        return json_response.success(categories_service.get_categories(user))
    except UnAuthorized:
        return json_response.unauthorized()
    except NoCategories:
        return json_response.not_found()
コード例 #3
0
ファイル: categories.py プロジェクト: LazyPanda07/Flask
def delete_category_by_id(id: int, user):
    categories_service = CategoriesService()

    try:
        return json_response.success(
            categories_service.delete_category_by_id(id, user))
    except UnAuthorized:
        return json_response.unauthorized()
    except CategoryDoesntExist:
        return json_response.not_found()
コード例 #4
0
def delete_transaction(id: int, user):
    transaction_service = TransactionsService()

    try:
        transaction_service.delete_transaction_by_id(id, user)
        return json_response.deleted()
    except UnAuthorized:
        return json_response.unauthorized()
    except TransactionDoesntExist:
        return json_response.not_found()
コード例 #5
0
def get_transaction_by_id(id: int, user):
    transaction_service = TransactionsService()

    try:
        return json_response.success(
            transaction_service.get_transaction_by_id(id, user))
    except UnAuthorized:
        return json_response.unauthorized()
    except TransactionDoesntExist:
        return json_response.not_found()
コード例 #6
0
def get_transactions(user):
    transaction_service = TransactionsService()

    try:
        return json_response.success(
            transaction_service.get_transactions(user))
    except UnAuthorized:
        return json_response.unauthorized()
    except NoTransactions:
        return json_response.not_found()
コード例 #7
0
ファイル: categories.py プロジェクト: LazyPanda07/Flask
def edit_category_by_id(id: int, user):
    data = request.get_json()
    categories_service = CategoriesService()

    try:
        return json_response.success(
            categories_service.edit_category_by_id(id, data, user))
    except UnAuthorized:
        return json_response.unauthorized()
    except CategoryDoesntExist:
        return json_response.not_found()
コード例 #8
0
def edit_transaction(id: int, user):
    data = request.get_json()
    transaction_service = TransactionsService()

    try:
        return json_response.success(
            transaction_service.edit_transaction_by_id(id, data, user))
    except UnAuthorized:
        return json_response.unauthorized()
    except TransactionDoesntExist:
        return json_response.not_found()