Commit 6c02d798 by Carlos Andrés Rocha

Fix to read utf-8 enconded html files for custom course tabs

parent ef509271
...@@ -11,10 +11,13 @@ actually generates the CourseTab. ...@@ -11,10 +11,13 @@ actually generates the CourseTab.
from collections import namedtuple from collections import namedtuple
import logging import logging
import codecs
from django.conf import settings from django.conf import settings
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from fs.errors import ResourceNotFoundError
from courseware.access import has_access from courseware.access import has_access
from static_replace import replace_urls from static_replace import replace_urls
...@@ -266,7 +269,8 @@ def get_static_tab_contents(course, tab): ...@@ -266,7 +269,8 @@ def get_static_tab_contents(course, tab):
try: try:
with fs.open(p) as tabfile: with fs.open(p) as tabfile:
# TODO: redundant with module_render.py. Want to be helper methods in static_replace or something. # 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']) text = tabfile.read().decode('utf-8')
contents = replace_urls(text, course.metadata['data_dir'])
return replace_urls(contents, staticfiles_prefix='/courses/'+course.id, replace_prefix='/course/') return replace_urls(contents, staticfiles_prefix='/courses/'+course.id, replace_prefix='/course/')
except (ResourceNotFoundError) as err: except (ResourceNotFoundError) as err:
log.exception("Couldn't load tab contents from '{0}': {1}".format(p, err)) log.exception("Couldn't load tab contents from '{0}': {1}".format(p, err))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment