Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cms/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,8 @@
urlpatterns += [
path('api/contentstore/', include('cms.djangoapps.contentstore.rest_api.urls'))
]

# Content tagging
urlpatterns += [
path('api/content_tagging/', include(('openedx.features.content_tagging.urls'))),
]
8 changes: 2 additions & 6 deletions openedx/features/content_tagging/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,16 @@ def get_taxonomies_for_org(


def get_content_tags(
object_id: str, taxonomy: Taxonomy = None, valid_only=True
object_id: str, taxonomy_id: str = None
) -> Iterator[ContentObjectTag]:
"""
Generates a list of content tags for a given object.

Pass taxonomy to limit the returned object_tags to a specific taxonomy.

Pass valid_only=False when displaying tags to content authors, so they can see invalid tags too.
Invalid tags will (probably) be hidden from learners.
"""
for object_tag in oel_tagging.get_object_tags(
object_id=object_id,
taxonomy=taxonomy,
valid_only=valid_only,
taxonomy_id=taxonomy_id,
):
yield ContentObjectTag.cast(object_tag)

Expand Down
2 changes: 1 addition & 1 deletion openedx/features/content_tagging/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Meta:

@classmethod
def get_relationships(
cls, taxonomy: Taxonomy, rel_type: RelType, org_short_name: str = None
cls, taxonomy: Taxonomy, rel_type: RelType, org_short_name: Union[str, None] = None
) -> QuerySet:
"""
Returns the relationships of the given rel_type and taxonomy where:
Expand Down
Empty file.
9 changes: 9 additions & 0 deletions openedx/features/content_tagging/rest_api/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""
Taxonomies API URLs.
"""

from django.urls import path, include

from .v1 import urls as v1_urls

urlpatterns = [path("v1/", include(v1_urls))]
Empty file.
21 changes: 21 additions & 0 deletions openedx/features/content_tagging/rest_api/v1/filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
API Filters for content tagging org
"""

from rest_framework.filters import BaseFilterBackend

from ...rules import is_taxonomy_admin


class UserOrgFilterBackend(BaseFilterBackend):
"""
Taxonomy admin can see all taxonomies
Everyone else can see only enabled taxonomies

"""

def filter_queryset(self, request, queryset, _):
if is_taxonomy_admin(request.user):
return queryset

return queryset.filter(enabled=True)
23 changes: 23 additions & 0 deletions openedx/features/content_tagging/rest_api/v1/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
API Serializers for content tagging org
"""

from rest_framework import serializers

from openedx_tagging.core.tagging.rest_api.v1.serializers import (
TaxonomyListQueryParamsSerializer,
)

from organizations.models import Organization


class TaxonomyOrgListQueryParamsSerializer(TaxonomyListQueryParamsSerializer):
"""
Serializer for the query params for the GET view
"""

org = serializers.SlugRelatedField(
slug_field="short_name",
queryset=Organization.objects.all(),
required=False,
)
Empty file.
Loading