Gitlab CSE Unil

Commit 31e40a99 authored by M. Chardon's avatar M. Chardon
Browse files

remplacement de django_sendfile par système natif django 2.2

parent 5432d23a
......@@ -27,9 +27,10 @@ from adim_ttp.decorators import attp_login
from adim_utils.decorators import clear_function_cache
from .forms import UploadImageFileForm
from sendfile import sendfile
from .utils import add_image_border, create_image_thumbnail
from django.http import FileResponse
logger = logging.getLogger(__name__)
def home(request):
......@@ -96,7 +97,8 @@ def _get_anobj(request, anobj_uuid=None, anobj_id=None):
def send_anobj_img(request, anobj_uuid):
try:
anobj = _get_anobj(request, anobj_uuid=anobj_uuid)
return sendfile(request, anobj.image.path)
#return sendfile(request, anobj.image.path)
return FileResponse(open(anobj.image.path, 'rb'))
except Http404:
return HttpResponseForbidden('Sorry, you cannot access this file')
......@@ -127,7 +129,8 @@ def send_anobj_thumb(request, anobj_uuid):
settings.MEDIA_ROOT,
thumb_name
)
return sendfile(request, thumb_path)
#return sendfile(request, thumb_path)
return FileResponse(open(thumb_path, 'rb'))
except Http404:
return HttpResponseForbidden('Sorry, you cannot access this file')
......
......@@ -14,8 +14,6 @@ from adim.permissions import SHARING_MODE_NONE
from adim_ttp.decorators import attp_login
from adim_utils.decorators import clear_function_cache
from sendfile import sendfile
logger = logging.getLogger(__name__)
......
......@@ -34,9 +34,9 @@
## XsendFile Conf
## --------------
<IfModule xsendfile_module>
XSendFile On
</IfModule>
#<IfModule xsendfile_module>
# XSendFile On
#</IfModule>
<Directory "{{ settings.MEDIA_ROOT }}/ao_images/">
Order allow,deny
Deny from all
......
......@@ -38,10 +38,10 @@
# --------------
# XsendFile Conf
# --------------
<IfModule xsendfile_module>
XSendFile On
XSendFilePath "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/media"
</IfModule>
#<IfModule xsendfile_module>
# XSendFile On
# XSendFilePath "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/media"
#</IfModule>
</Directory>
......
......@@ -47,10 +47,10 @@
# --------------
# XsendFile Conf
# --------------
<IfModule xsendfile_module>
XSendFile On
XSendFilePath "/nas/data/adim/media/"
</IfModule>
#<IfModule xsendfile_module>
# XSendFile On
# XSendFilePath "/nas/data/adim/media/"
#</IfModule>
</Directory>
......
......@@ -53,10 +53,10 @@
# --------------
# XsendFile Conf
# --------------
<IfModule xsendfile_module>
XSendFile On
XSendFilePath "/var/django/projects/adim-dev.django/adim_project/media"
</IfModule>
#<IfModule xsendfile_module>
# XSendFile On
# XSendFilePath "/var/django/projects/adim-dev.django/adim_project/media"
#</IfModule>
</Directory>
......
......@@ -147,7 +147,7 @@ SESSION_COOKIE_NAME = "adim_sessid"
LOCAL_APPS = ('django_extensions','eav')
# ..... MISC
SENDFILE_BACKEND = 'sendfile.backends.xsendfile'
#SENDFILE_BACKEND = 'sendfile.backends.xsendfile'
# ..... REST FRAMEWORK
......
......@@ -27,7 +27,7 @@ DATABASES = {
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_FILE_PATH = '{}/log/emails/current'.format(dirname(SITE_ROOT))
SENDFILE_BACKEND = 'sendfile.backends.development'
#SENDFILE_BACKEND = 'sendfile.backends.development'
ADIM_PROD = False
ADIM_DEBUG_JS = True
......
......@@ -18,7 +18,7 @@ DATABASES = {
'NAME': 'adim_dev2',
'USER': 'adim',
'PASSWORD': 'ioue634jrs8asdfd0hewq876iujkh9877iuzhiuhg9875kb',
'HOST': 'leia.unil.ch',
'HOST': 'localhost',
},
}
......@@ -27,7 +27,7 @@ ATTP = {
'CACHE_TIMEOUT': 20, # 30,
},
'moodle': {
'CHECK_URL': "https://tstmoodle.unil.ch/33/mod/adim/checkAccess.php?uuid={uuid}",
'CHECK_URL': "https://tstmoodle.unil.ch/36/mod/adim/checkAccess.php?uuid={uuid}",
'MODE_ID': 16
},
'toto': {
......@@ -44,4 +44,13 @@ ADIM_PROD = False
ADIM_DEBUG_JS = False
# Only the ip listed here can access the admin interface
INTERNAL_IPS = ('130.223.159.72', )
\ No newline at end of file
INTERNAL_IPS = ('130.223.159.72', )
AAI = {
'SLO': True,
# Not yet used
'URLS': {
'SP_LOGOUT': "https://yin-zhen.unil.ch/Shibboleth.sso/Logout",
'idp_LOGOUT': "https://aai.unil.ch/idp/logout.jsp"
}
}
\ No newline at end of file
......@@ -44,15 +44,15 @@
<Directory "{{ settings.MEDIA_ROOT }}/ao_images/">
Order allow,deny
Deny from all
{% block xsendfile %}
# --------------
# XsendFile Conf
# --------------
<IfModule xsendfile_module>
XSendFile On
XSendFilePath "{{ settings.MEDIA_ROOT }}"
</IfModule>
{% endblock xsendfile %}
#{% block xsendfile %}
# # --------------
# # XsendFile Conf
# # --------------
# <IfModule xsendfile_module>
# XSendFile On
# XSendFilePath "{{ settings.MEDIA_ROOT }}"
# </IfModule>
#{% endblock xsendfile %}
</Directory>
{% endblock protected_media_paths %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment