Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • AlekSIS/official/AlekSIS-App-Resint
  • sunweaver/AlekSIS-App-Resint
2 results
Show changes
Commits on Source (1)
......@@ -5,6 +5,7 @@ from .views import (
LiveDocumentDeleteView,
LiveDocumentEditView,
LiveDocumentListView,
LiveDocumentShowAPIView,
LiveDocumentShowView,
PosterCurrentView,
PosterDeleteView,
......@@ -42,4 +43,9 @@ urlpatterns = [
path(
"live_documents/<str:slug>.pdf", LiveDocumentShowView.as_view(), name="show_live_document",
),
path(
"api/live_documents/<str:slug>.pdf",
LiveDocumentShowAPIView.as_view(),
name="api_show_live_document",
),
]
......@@ -15,6 +15,7 @@ from django.views.generic.list import ListView
from django_tables2 import SingleTableView
from guardian.shortcuts import get_objects_for_user
from oauth2_provider.views.mixins import ClientProtectedResourceMixin
from reversion.views import RevisionMixin
from rules.contrib.views import PermissionRequiredMixin
......@@ -221,15 +222,24 @@ class LiveDocumentDeleteView(PermissionRequiredMixin, RevisionMixin, AdvancedDel
success_message = _("The live document has been deleted.")
class LiveDocumentShowView(PermissionRequiredMixin, SingleObjectMixin, View):
"""Show the current version of the live document."""
class LiveDocumentShowBaseView(SingleObjectMixin, View):
"""Base view for showing live documents."""
model = LiveDocument
permission_required = "resint.view_livedocument_rule"
def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> FileResponse:
live_document = self.get_object()
file = live_document.get_current_file()
if not file:
raise Http404
return FileResponse(file.file, content_type="application/pdf")
return FileResponse(file, content_type="application/pdf")
class LiveDocumentShowView(PermissionRequiredMixin, LiveDocumentShowBaseView):
"""Show the current version of the live document."""
permission_required = "resint.view_livedocument_rule"
class LiveDocumentShowAPIView(ClientProtectedResourceMixin, LiveDocumentShowBaseView):
"""Show the current version of the live document in API."""