Add ContentDownloadRequest
viewset and connect with 'My Downloads'
#10379
Labels
APP: Learn
Re: Learn App (content, quizzes, lessons, etc.)
DEV: backend
Python, databases, networking, filesystem...
DEV: frontend
P0 - critical
Priority: Release blocker or regression
TAG: new feature
New user-facing feature
Milestone
Depends on: #10365
Background
In order to provide the backend for the 'My Downloads' page, we need a new API viewset that will return a list of users downloads.
Deliverables
The
ContentDownloadRequestViewSet
a) It should inherit
ValuesViewset
b) It should operate upon the model
ContentDownloadRequest
The
ContentDownloadRequestViewSet
: list responsec) It should always filter the queryset for the request user. For example:
d) It should filter out any download requests that have a corresponding removal. For example:
e) It should map the model field
source_id
to the response fielduser_id
f) It should annotate
ContentNode
metadata for each request, either returning from stored withinContentDownloadRequest.metadata
or preferablyContentNode
if the metadata has already been importedtitle
,kind
,learning_activities
, andtotal_size
of necessary filesg) It should paginate the list response in groups of 25
The
ContentDownloadRequestViewSet
: request creationThere are two cases to handle for request creation:
ContentDownloadRequest
model that matches this resource for this user - in which case the following steps should be taken:a) It should allow creation of a
ContentDownloadRequest
model for a userb) It should create the model with the appropriate fields. See
ContentRequest.build_for_user
c) It should accept metadata to store in
ContentRequest.metadata
for rendering until metadata has been importedThis should be robust to the request already existing, and not error.
ContentRemovalRequest
model that matches this resource for this user, in which case it should be deleted.In normal operation only one of these cases will be true, but it is probably safer to handle both on every creation request to be sure.
The
ContentDownloadRequestViewSet
: request deletiona) It should create a
ContentRemovalRequest
model for a userb) It should create the model with the appropriate fields. See
ContentRequest.build_for_user
This should be robust to the removal already existing and not error.
The composable
useDownloadRequests
a) It should be updated to query the new API viewset added above
Note: there are slight differences in the fields wrt what has been implemented on the frontend
The Vue component
DownloadsList
a) It should be updated with changes to the
useDownloadRequests
composableb) It should be updated to handle the API response fields
Acceptance criteria
The 'My Downloads' page should become functional as designed in the Figma spec https://www.figma.com/file/MpCG7r5PULOCJsEvnTSti8/Android-Designs-2022?node-id=194-2922
References
#10137
The text was updated successfully, but these errors were encountered: