From 9a97b75d717bf0c735f470677c988c8ccebe7146 Mon Sep 17 00:00:00 2001 From: leigh-mil Date: Thu, 14 Mar 2019 14:05:16 -0400 Subject: [PATCH] Use NoAccessError instead of NotFoundError where a resource exists but the user cannot access it because of the state of the resource --- atst/routes/portfolios/task_orders.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/atst/routes/portfolios/task_orders.py b/atst/routes/portfolios/task_orders.py index dd7856a7..6f2be63f 100644 --- a/atst/routes/portfolios/task_orders.py +++ b/atst/routes/portfolios/task_orders.py @@ -126,9 +126,12 @@ def resend_invite(portfolio_id, task_order_id, form=None): invitation = Invitations.lookup_by_portfolio_and_user(portfolio, officer) - if not invitation or (invitation.status is not InvitationStatus.PENDING): + if not invitation: raise NotFoundError("invitation") + if invitation.status is not InvitationStatus.PENDING: + raise NoAccessError("invitation") + Invitations.revoke(token=invitation.token) invite_service = InvitationService( @@ -210,7 +213,7 @@ def task_order_invitations(portfolio_id, task_order_id): form=form, ) else: - raise NotFoundError("task_order") + raise NoAccessError("task_order") @portfolios_bp.route(