Skip to content

Commit 30f1e80

Browse files
committed
Use default settings, don't let apply styles if disabled
1 parent c57b39a commit 30f1e80

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

sendfile.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from django.http import HttpResponse, Http404
2-
from django.conf import settings
32
from django.utils.http import urlquote
43
import os
54
import re
65
import mimetypes
76

8-
from django.conf import settings
7+
from . settings import LASANA_USE_X_SENDFILE
98

109
#For no-XSendfile approach
1110
from django.core.servers.basehttp import FileWrapper
@@ -20,7 +19,7 @@ def send(request, file):
2019
if detected_type is None:
2120
detected_type = 'application/octet-stream'
2221

23-
if settings.LASANA_USE_X_SENDFILE:
22+
if LASANA_USE_X_SENDFILE:
2423
response = HttpResponse(content_type=detected_type)
2524
response['Content-Disposition'] = 'filename=%s' % urlquote(os.path.basename(file.name))
2625
content_range = request.META.get('HTTP_RANGE')

settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ def get(key, default):
99
LASANA_DEFAULT_STYLE = get('LASANA_DEFAULT_STYLE', 'original')
1010

1111
LASANA_ALLOW_CHANGE_STYLE = get('LASANA_ALLOW_CHANGE_STYLE', True)
12+
13+
LASANA_USE_X_SENDFILE = get('LASANA_USE_X_SENDFILE', False)
14+
15+
LASANA_UPLOAD_ROOT = get('LASANA_UPLOAD_ROOT', './uploads')

styles.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import re
2-
from . settings import LASANA_DEFAULT_STYLE
2+
from . settings import LASANA_DEFAULT_STYLE, LASANA_ALLOW_CHANGE_STYLE
33

44
basic_name = re.compile(r'^[a-zA-Z0-9_\-]+$')
55

@@ -8,6 +8,9 @@ def is_basic_name(style):
88
return bool(basic_name.match(style))
99

1010
def get_style(request):
11+
if not LASANA_ALLOW_CHANGE_STYLE:
12+
return LASANA_DEFAULT_STYLE
13+
1114
style_from_session = request.session.get('style')
1215

1316
style_from_get = request.GET.get('style')

0 commit comments

Comments
 (0)