photo26/photo21/views.py
2021-10-22 17:52:27 +02:00

22 lines
717 B
Python

# Copyright (C) 2021 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic import ListView, View
from django.http import HttpResponse
from photologue.models import Gallery
class MediaAccess(LoginRequiredMixin, View):
def get(self, request, path):
response = HttpResponse()
# Content-type will be detected by nginx
del response['Content-Type']
response['X-Accel-Redirect'] = '/protected/media/' + path
return response
class IndexView(LoginRequiredMixin, ListView):
queryset = Gallery.objects.on_site().is_public()
paginate_by = 4
template_name = "index.html"