From f007a8ff92e4bf542fe7c90f1d57f63feed84445 Mon Sep 17 00:00:00 2001 From: Bridger Maxwell Date: Wed, 18 Jul 2012 11:44:19 -0400 Subject: [PATCH] The about image is now pulled from the course data directory and shown on the homepage, about course, and dashboard. Working on a way to show other, arbitrary course images. --- lms/djangoapps/courseware/courses.py | 17 +++++++++++++++++ lms/templates/course.html | 3 ++- lms/templates/portal/course_about.html | 7 +++++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py index b6853ae12a..7e7417166f 100644 --- a/lms/djangoapps/courseware/courses.py +++ b/lms/djangoapps/courseware/courses.py @@ -1,5 +1,6 @@ from functools import wraps +from django.conf import settings from django.http import Http404 from xmodule.course_module import CourseDescriptor @@ -31,3 +32,19 @@ def check_course(course_id, course_must_be_open=True, course_required=True): raise Http404("This course has not yet started.") return course + +def course_static_file_url(course, filepath): + """ + Given a course and a filepath from the course's directory + (like images/course_image.png), this returns the url for + the static file in the form. It will be something like + /static/content-mit-6002x/images/course_image.png. + """ + return "/".join( [settings.STATIC_URL, course.metadata['data_dir'], filepath] ) + +def course_image_url(course): + return course_static_file_url(course, "images/course_image.png") + + + + \ No newline at end of file diff --git a/lms/templates/course.html b/lms/templates/course.html index c22ff349ea..7ff04ad870 100644 --- a/lms/templates/course.html +++ b/lms/templates/course.html @@ -1,6 +1,7 @@ <%namespace name='static' file='static_content.html'/> <%! from django.core.urlresolvers import reverse + from courseware.courses import course_image_url %> <%page args="course" /> @@ -16,7 +17,7 @@
- +

${course.get_about_section('short_description')}

diff --git a/lms/templates/portal/course_about.html b/lms/templates/portal/course_about.html index 51e769a3a4..22261a52af 100644 --- a/lms/templates/portal/course_about.html +++ b/lms/templates/portal/course_about.html @@ -1,4 +1,7 @@ -<%! from django.core.urlresolvers import reverse %> +<%! + from django.core.urlresolvers import reverse + from courseware.courses import course_image_url +%> <%namespace name='static' file='../static_content.html'/> <%block name="js_extra"> @@ -26,7 +29,7 @@ % if course.get_about_section("video"):
- +