Merge branch 'main' of ssh://git.edgarpierre.fr:39529/edpibu/nummi

This commit is contained in:
Edgar P. Burkhart 2022-12-21 15:14:36 +01:00
commit 98fea25615
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
2 changed files with 7 additions and 4 deletions

View file

@ -22,11 +22,9 @@ from django.conf.urls.static import static
from . import views
urlpatterns = [
path("media/<path:path>", views.media, name="media"),
] + i18n_patterns(
urlpatterns = [path("media/<path:path>", views.media, name="media"),] + i18n_patterns(
path("", include("main.urls")),
path("plot/", include("plot.urls")),
path("admin/", admin.site.urls),
prefix_default_language=False,
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
)

View file

@ -1,8 +1,13 @@
from django.conf import settings
from django.http import HttpResponse
from django.contrib.auth.decorators import login_required
from django.views.static import serve
@login_required
def media(request, path):
if settings.DEBUG:
return serve(request, path, settings.MEDIA_ROOT)
_res = HttpResponse()
_res["Content-Type"] = ""
_res["X-Accel-Redirect"] = "/internal/media/" + path