Skip to content
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

[Tagging] Implement tagging REST API: Retrieve object tags #81

Closed
pomegranited opened this issue Jul 24, 2023 · 0 comments · Fixed by openedx/openedx-learning#68
Closed

Comments

@pomegranited
Copy link

pomegranited commented Jul 24, 2023

Story

"As a content author, I want to see all the tags applied to my content so I can see what needs to be added or changed."

Description

Implement a REST API that allows retrieving the full list of tags applied to a given object.
This ticket implements the API in the oel_tagging library, but a later ticket will use to fetch the tags applied to content edited in Studio.

Completion criteria

Build on/subclass the "taxonomy REST API view" added by #73, and implement these REST API endpoints:

oel_tagging:

GET /tagging/rest_api/v1/object_tags/<object_id>/?taxonomy=<pk>&page_size=<size>&page=1

Bring the above REST API into content_tagging under this path:

GET /api/content_tagging/v1/object_tags/<object_id>/?taxonomy=<pk>&page_size=<size>&page=1

  • Uses oel_tagging.api.get_object_tags to return a paginated list of ObjectTag metadata for the given <object_id>: name, value, taxonomy_id, tag_ref, is_valid
  • The returned list of object tags is sorted (descending) by taxonomy_id, name, value, tag_id -- this will require updating the oel_tagging.api.get_object_tags() method.
  • taxonomy parameter: (optional) Taxonomy pk
    • Return only ObjectTags for the given taxonomy, if it exists.
  • Paginate this data, with a default MAX_PAGE_SIZE = 100, to allow most people to retrieve all of their object tags in one hit.
    Objects with more ObjectTags will need to know where to go to get their next page of data, and so this endpoint should support that too.
  • Bringing the oel_tagging REST API into content_tagging shouldn't require much? You should be able to just register the oel_tagging viewset under the content_tagging REST API router

Automated testing must cover common paths in behavioral specification.

Pagination

Use the same Pagination parameters and serialized response data as was developed for #74.

Behavioral specifications

Suppose the Open edX instance has these taxonomies:

  • system-defined language taxonomy: st1 (enabled) linked to 1 (valid) object tag for object_id="abc".
  • closed taxonomies created by taxonomy admins: t1 (enabled), t2 (disabled), each linked to 20 object tags for object_id="abc"
  • 2 free-text taxonomies created by taxonomy admins: o1 (enabled), o2 (disabled), each linked to 200 object tags for object_id="abc"

Suppose the pagination defaults are:

  • page_size = 100
  • max_page_size = 100
  • page = 1

and the following users:

  • userA: non-staff
  • userS: global staff user

Note: because anyone can view an object tag, there is no difference between what userA and userS see from this endpoint.

/tagging/rest_api/v1/object_tags/<object_id>/

  • When userA or userS requests ^, they receive a list of object tag metadata, max 100, matching the given object_id, and linked to any (or no) taxonomy.

/tagging/rest_api/v1/object_tags/<object_id>/?taxonomy=<pk>

  • When userA or userS requests ^, they receive a list of object tag metadata, max 100, matching the given object_id, with taxonomy_id=<pk>.

/tagging/rest_api/v1/object_tags/<object_id>/?taxonomy=t2

  • When userA or userS requests ^, they will receive only invalid object tags, because taxonomy t2 is disabled, which renders all of its object tags "invalid".

/tagging/rest_api/v1/object_tags/<object_id>/?taxonomy=<pk>&page=2

  • When userA or userS requests ^, they receive page 2 of the list of object tag metadata, max 100, matching the given object_id, with taxonomy_id=<pk>.

/tagging/rest_api/v1/object_tags/<object_id>/?taxonomy=<pk>&page=3&page_size=2

  • When userA or userS requests ^, they receive page 3 of the list of object tag metadata, max 2, matching the given object_id, with taxonomy_id=<pk>.

POST/PUT/PATCH /tagging/rest_api/v1/object_tags/<object_id>/

  • Returns an error code, e.g. 405 method not allowed

Documentation updates & improvements criteria

  • API endpoint and its parameters should be well-documented
  • Note: this API should be marked as “unstable” for the MVP.

Relevant PRs/repositories

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

2 participants