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
a19319f7
Commit
a19319f7
authored
Sep 20, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add some error handling
parent
27cd9c9f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
lms/djangoapps/courseware/tabs.py
+12
-6
No files found.
lms/djangoapps/courseware/tabs.py
View file @
a19319f7
...
...
@@ -243,7 +243,7 @@ def get_static_tab_by_slug(course, tab_slug):
if
course
.
tabs
is
None
:
return
None
for
tab
in
course
.
tabs
:
#
if the tab is misconfigured, this will blow up. The validation code should check..
.
#
The validation code checks that these exist
.
if
tab
[
'type'
]
==
'static_tab'
and
tab
[
'url_slug'
]
==
tab_slug
:
return
tab
...
...
@@ -258,11 +258,17 @@ def get_static_tab_contents(course, tab):
Looks in tabs/{course_url_name}/{tab_slug}.html first, then tabs/{tab_slug}.html.
"""
slug
=
tab
[
'url_slug'
]
paths
=
[
'tabs/{0}/{1}.html'
.
format
(
course
.
url_name
,
slug
),
'tabs/{0}.html'
.
format
(
slug
)]
paths
=
[
'tabs/{0}/{1}.html'
.
format
(
course
.
url_name
,
slug
),
'tabs/{0}.html'
.
format
(
slug
)]
fs
=
course
.
system
.
resources_fs
for
p
in
paths
:
if
fs
.
exists
(
p
):
with
fs
.
open
(
p
)
as
tabfile
:
# TODO: redundant with module_render.py. Want to be helper methods in static_replace or something.
contents
=
replace_urls
(
tabfile
.
read
(),
course
.
metadata
[
'data_dir'
])
return
replace_urls
(
contents
,
staticfiles_prefix
=
'/courses/'
+
course
.
id
,
replace_prefix
=
'/course/'
)
try
:
with
fs
.
open
(
p
)
as
tabfile
:
# TODO: redundant with module_render.py. Want to be helper methods in static_replace or something.
contents
=
replace_urls
(
tabfile
.
read
(),
course
.
metadata
[
'data_dir'
])
return
replace_urls
(
contents
,
staticfiles_prefix
=
'/courses/'
+
course
.
id
,
replace_prefix
=
'/course/'
)
except
(
ResourceNotFoundError
)
as
err
:
log
.
warning
(
"Couldn't load tab contents from '{0}': {1}"
.
format
(
p
,
err
))
return
None
return
None
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