Skip to content

Commit

Permalink
edit name choice validation and pm test updates (#538)
Browse files Browse the repository at this point in the history
Signed-off-by: Kial Jinnah <[email protected]>
  • Loading branch information
kialj876 authored and katiemcgoff committed Mar 1, 2019
1 parent c96c35b commit 6a34ec2
Show file tree
Hide file tree
Showing 3 changed files with 1,560 additions and 6 deletions.
11 changes: 10 additions & 1 deletion api/namex/resources/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def patch(nr, *args, **kwargs):
nrd.save_to_db()
EventRecorder.record(user, Event.PATCH, nrd, json_input)

except (Exception) as err:
except Exception as err:
current_app.logger.debug(err.with_traceback(None))
return jsonify(message='Internal server error'), 500

Expand Down Expand Up @@ -526,6 +526,15 @@ def put(nr, *args, **kwargs):
if not services.name_request.valid_state_transition(user, nrd, state):
return jsonify(message='you are not authorized to make these changes'), 401

name_choice_exists = {1: False, 2: False, 3: False}
for name in json_input.get('names', None):
if name['name'] and name['name'] is not '':
name_choice_exists[name['choice']] = True
if not name_choice_exists[1]:
return jsonify(message='Data does not include a name choice 1'), 400
if not name_choice_exists[2] and name_choice_exists[3]:
return jsonify(message='Data contains a name choice 3 without a name choice 2'), 400

try:
existing_nr = RequestDAO.get_inprogress(user)
if existing_nr:
Expand Down
Loading

0 comments on commit 6a34ec2

Please sign in to comment.