File tree Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 1
1
from django .http import HttpResponse , Http404
2
- from django .conf import settings
3
2
from django .utils .http import urlquote
4
3
import os
5
4
import re
6
5
import mimetypes
7
6
8
- from django . conf import settings
7
+ from . settings import LASANA_USE_X_SENDFILE
9
8
10
9
#For no-XSendfile approach
11
10
from django .core .servers .basehttp import FileWrapper
@@ -20,7 +19,7 @@ def send(request, file):
20
19
if detected_type is None :
21
20
detected_type = 'application/octet-stream'
22
21
23
- if settings . LASANA_USE_X_SENDFILE :
22
+ if LASANA_USE_X_SENDFILE :
24
23
response = HttpResponse (content_type = detected_type )
25
24
response ['Content-Disposition' ] = 'filename=%s' % urlquote (os .path .basename (file .name ))
26
25
content_range = request .META .get ('HTTP_RANGE' )
Original file line number Diff line number Diff line change @@ -9,3 +9,7 @@ def get(key, default):
9
9
LASANA_DEFAULT_STYLE = get ('LASANA_DEFAULT_STYLE' , 'original' )
10
10
11
11
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' )
Original file line number Diff line number Diff line change 1
1
import re
2
- from . settings import LASANA_DEFAULT_STYLE
2
+ from . settings import LASANA_DEFAULT_STYLE , LASANA_ALLOW_CHANGE_STYLE
3
3
4
4
basic_name = re .compile (r'^[a-zA-Z0-9_\-]+$' )
5
5
@@ -8,6 +8,9 @@ def is_basic_name(style):
8
8
return bool (basic_name .match (style ))
9
9
10
10
def get_style (request ):
11
+ if not LASANA_ALLOW_CHANGE_STYLE :
12
+ return LASANA_DEFAULT_STYLE
13
+
11
14
style_from_session = request .session .get ('style' )
12
15
13
16
style_from_get = request .GET .get ('style' )
You can’t perform that action at this time.
0 commit comments