fix: Show tag count when paste a component in a course [FC-0046] (#36318)
* fix: Show tag count when paste a component in a course * refactor: get_children_tags_count updated to get_tags_count
This commit is contained in:
@@ -57,7 +57,7 @@ from cms.djangoapps.contentstore.xblock_storage_handlers.view_handlers import (
|
|||||||
)
|
)
|
||||||
from cms.djangoapps.contentstore.xblock_storage_handlers.xblock_helpers import (
|
from cms.djangoapps.contentstore.xblock_storage_handlers.xblock_helpers import (
|
||||||
usage_key_with_run,
|
usage_key_with_run,
|
||||||
get_children_tags_count,
|
get_tags_count,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -245,10 +245,10 @@ def xblock_view_handler(request, usage_key_string, view_name):
|
|||||||
|
|
||||||
force_render = request.GET.get("force_render", None)
|
force_render = request.GET.get("force_render", None)
|
||||||
|
|
||||||
# Fetch tags of children components
|
# Fetch tags of xblock and children components
|
||||||
tags_count_map = {}
|
tags_count_map = {}
|
||||||
if not is_tagging_feature_disabled():
|
if not is_tagging_feature_disabled():
|
||||||
tags_count_map = get_children_tags_count(xblock)
|
tags_count_map = get_tags_count(xblock, include_children=True)
|
||||||
|
|
||||||
# Set up the context to be passed to each XBlock's render method.
|
# Set up the context to be passed to each XBlock's render method.
|
||||||
context = request.GET.dict()
|
context = request.GET.dict()
|
||||||
|
|||||||
@@ -16,11 +16,19 @@ def usage_key_with_run(usage_key_string):
|
|||||||
return usage_key
|
return usage_key
|
||||||
|
|
||||||
|
|
||||||
def get_children_tags_count(xblock):
|
def get_tags_count(xblock, include_children=False):
|
||||||
"""
|
"""
|
||||||
Returns a map with tag count of each child
|
Returns a map with tag count of the `xblock`
|
||||||
|
|
||||||
|
Use `include_children` to include each children on the query.
|
||||||
"""
|
"""
|
||||||
children = xblock.get_children()
|
query_list = [str(xblock.location)]
|
||||||
child_usage_keys = [str(child.location) for child in children]
|
|
||||||
tags_count_query = ','.join(child_usage_keys)
|
if include_children:
|
||||||
|
children = xblock.get_children()
|
||||||
|
child_usage_keys = [str(child.location) for child in children]
|
||||||
|
query_list.extend(child_usage_keys)
|
||||||
|
|
||||||
|
tags_count_query = ",".join(query_list)
|
||||||
|
|
||||||
return get_object_tag_counts(tags_count_query, count_implicit=True)
|
return get_object_tag_counts(tags_count_query, count_implicit=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user