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.
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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 @@
|
||||
</header>
|
||||
<section class="info">
|
||||
<div class="cover-image">
|
||||
<img src="${static.url('images/courses/history.png')}">
|
||||
<img src="${course_image_url(course)}">
|
||||
</div>
|
||||
<div class="desc">
|
||||
<p>${course.get_about_section('short_description')}</p>
|
||||
|
||||
@@ -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">
|
||||
<script src="${static.url('js/course_info.js')}"></script>
|
||||
@@ -26,7 +29,7 @@
|
||||
% if course.get_about_section("video"):
|
||||
<a href="#video-modal" class="media" rel="leanModal">
|
||||
<div class="hero">
|
||||
<img src="${static.url('images/courses/circuits.jpeg')}" />
|
||||
<img src="${course_image_url(course)}" />
|
||||
<div class="play-intro"></div>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user