-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fetch content metadata for serialized assignments in credits_available
response payload
#316
Conversation
""" | ||
Serializer to help return additional content metadata for assignments. These fields should | ||
map more or less 1-1 to the fields in content metadata dicts returned from the | ||
enterprise-catalog `get_content_metadata` response payload. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gives us a common place to hook into any additional data we want from the enterprise-catalog get_content_metadata
endpoint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this pattern of having an isolated place to extract specific fields from get_content_metadata
endpoint as needed.
enterprise_access/apps/api/serializers/content_assignments/assignment.py
Outdated
Show resolved
Hide resolved
record['key']: record for record in content_metadata_list | ||
} | ||
return { | ||
assignment.content_key: metadata_by_key.get(assignment.content_key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[curious, non-blocking] Could there ever be a chance where the assignment's content key is no longer part of the catalog when this gets evaluated? How does the get_content_metadata
API handle content keys that are not part of the catalog?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you'd end up with the assignment's content_key mapping to null here. The situation you're describing is technically possible (content falls out of catalog after allocation), but I'm not sure exactly what should happen in that case. Ideally we'd have a hook in place to error out any unaccepted assignments.
The get_content_metadata
endpoint won't include a record for requested keys that are not in the catalog, but the response is still a 200 as long as the catalog actually exists (even when no requested keys are found within it).
""" | ||
Serializer to help return additional content metadata for assignments. These fields should | ||
map more or less 1-1 to the fields in content metadata dicts returned from the | ||
enterprise-catalog `get_content_metadata` response payload. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this pattern of having an isolated place to extract specific fields from get_content_metadata
endpoint as needed.
e770df8
to
efd6f4e
Compare
efd6f4e
to
0743d0d
Compare
credits_available
response payload
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just a handful of non-blocking nits.
enterprise_access/apps/api/serializers/subsidy_access_policy.py
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,110 @@ | |||
""" | |||
Python API for interacting with content metadata. | |||
TODO: refactor subsidy_access_policy/content_metadata_api.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit/sanity check] Is this TODO part of this PR, or is it slated for future work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slated for future work
…s_available assignments ENT-7878
0743d0d
to
3c0d1a9
Compare
This change allows us to pull-through content metadata from the enteprise-catalog
get_content_metadata
endpoint into serialized assignments contained within responses of thecredits_available
view.For example, in response to
you'd get
Has good drf-spec docs at http://localhost:18270/api/schema/redoc/#tag/Subsidy-Access-Policy-Redemption/operation/api_v1_policy_redemption_credits_available_list
This PR built on top of some serialization changes in #307