Skip to content

Commit

Permalink
Merge branch 'rpenido/fal-3610-download-course-tag-spreadsheet' into …
Browse files Browse the repository at this point in the history
…rpenido/fal-3611-download-library-tag-spreadsheet
  • Loading branch information
rpenido committed Feb 15, 2024
2 parents f750076 + 779cc98 commit f637076
Show file tree
Hide file tree
Showing 72 changed files with 877 additions and 458 deletions.
3 changes: 0 additions & 3 deletions cms/djangoapps/api/v1/views/course_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

from django.conf import settings
from django.http import Http404
from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication
from opaque_keys.edx.keys import CourseKey
from rest_framework import parsers, permissions, status, viewsets
from rest_framework.authentication import SessionAuthentication
from rest_framework.decorators import action
from rest_framework.response import Response

Expand All @@ -21,7 +19,6 @@


class CourseRunViewSet(viewsets.GenericViewSet): # lint-amnesty, pylint: disable=missing-class-docstring
authentication_classes = (JwtAuthentication, SessionAuthentication,)
lookup_value_regex = settings.COURSE_KEY_REGEX
permission_classes = (permissions.IsAdminUser,)
serializer_class = CourseRunSerializer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ def _save_xblock(
publish = "make_public"

# Make public after updating the xblock, in case the caller asked for both an update and a publish.
# Used by Bok Choy tests and by republishing of staff locks.
if publish == "make_public":
modulestore().publish(xblock.location, user.id)

Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/models/settings/course_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def validate_single_topic(cls, topic_settings):
"""
error_list = []
valid_teamset_types = [TeamsetType.open.value, TeamsetType.public_managed.value,
TeamsetType.private_managed.value]
TeamsetType.private_managed.value, TeamsetType.open_managed.value]
valid_keys = {'id', 'name', 'description', 'max_team_size', 'type'}
teamset_type = topic_settings.get('type', {})
if teamset_type:
Expand Down
6 changes: 6 additions & 0 deletions cms/djangoapps/models/settings/tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
"type": "private_managed",
"description": "Private Topic 2 desc",
"name": "Private Topic 2 Name"
},
{
"id": "open_managed_topic_1_id",
"type": "open_managed",
"description": "Open Managed Topic 1 desc",
"name": "Open Managed Topic 1 Name"
}
]
}
Expand Down
4 changes: 3 additions & 1 deletion cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@

from lms.djangoapps.lms_xblock.mixin import LmsBlockMixin
from cms.lib.xblock.authoring_mixin import AuthoringMixin
from cms.lib.xblock.tagging.tagged_block_mixin import TaggedBlockMixin
from xmodule.modulestore.edit_info import EditInfoMixin
from openedx.core.djangoapps.theming.helpers_dirs import (
get_themes_unchecked,
Expand Down Expand Up @@ -975,6 +976,7 @@
XModuleMixin,
EditInfoMixin,
AuthoringMixin,
TaggedBlockMixin,
)
XBLOCK_EXTRA_MIXINS = ()

Expand Down Expand Up @@ -2193,7 +2195,7 @@
'KEY_PREFIX': 'course_structure',
'KEY_FUNCTION': 'common.djangoapps.util.memcache.safe_key',
'LOCATION': ['localhost:11211'],
'TIMEOUT': '7200',
'TIMEOUT': '604800', # 1 week
'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
'OPTIONS': {
'no_delay': True,
Expand Down
2 changes: 1 addition & 1 deletion cms/envs/devstack-experimental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ CACHES:
KEY_PREFIX: course_structure
LOCATION:
- edx.devstack.memcached:11211
TIMEOUT: '7200'
TIMEOUT: '604800'
default:
BACKEND: django.core.cache.backends.memcached.PyMemcacheCache
OPTIONS:
Expand Down
57 changes: 57 additions & 0 deletions cms/lib/xblock/tagging/tagged_block_mixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# lint-amnesty, pylint: disable=missing-module-docstring
from urllib.parse import quote


class TaggedBlockMixin:
"""
Mixin containing XML serializing and parsing functionality for tagged blocks
"""

def serialize_tag_data(self):
"""
Serialize block's tag data to include in the xml, escaping special characters
Example tags:
LightCast Skills Taxonomy: ["Typing", "Microsoft Office"]
Open Canada Skills Taxonomy: ["MS Office", "<some:;,skill/|=>"]
Example serialized tags:
lightcast-skills:Typing,Microsoft Office;open-canada-skills:MS Office,%3Csome%3A%3B%2Cskill%2F%7C%3D%3E
"""
# This import is done here since we import and use TaggedBlockMixin in the cms settings, but the
# content_tagging app wouldn't have loaded yet, so importing it outside causes an error
from openedx.core.djangoapps.content_tagging.api import get_object_tags
content_tags = get_object_tags(self.scope_ids.usage_id)

serialized_tags = []
taxonomies_and_tags = {}
for tag in content_tags:
taxonomy_export_id = tag.taxonomy.export_id

if not taxonomies_and_tags.get(taxonomy_export_id):
taxonomies_and_tags[taxonomy_export_id] = []

# Escape special characters in tag values, except spaces (%20) for better readability
escaped_tag = quote(tag.value).replace("%20", " ")
taxonomies_and_tags[taxonomy_export_id].append(escaped_tag)

for taxonomy in taxonomies_and_tags:
merged_tags = ','.join(taxonomies_and_tags.get(taxonomy))
serialized_tags.append(f"{taxonomy}:{merged_tags}")

return ";".join(serialized_tags)

def add_tags_to_node(self, node):
"""
Serialize and add tag data (if any) to node
"""
tag_data = self.serialize_tag_data()
if tag_data:
node.set('tags-v1', tag_data)

def add_xml_to_node(self, node):
"""
Include the serialized tag data in XML when adding to node
"""
super().add_xml_to_node(node)
self.add_tags_to_node(node)
2 changes: 0 additions & 2 deletions common/djangoapps/entitlements/rest_api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from rest_framework import permissions, status, viewsets
from rest_framework.authentication import SessionAuthentication
from rest_framework.response import Response
from rest_framework.views import APIView

Expand Down Expand Up @@ -328,7 +327,6 @@ class EntitlementEnrollmentViewSet(viewsets.GenericViewSet):
- Unenroll
- Switch Enrollment
"""
authentication_classes = (JwtAuthentication, SessionAuthentication,)
# TODO: ARCH-91
# This view is excluded from Swagger doc generation because it
# does not specify a serializer class.
Expand Down

This file was deleted.

This file was deleted.

2 changes: 2 additions & 0 deletions common/djangoapps/student/signals/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# lint-amnesty, pylint: disable=missing-module-docstring

from common.djangoapps.student.signals.signals import (
emit_course_access_role_added,
emit_course_access_role_removed,
ENROLL_STATUS_CHANGE,
ENROLLMENT_TRACK_UPDATED,
REFUND_ORDER,
Expand Down
Loading

0 comments on commit f637076

Please sign in to comment.