From eeadf0ba87daaf70299847d8f178dddd78fedf56 Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Mon, 20 Aug 2012 19:28:07 -0400 Subject: [PATCH] Let policies be stored in policies/{url_name}/policy.json * still backcompat with old mode --- common/lib/xmodule/xmodule/modulestore/xml.py | 9 +++++++-- .../{TT_2012_Fall.json => TT_2012_Fall/policy.json} | 0 2 files changed, 7 insertions(+), 2 deletions(-) rename common/test/data/two_toys/policies/{TT_2012_Fall.json => TT_2012_Fall/policy.json} (100%) diff --git a/common/lib/xmodule/xmodule/modulestore/xml.py b/common/lib/xmodule/xmodule/modulestore/xml.py index e0fecb243d..769d110518 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml.py +++ b/common/lib/xmodule/xmodule/modulestore/xml.py @@ -243,8 +243,13 @@ class XMLModuleStore(ModuleStoreBase): url_name = course_data.get('url_name', course_data.get('slug')) if url_name: - policy_path = self.data_dir / course_dir / 'policies' / '{0}.json'.format(url_name) - policy = self.load_policy(policy_path, tracker) + old_policy_path = self.data_dir / course_dir / 'policies' / url_name / 'policy.json' + policy = self.load_policy(old_policy_path, tracker) + + # VS[compat]: remove once courses use the policy dirs. + if policy == {}: + old_policy_path = self.data_dir / course_dir / 'policies' / '{0}.json'.format(url_name) + policy = self.load_policy(old_policy_path, tracker) else: policy = {} # VS[compat] : 'name' is deprecated, but support it for now... diff --git a/common/test/data/two_toys/policies/TT_2012_Fall.json b/common/test/data/two_toys/policies/TT_2012_Fall/policy.json similarity index 100% rename from common/test/data/two_toys/policies/TT_2012_Fall.json rename to common/test/data/two_toys/policies/TT_2012_Fall/policy.json