Merge pull request #3858 from aboudreault/xblock-resource-missing-mimetypes
Add missing mimetypes for xblock resources
This commit is contained in:
@@ -14,3 +14,19 @@ def run():
|
||||
Executed during django startup
|
||||
"""
|
||||
autostartup()
|
||||
|
||||
add_mimetypes()
|
||||
|
||||
|
||||
def add_mimetypes():
|
||||
"""
|
||||
Add extra mimetypes. Used in xblock_resource.
|
||||
|
||||
If you add a mimetype here, be sure to also add it in lms/startup.py.
|
||||
"""
|
||||
import mimetypes
|
||||
|
||||
mimetypes.add_type('application/vnd.ms-fontobject', '.eot')
|
||||
mimetypes.add_type('application/x-font-opentype', '.otf')
|
||||
mimetypes.add_type('application/x-font-ttf', '.ttf')
|
||||
mimetypes.add_type('application/font-woff', '.woff')
|
||||
|
||||
@@ -63,7 +63,6 @@ XQUEUE_INTERFACE = XQueueInterface(
|
||||
# Some brave person should make the variable names consistently someday, but the code's
|
||||
# coupled enough that it's kind of tricky--you've been warned!
|
||||
|
||||
|
||||
class LmsModuleRenderError(Exception):
|
||||
"""
|
||||
An exception class for exceptions thrown by module_render that don't fit well elsewhere
|
||||
|
||||
@@ -20,6 +20,8 @@ def run():
|
||||
"""
|
||||
autostartup()
|
||||
|
||||
add_mimetypes()
|
||||
|
||||
if settings.FEATURES.get('USE_CUSTOM_THEME', False):
|
||||
enable_theme()
|
||||
|
||||
@@ -30,6 +32,20 @@ def run():
|
||||
enable_third_party_auth()
|
||||
|
||||
|
||||
def add_mimetypes():
|
||||
"""
|
||||
Add extra mimetypes. Used in xblock_resource.
|
||||
|
||||
If you add a mimetype here, be sure to also add it in cms/startup.py.
|
||||
"""
|
||||
import mimetypes
|
||||
|
||||
mimetypes.add_type('application/vnd.ms-fontobject', '.eot')
|
||||
mimetypes.add_type('application/x-font-opentype', '.otf')
|
||||
mimetypes.add_type('application/x-font-ttf', '.ttf')
|
||||
mimetypes.add_type('application/font-woff', '.woff')
|
||||
|
||||
|
||||
def enable_theme():
|
||||
"""
|
||||
Enable the settings for a custom theme, whose files should be stored
|
||||
|
||||
15
lms/tests.py
15
lms/tests.py
@@ -1,10 +1,25 @@
|
||||
"""Tests for the lms module itself."""
|
||||
|
||||
import mimetypes
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from edxmako import add_lookup, LOOKUP
|
||||
from lms import startup
|
||||
|
||||
|
||||
class LmsModuleTests(TestCase):
|
||||
"""
|
||||
Tests for lms module itself.
|
||||
"""
|
||||
|
||||
def test_new_mimetypes(self):
|
||||
extensions = ['eot', 'otf', 'ttf', 'woff']
|
||||
for extension in extensions:
|
||||
mimetype, _ = mimetypes.guess_type('test.' + extension)
|
||||
self.assertIsNotNone(mimetype)
|
||||
|
||||
|
||||
class TemplateLookupTests(TestCase):
|
||||
"""
|
||||
Tests for TemplateLookup.
|
||||
|
||||
Reference in New Issue
Block a user