From 2d5fb28d9d57823da9f18c0b3c82ca1ef4fc4a0b Mon Sep 17 00:00:00 2001 From: Braden MacDonald Date: Thu, 19 Oct 2023 10:12:45 -0700 Subject: [PATCH] feat: support any URL namespace for tagging REST API --- openedx_tagging/core/tagging/rest_api/v1/serializers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openedx_tagging/core/tagging/rest_api/v1/serializers.py b/openedx_tagging/core/tagging/rest_api/v1/serializers.py index 7e3ee0b3..4ff74e36 100644 --- a/openedx_tagging/core/tagging/rest_api/v1/serializers.py +++ b/openedx_tagging/core/tagging/rest_api/v1/serializers.py @@ -118,11 +118,12 @@ def get_sub_tags_url(self, obj: TagData): """ if obj["child_count"] > 0 and "taxonomy_id" in self.context: query_params = f"?parent_tag={obj['value']}" + request = self.context.get("request") + url_namespace = request.resolver_match.view_name.split(":")[0] # get the namespace, usually "oel_tagging" url = ( - reverse("oel_tagging:taxonomy-tags", args=[str(self.context["taxonomy_id"])]) + reverse(f"{url_namespace}:taxonomy-tags", args=[str(self.context["taxonomy_id"])]) + query_params ) - request = self.context.get("request") return request.build_absolute_uri(url) return None