Commit ce29b5ae by Victor Shnayder

Special case handling of course url_names in policy.json

parent a4d67bab
...@@ -234,10 +234,16 @@ class XMLModuleStore(ModuleStoreBase): ...@@ -234,10 +234,16 @@ class XMLModuleStore(ModuleStoreBase):
system = ImportSystem(self, org, course, course_dir, tracker) system = ImportSystem(self, org, course, course_dir, tracker)
course_descriptor = system.process_xml(etree.tostring(course_data))
policy_path = self.data_dir / course_dir / 'policy.json' policy_path = self.data_dir / course_dir / 'policy.json'
policy = self.load_policy(policy_path, tracker) policy = self.load_policy(policy_path, tracker)
# Special case -- need to change the url_name of the course before
# it gets loaded, so its location and other fields are right
if 'course_url_name' in policy:
new_url_name = policy['course_url_name']
log.info("changing course url_name to {}".format(new_url_name))
course_data.set('url_name', new_url_name)
course_descriptor = system.process_xml(etree.tostring(course_data))
XModuleDescriptor.apply_policy(course_descriptor, policy) XModuleDescriptor.apply_policy(course_descriptor, policy)
# NOTE: The descriptors end up loading somewhat bottom up, which # NOTE: The descriptors end up loading somewhat bottom up, which
......
...@@ -303,6 +303,10 @@ def policy_key(location): ...@@ -303,6 +303,10 @@ def policy_key(location):
Get the key for a location in a policy file. (Since the policy file is Get the key for a location in a policy file. (Since the policy file is
specific to a course, it doesn't need the full location url). specific to a course, it doesn't need the full location url).
""" """
# Special case--we need to be able to override the url_name on a course,
# so special case where we look for the course descriptor
if location.category == 'course':
return 'course'
return '{cat}/{name}'.format(cat=location.category, name=location.name) return '{cat}/{name}'.format(cat=location.category, name=location.name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment