-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: add collection notes endpoint #444
Changes from 1 commit
3060b3b
d830899
09b7c71
79bf4ec
01ad267
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,6 +232,21 @@ def metadata(self, request, pk=None): | |
|
||
return Response(metadata) | ||
|
||
@action(detail=True) | ||
def notes(self, request, pk=None): | ||
"""Return the notes for the compiled collection and its parent collection.""" | ||
compiled_collection = get_object_or_404(Collection, pk=pk) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why request the compiled collection? I think it'd be more generic to request the root collection, and then get notes from all child collections. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was following the same approach as the metadata endpoint, as I thought the registry would probably ask for the compiled collection. But you are right and I will change it to the root collection instead |
||
collection = compiled_collection.get_root_parent() | ||
|
||
if compiled_collection.transform_type != Collection.Transform.COMPILE_RELEASES: | ||
return Response("The collection must be a compiled collection", status=status.HTTP_400_BAD_REQUEST) | ||
|
||
notes_db = CollectionNote.objects.filter(collection_id__in=[compiled_collection.id, collection.id]) | ||
notes = {level: [] for level in CollectionNote.Level.values} # noqa: PD011 | ||
for note in notes_db: | ||
notes[note.code].append([note.note, note.data]) | ||
return Response(notes) | ||
|
||
@extend_schema(responses=TreeSerializer(many=True)) | ||
@action(detail=True) | ||
def tree(self, request, pk=None): | ||
|
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.
The other views use
@extend_schema
to define the output format. This is only to improve the OpenAPI docs. You can create a follow-up issue instead.