Skip to content
Merged
1 change: 1 addition & 0 deletions doc/release/RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html

### Bugfix
* [OSDEV-1388](https://opensupplyhub.atlassian.net/browse/OSDEV-1388) - The waiter from boto3 cannot wait more than half an hour so we replaced it with our own.
* [OSDEV-1482](https://opensupplyhub.atlassian.net/browse/OSDEV-1482) - The `GET api/v1/moderation-events/{moderation_id}` endpoint return single response instead of array with one item.

### What's new
* [OSDEV-1175](https://opensupplyhub.atlassian.net/browse/OSDEV-1175) - New Moderation Queue Page was integrated with `GET api/v1/moderation-events/` endpoint that include pagination, sorting and filtering.
Expand Down
13 changes: 12 additions & 1 deletion src/django/api/views/v1/moderation_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,18 @@ def retrieve(self, _, pk=None):
query_body
)

return Response(response)
events = response.get("data", [])

if len(events) == 0:
return Response(
data={
"detail": 'The moderation event with the '
'given uuid was not found.',
},
status=status.HTTP_404_NOT_FOUND,
)

return Response(events[0])

@handle_errors_decorator
def partial_update(self, request, pk=None):
Expand Down
6 changes: 2 additions & 4 deletions src/tests/v1/test_moderation_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ def test_moderation_events_exact(self):
headers=self.basic_headers,
)

result = response.json()
self.assertEqual(result['count'], 0)
self.assertEqual(response.status_code, 404)

moderation_id = '1f35a90f-70a0-4c3e-8e06-2ed8e1fc6800'
response = requests.get(
Expand All @@ -22,8 +21,7 @@ def test_moderation_events_exact(self):
)

result = response.json()
self.assertEqual(result['count'], 1)
self.assertEqual(result['data'][0]['moderation_id'], moderation_id)
self.assertEqual(result['moderation_id'], moderation_id)

def test_moderation_events_status(self):
response = requests.get(
Expand Down