Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NRO Decommissioning: Allow user to modify cancel from legacy side#25224 #1664

Merged
merged 3 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/namex/VERSION.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__version__ = '1.2.21c'
__version__ = '1.2.21d'

4 changes: 4 additions & 0 deletions api/namex/resources/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,10 @@ def put(nr, *args, **kwargs):

try:
user = get_or_create_user_by_jwt(g.jwt_oidc_token_info)

current_app.logger.debug(f"User found!")
nrd = RequestDAO.find_by_nr(nr)
current_app.logger.debug(f"nrd found!")
if not nrd:
return make_response(jsonify({"message": "Request:{} not found".format(nr)}), 404)
orig_nrd = nrd.json()
Expand All @@ -728,6 +731,7 @@ def put(nr, *args, **kwargs):
current_app.logger.error("Error when patching NR:{0} Err:{1}".format(nr, err))
return make_response(jsonify({"message": "NR had an internal error"}), 404)

current_app.logger.debug(f"Before valid_state_transition")
if not valid_state_transition(user, nrd, state):
return make_response(jsonify(message='you are not authorized to make these changes'), 401)

Expand Down
2 changes: 2 additions & 0 deletions api/namex/services/name_request/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ def valid_state_transition(user, nr, new_state):
"""
# when the legacy user just created a new NR from legacy side, the user should be allowed to
# modify and cancel it from the legacy side (while the NR still in DRAFT state).
current_app.logger.debug(f"inside valid_state_transition")
if nr.stateCd == State.DRAFT and (new_state == State.DRAFT or new_state == State.CANCELLED):
return True

current_app.logger.debug(f"inside valid_state_transition continue")
if (new_state in (State.APPROVED,
State.REJECTED,
State.CONDITIONAL)) \
Expand Down
Loading