mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 15:38:15 +00:00
Move file extension and type map generation from urls.py to utils.py.
This commit is contained in:
4
urls.py
4
urls.py
@@ -17,7 +17,6 @@ from seahub.views import root, peers, myhome, \
|
|||||||
from seahub.notifications.views import notification_list
|
from seahub.notifications.views import notification_list
|
||||||
from seahub.share.views import share_admin
|
from seahub.share.views import share_admin
|
||||||
from seahub.group.views import group_list
|
from seahub.group.views import group_list
|
||||||
from seahub.utils import gen_fileext_type_map
|
|
||||||
|
|
||||||
# Uncomment the next two lines to enable the admin:
|
# Uncomment the next two lines to enable the admin:
|
||||||
#from django.contrib import admin
|
#from django.contrib import admin
|
||||||
@@ -110,6 +109,3 @@ if settings.DEBUG:
|
|||||||
(r'^%s/(?P<path>.*)$' % (media_url), 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
|
(r'^%s/(?P<path>.*)$' % (media_url), 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add file extension and type to dictionary at django startup,
|
|
||||||
# this function should be called only once.
|
|
||||||
FILEEXT_TYPE_MAP = gen_fileext_type_map()
|
|
||||||
|
2
utils.py
2
utils.py
@@ -237,7 +237,6 @@ def valid_previewed_file(filename):
|
|||||||
Check whether file can preview on web
|
Check whether file can preview on web
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from urls import FILEEXT_TYPE_MAP
|
|
||||||
fileExt = os.path.splitext(filename)[1][1:]
|
fileExt = os.path.splitext(filename)[1][1:]
|
||||||
return FILEEXT_TYPE_MAP.get(fileExt)
|
return FILEEXT_TYPE_MAP.get(fileExt)
|
||||||
|
|
||||||
@@ -267,3 +266,4 @@ def gen_fileext_type_map():
|
|||||||
d[fileext] = filetype
|
d[fileext] = filetype
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
FILEEXT_TYPE_MAP = gen_fileext_type_map()
|
||||||
|
Reference in New Issue
Block a user