Skip to content

Commit

Permalink
consider 'CONSUMED' state in state transition validation (bcgov#1562)
Browse files Browse the repository at this point in the history
  • Loading branch information
eve-git authored Aug 20, 2024
1 parent 2752507 commit e68f26f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/namex/services/name_request/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ def valid_state_transition(user, nr, new_state):
return True

# NR is in a final state, but maybe the user wants to pull it back for corrections
if nr.stateCd in State.COMPLETED_STATE:
if new_state == State.CONSUMED:
return nr.stateCd == State.APPROVED or (nr.stateCd == State.CONDITIONAL and (nr.consentFlag in ('R', 'N')))
elif nr.stateCd in State.COMPLETED_STATE:
if not jwt.validate_roles([User.APPROVER]) and not jwt.validate_roles([User.EDITOR]):
return False
# return jsonify({"message": "Only Names Examiners can alter completed Requests"}), 401
Expand All @@ -178,6 +180,7 @@ def valid_state_transition(user, nr, new_state):
elif nr.stateCd == State.INPROGRESS:
if nr.userId != user.id:
return False

return True


Expand Down

0 comments on commit e68f26f

Please sign in to comment.