feat: add document management views, URLs, and permission unit tests
This commit is contained in:
parent
80f2956872
commit
061fb6dc62
3 changed files with 820 additions and 777 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,3 +1,4 @@
|
||||||
|
from django.contrib.auth.decorators import login_not_required
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
@ -60,11 +61,11 @@ urlpatterns = [
|
||||||
path("<int:pk>/remove-folder/<int:folder_id>/", views.RemoveFolderFromDocumentView.as_view(), name="remove_folder"),
|
path("<int:pk>/remove-folder/<int:folder_id>/", views.RemoveFolderFromDocumentView.as_view(), name="remove_folder"),
|
||||||
path("<int:pk>/add-tag/", views.AddTagToDocumentView.as_view(), name="add_tag"),
|
path("<int:pk>/add-tag/", views.AddTagToDocumentView.as_view(), name="add_tag"),
|
||||||
path("<int:pk>/remove-tag/<int:tag_id>/", views.RemoveTagFromDocumentView.as_view(), name="remove_tag"),
|
path("<int:pk>/remove-tag/<int:tag_id>/", views.RemoveTagFromDocumentView.as_view(), name="remove_tag"),
|
||||||
path("public/<str:token>/", views.PublicDocumentView.as_view(), name="public_view"),
|
path("public/<str:token>/", login_not_required(views.PublicDocumentView.as_view()), name="public_view"),
|
||||||
path("public/<str:token>/download/", views.PublicDocumentDownloadView.as_view(), name="public_download"),
|
path("public/<str:token>/download/", login_not_required(views.PublicDocumentDownloadView.as_view()), name="public_download"),
|
||||||
path(
|
path(
|
||||||
"folders/public/<str:token>/",
|
"folders/public/<str:token>/",
|
||||||
views.PublicFolderView.as_view(),
|
login_not_required(views.PublicFolderView.as_view()),
|
||||||
name="folder_public",
|
name="folder_public",
|
||||||
),
|
),
|
||||||
path("<int:pk>/georeference/", views.DocumentGeoreferenceView.as_view(), name="georeference"),
|
path("<int:pk>/georeference/", views.DocumentGeoreferenceView.as_view(), name="georeference"),
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import mimetypes
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
|
from django.contrib.auth.decorators import login_not_required
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
|
|
@ -11,6 +12,7 @@ from django.db.models.functions import Lower
|
||||||
from django.shortcuts import get_object_or_404, redirect, render
|
from django.shortcuts import get_object_or_404, redirect, render
|
||||||
from django.urls import reverse, reverse_lazy
|
from django.urls import reverse, reverse_lazy
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from django.utils.decorators import method_decorator
|
||||||
from django.utils.encoding import smart_str
|
from django.utils.encoding import smart_str
|
||||||
from django.utils.http import url_has_allowed_host_and_scheme
|
from django.utils.http import url_has_allowed_host_and_scheme
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
@ -1352,6 +1354,7 @@ class RemoveTagFromDocumentView(LoginRequiredMixin, View):
|
||||||
return redirect(document.get_absolute_url())
|
return redirect(document.get_absolute_url())
|
||||||
|
|
||||||
|
|
||||||
|
@method_decorator(login_not_required, name="dispatch")
|
||||||
class PublicDocumentView(View):
|
class PublicDocumentView(View):
|
||||||
template_name = "documents/document_public.html"
|
template_name = "documents/document_public.html"
|
||||||
|
|
||||||
|
|
@ -1376,6 +1379,7 @@ class PublicDocumentView(View):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@method_decorator(login_not_required, name="dispatch")
|
||||||
class PublicDocumentDownloadView(View):
|
class PublicDocumentDownloadView(View):
|
||||||
def get(self, request, token):
|
def get(self, request, token):
|
||||||
link = get_object_or_404(
|
link = get_object_or_404(
|
||||||
|
|
@ -1409,6 +1413,7 @@ class PublicDocumentDownloadView(View):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
@method_decorator(login_not_required, name="dispatch")
|
||||||
class PublicFolderView(View):
|
class PublicFolderView(View):
|
||||||
template_name = "documents/documentfolder_public.html"
|
template_name = "documents/documentfolder_public.html"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue