Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
4d1c046a
Commit
4d1c046a
authored
Jul 23, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #277 from MITx/cpennington/pipelining-course-data
Use django-pipeline to read course static files.
parents
c6f0c57b
b8b133d3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
12 deletions
+7
-12
common/djangoapps/pipeline_mako/templates/static_content.html
+0
-3
lms/djangoapps/courseware/courses.py
+7
-9
No files found.
common/djangoapps/pipeline_mako/templates/static_content.html
View file @
4d1c046a
<
%!
<
%!
from
staticfiles
.
storage
import
staticfiles_storage
from
staticfiles
.
storage
import
staticfiles_storage
from
pipeline_mako
import
compressed_css
,
compressed_js
from
pipeline_mako
import
compressed_css
,
compressed_js
from
static_replace
import
replace_urls
%
>
%
>
<
%
def
name=
'url(file)'
>
${staticfiles_storage.url(file)}
</
%
def>
<
%
def
name=
'url(file)'
>
${staticfiles_storage.url(file)}
</
%
def>
...
@@ -24,5 +23,3 @@ from static_replace import replace_urls
...
@@ -24,5 +23,3 @@ from static_replace import replace_urls
% endfor
% endfor
%endif
%endif
</
%
def>
</
%
def>
<
%
def
name=
'replace_urls(text)'
>
${replace_urls(text)}
</
%
def>
lms/djangoapps/courseware/courses.py
View file @
4d1c046a
...
@@ -9,9 +9,12 @@ from django.http import Http404
...
@@ -9,9 +9,12 @@ from django.http import Http404
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
static_replace
import
replace_urls
from
staticfiles.storage
import
staticfiles_storage
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
def
check_course
(
course_id
,
course_must_be_open
=
True
,
course_required
=
True
):
def
check_course
(
course_id
,
course_must_be_open
=
True
,
course_required
=
True
):
"""
"""
Given a course_id, this returns the course object. By default,
Given a course_id, this returns the course object. By default,
...
@@ -39,14 +42,9 @@ def check_course(course_id, course_must_be_open=True, course_required=True):
...
@@ -39,14 +42,9 @@ def check_course(course_id, course_must_be_open=True, course_required=True):
return
course
return
course
### These methods look like they should be on the course_module object itself, but they rely
### on the lms. Maybe they should be added dynamically to the class?
def
course_static_url
(
course
):
return
settings
.
STATIC_URL
+
"/"
+
course
.
metadata
[
'data_dir'
]
+
"/"
def
course_image_url
(
course
):
def
course_image_url
(
course
):
return
course_static_url
(
course
)
+
"images/course_image.jpg"
return
staticfiles_storage
.
url
(
course
.
metadata
[
'data_dir'
]
+
"/images/course_image.jpg"
)
def
get_course_about_section
(
course
,
section_key
):
def
get_course_about_section
(
course
,
section_key
):
"""
"""
...
@@ -78,7 +76,7 @@ def get_course_about_section(course, section_key):
...
@@ -78,7 +76,7 @@ def get_course_about_section(course, section_key):
'effort'
,
'end_date'
,
'prerequisites'
]:
'effort'
,
'end_date'
,
'prerequisites'
]:
try
:
try
:
with
course
.
system
.
resources_fs
.
open
(
path
(
"about"
)
/
section_key
+
".html"
)
as
htmlFile
:
with
course
.
system
.
resources_fs
.
open
(
path
(
"about"
)
/
section_key
+
".html"
)
as
htmlFile
:
return
htmlFile
.
read
()
.
decode
(
'utf-8'
)
.
format
(
COURSE_STATIC_URL
=
course_static_url
(
course
)
)
return
replace_urls
(
htmlFile
.
read
()
.
decode
(
'utf-8'
),
course
.
metadata
[
'data_dir'
]
)
except
ResourceNotFoundError
:
except
ResourceNotFoundError
:
log
.
warning
(
"Missing about section {key} in course {url}"
.
format
(
key
=
section_key
,
url
=
course
.
location
.
url
()))
log
.
warning
(
"Missing about section {key} in course {url}"
.
format
(
key
=
section_key
,
url
=
course
.
location
.
url
()))
return
None
return
None
...
@@ -107,7 +105,7 @@ def get_course_info_section(course, section_key):
...
@@ -107,7 +105,7 @@ def get_course_info_section(course, section_key):
if
section_key
in
[
'handouts'
,
'guest_handouts'
,
'updates'
,
'guest_updates'
]:
if
section_key
in
[
'handouts'
,
'guest_handouts'
,
'updates'
,
'guest_updates'
]:
try
:
try
:
with
course
.
system
.
resources_fs
.
open
(
path
(
"info"
)
/
section_key
+
".html"
)
as
htmlFile
:
with
course
.
system
.
resources_fs
.
open
(
path
(
"info"
)
/
section_key
+
".html"
)
as
htmlFile
:
return
htmlFile
.
read
()
.
decode
(
'utf-8'
)
return
replace_urls
(
htmlFile
.
read
()
.
decode
(
'utf-8'
),
course
.
metadata
[
'data_dir'
]
)
except
ResourceNotFoundError
:
except
ResourceNotFoundError
:
log
.
exception
(
"Missing info section {key} in course {url}"
.
format
(
key
=
section_key
,
url
=
course
.
location
.
url
()))
log
.
exception
(
"Missing info section {key} in course {url}"
.
format
(
key
=
section_key
,
url
=
course
.
location
.
url
()))
return
"! Info section missing !"
return
"! Info section missing !"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment