Skip to content

Commit

Permalink
update response object
Browse files Browse the repository at this point in the history
  • Loading branch information
jtmst committed Dec 18, 2024
1 parent 61eddce commit c051f3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 4 additions & 5 deletions bloom_nofos/nofos/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ def create_nofo(request, payload: NofoSchema):
_build_nofo(nofo, sections)
nofo.save()

return 201, {
"message": f"NOFO {nofo.id} imported successfully",
"Location": f"/api/nofos/{nofo.id}",
"nofo": nofo,
}
serialized_nofo = NofoSchema.from_orm(nofo)
return_response = api.create_response(request, serialized_nofo, status=201)
return_response.headers["Location"] = f"/api/nofos/{nofo.id}"
return return_response

except ValidationError as e:
return 400, {"message": "Model validation error", "details": e.message_dict}
Expand Down
2 changes: 0 additions & 2 deletions bloom_nofos/nofos/api/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,4 @@ class ErrorSchema(Schema):


class SuccessSchema(Schema):
message: str
Location: str
nofo: NofoSchema

0 comments on commit c051f3a

Please sign in to comment.