drafts: Make the ID of the draft a part of the draft dict.

Then because the ID is now part of the draft dict, we can
(and do) change the structure of the "drafts" parameter
returned from `GET /drafts` from an object (mapping ID to
data) to an array.

Signed-off-by: Hemanth V. Alluri <hdrive1999@gmail.com>
This commit is contained in:
Hemanth V. Alluri
2020-08-06 11:40:35 +05:30
committed by Tim Abbott
parent 8d59fd2f45
commit 99cf37dc51
3 changed files with 22 additions and 14 deletions

View File

@@ -87,7 +87,7 @@ def further_validated_draft_dict(draft_dict: Dict[str, Any],
def fetch_drafts(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
user_drafts = Draft.objects.filter(user_profile=user_profile).order_by("last_edit_time")
draft_dicts = {str(draft.id): draft.to_dict() for draft in user_drafts}
draft_dicts = [draft.to_dict() for draft in user_drafts]
return json_success({"count": user_drafts.count(), "drafts": draft_dicts})
@has_request_variables