From 0b6bf77373fe9aec22c7be46329f625ccad2d031 Mon Sep 17 00:00:00 2001 From: Arjun Singh Date: Wed, 22 Aug 2012 04:58:30 -0700 Subject: [PATCH 1/3] Adding a course-specific css class to body so that we can have course-targeted styles as a last resort --- common/lib/xmodule/xmodule/course_module.py | 4 ++++ lms/templates/courseware/courseware.html | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index 5cc4a09165..5eeb5ee11c 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -197,6 +197,10 @@ class CourseDescriptor(SequenceDescriptor): def start_date_text(self): return time.strftime("%b %d, %Y", self.start) + @property + def css_class(self): + return self.metadata.get('css_class', '') + @property def title(self): return self.display_name diff --git a/lms/templates/courseware/courseware.html b/lms/templates/courseware/courseware.html index 02149ec463..3f6588420a 100644 --- a/lms/templates/courseware/courseware.html +++ b/lms/templates/courseware/courseware.html @@ -1,6 +1,6 @@ <%inherit file="/main.html" /> <%namespace name='static' file='/static_content.html'/> -<%block name="bodyclass">courseware +<%block name="bodyclass">courseware ${course.css_class} <%block name="title">${course.number} Courseware <%block name="headextra"> From 9a21c5d4a8dadc9af882f579df5fde52b22bcb51 Mon Sep 17 00:00:00 2001 From: Arjun Singh Date: Wed, 22 Aug 2012 05:00:11 -0700 Subject: [PATCH 2/3] Adding reasoning for adding a new metadata field --- common/lib/xmodule/xmodule/course_module.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index 5eeb5ee11c..4e799a6f0d 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -197,6 +197,10 @@ class CourseDescriptor(SequenceDescriptor): def start_date_text(self): return time.strftime("%b %d, %Y", self.start) + # An extra property is used rather than the wiki_slug/number because + # there are courses that change the number for different runs. This allows + # courses to share the same css_class across runs even if they have + # different numbers. @property def css_class(self): return self.metadata.get('css_class', '') From 23e3d371ef3063bfa03a46f7f53ac9d5480ac3ad Mon Sep 17 00:00:00 2001 From: Arjun Singh Date: Wed, 22 Aug 2012 11:49:26 -0700 Subject: [PATCH 3/3] adding more details about the state of course.css_class --- common/lib/xmodule/xmodule/course_module.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index 4e799a6f0d..3d2b6c60bf 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -201,6 +201,11 @@ class CourseDescriptor(SequenceDescriptor): # there are courses that change the number for different runs. This allows # courses to share the same css_class across runs even if they have # different numbers. + # + # TODO get rid of this as soon as possible or potentially build in a robust + # way to add in course-specific styling. There needs to be a discussion + # about the right way to do this, but arjun will address this ASAP. Also + # note that the courseware template needs to change when this is removed. @property def css_class(self): return self.metadata.get('css_class', '')