Skip to content

Commit

Permalink
#145: Remove to_dict() conversion on PATCH entity endpoints
Browse files Browse the repository at this point in the history
- Python ICAT backend doesn't need this conversion, so this has been moved into the relevant DB backend helper function
  • Loading branch information
MRichards99 committed Oct 1, 2020
1 parent 0747c5b commit a4baba3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
4 changes: 2 additions & 2 deletions common/database/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,14 @@ def patch_entities(table, json_list):
if key.upper() == "ID":
update_row_from_id(table, json_list[key], json_list)
result = get_row_by_id(table, json_list[key])
results.append(result)
results.append(result.to_dict())
else:
for entity in json_list:
for key in entity:
if key.upper() == "ID":
update_row_from_id(table, entity[key], entity)
result = get_row_by_id(table, entity[key])
results.append(result)
results.append(result.to_dict())
if len(results) == 0:
raise BadRequestError(f" Bad request made, request: {json_list}")

Expand Down
9 changes: 2 additions & 7 deletions src/resources/entities/entity_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,8 @@ def post(self):

def patch(self):
return (
list(
map(
lambda x: x.to_dict(),
backend.update(
get_session_id_from_auth_header(), table, request.json
),
)
backend.update(
get_session_id_from_auth_header(), table, request.json
),
200,
)
Expand Down

0 comments on commit a4baba3

Please sign in to comment.