init mimetypes

pull/1/head
eric 2016-03-25 14:13:39 -04:00
parent f15cfdcc7f
commit 60bc236ab4
3 changed files with 1605 additions and 1 deletions

1596
deploy/mime.types Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@ external library imports
import json import json
import re import re
import time import time
import mimetypes
from datetime import timedelta from datetime import timedelta
from decimal import Decimal as D from decimal import Decimal as D
@ -63,7 +64,9 @@ class PageTests(TestCase):
self.client = Client() self.client = Client()
self.client.login(username='test', password='test') self.client.login(username='test', password='test')
w= Work.objects.create(title="test work",language='en') w= Work.objects.create(title="test work",language='en')
def test_setttings(self):
self.assertEqual(mimetypes.guess_type('/whatever/my_file.epub')[0], 'application/epub+zip')
def test_view_by_self(self): def test_view_by_self(self):
# logged in # logged in

View File

@ -1,4 +1,5 @@
import datetime import datetime
import mimetypes
from os.path import dirname, realpath, join from os.path import dirname, realpath, join
import regluit import regluit
@ -423,6 +424,8 @@ FORMATS = (
('text','TEXT'), ('text','TEXT'),
('mobi','MOBI'), ('mobi','MOBI'),
) )
# used by MARC. maybe should use python's mimetypes
CONTENT_TYPES = { CONTENT_TYPES = {
'pdf': 'application/pdf', 'pdf': 'application/pdf',
'epub': 'application/epub+zip', 'epub': 'application/epub+zip',
@ -431,6 +434,8 @@ CONTENT_TYPES = {
'mobi': 'application/x-mobipocket-ebook' 'mobi': 'application/x-mobipocket-ebook'
} }
mimetypes.init(["{}/deploy/mime.types".format(PROJECT_DIR)])
# if you add more of these, make sure core/marc.py can deal # if you add more of these, make sure core/marc.py can deal
MARC_CHOICES = ( MARC_CHOICES = (
('DIRECT', 'Raw link'), ('DIRECT', 'Raw link'),