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

22774 make consume compatible to existing LEAR process #1565

Merged
merged 6 commits into from
Aug 22, 2024
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: 1 addition & 2 deletions api/namex/VERSION.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
__version__ = '1.2.3'

__version__ = '1.2.4'
16 changes: 6 additions & 10 deletions api/namex/resources/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def patch(nr, *args, **kwargs):
return make_response(jsonify({"message": "Request:{} not found".format(nr)}), 404)

if not valid_state_transition(user, nrd, state):
return make_response(jsonify(message='you are not authorized to make these changes'), 401)
return make_response(jsonify(message='Name Request state transition validation failed.'), 401)

# if the user has an existing (different) INPROGRESS NR, revert to previous state (default to HOLD)
existing_nr = RequestDAO.get_inprogress(user)
Expand Down Expand Up @@ -647,22 +647,18 @@ def patch(nr, *args, **kwargs):
nrd.furnished = 'Y'

def consumeName(nrd, json_input):
# Validate the required fields are present and not empty
name_to_consume = json_input.get('name')
if not name_to_consume \
or not json_input.get('consumptionDate') \
or not json_input.get('corpNum'):
return False, '"name", "consumptionDate", and "corpNum" are required and cannot be empty.'
if not json_input.get('corpNum'):
return False, '"corpNum" is required and cannot be empty.'

consumed = False
for nrd_name in nrd.names:
if name_to_consume == nrd_name.name:
nrd_name.consumptionDate = json_input.get('consumptionDate')
if nrd_name.state in (Name.APPROVED, Name.CONDITION):
nrd_name.consumptionDate = datetime.utcnow()
nrd_name.corpNum = json_input.get('corpNum')
consumed = True

if not consumed:
return False, f"The given name '{name_to_consume}' cannot be found to be consumed."
return False, f"Cannot find an Approved or Condition name to be consumed."

return True, None # Return success and no error message

Expand Down
Loading