mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
Fix some document actions but many are now wrong (not paginated)
This commit is contained in:
parent
31a2b36883
commit
fa18844b92
@ -377,16 +377,10 @@ class DocumentTypeViewSet(ModelViewSet, PermissionsAwareDocumentCountMixin):
|
||||
),
|
||||
history=extend_schema(
|
||||
description="View the document history",
|
||||
parameters=[
|
||||
OpenApiParameter(
|
||||
name="id",
|
||||
type=OpenApiTypes.STR,
|
||||
location=OpenApiParameter.PATH,
|
||||
),
|
||||
],
|
||||
responses={
|
||||
200: inline_serializer(
|
||||
name="LogEntry",
|
||||
many=True,
|
||||
fields={
|
||||
"id": serializers.IntegerField(),
|
||||
"timestamp": serializers.DateTimeField(),
|
||||
@ -408,13 +402,6 @@ class DocumentTypeViewSet(ModelViewSet, PermissionsAwareDocumentCountMixin):
|
||||
),
|
||||
metadata=extend_schema(
|
||||
description="View the document metadata",
|
||||
parameters=[
|
||||
OpenApiParameter(
|
||||
name="id",
|
||||
type=OpenApiTypes.STR,
|
||||
location=OpenApiParameter.PATH,
|
||||
),
|
||||
],
|
||||
responses={
|
||||
200: inline_serializer(
|
||||
name="Metadata",
|
||||
@ -440,29 +427,15 @@ class DocumentTypeViewSet(ModelViewSet, PermissionsAwareDocumentCountMixin):
|
||||
),
|
||||
notes=extend_schema(
|
||||
description="View, add, or delete notes for the document",
|
||||
parameters=[
|
||||
OpenApiParameter(
|
||||
name="id",
|
||||
type=OpenApiTypes.STR,
|
||||
location=OpenApiParameter.QUERY,
|
||||
),
|
||||
],
|
||||
responses={
|
||||
200: inline_serializer(
|
||||
name="Note",
|
||||
many=True,
|
||||
fields={
|
||||
"id": serializers.IntegerField(),
|
||||
"note": serializers.CharField(),
|
||||
"created": serializers.DateTimeField(),
|
||||
"user": inline_serializer(
|
||||
name="User",
|
||||
fields={
|
||||
"id": serializers.IntegerField(),
|
||||
"username": serializers.CharField(),
|
||||
"first_name": serializers.CharField(),
|
||||
"last_name": serializers.CharField(),
|
||||
},
|
||||
),
|
||||
"user": UserSerializer(),
|
||||
},
|
||||
),
|
||||
400: None,
|
||||
@ -472,13 +445,6 @@ class DocumentTypeViewSet(ModelViewSet, PermissionsAwareDocumentCountMixin):
|
||||
),
|
||||
suggestions=extend_schema(
|
||||
description="View suggestions for the document",
|
||||
parameters=[
|
||||
OpenApiParameter(
|
||||
name="id",
|
||||
type=OpenApiTypes.STR,
|
||||
location=OpenApiParameter.PATH,
|
||||
),
|
||||
],
|
||||
responses={
|
||||
200: inline_serializer(
|
||||
name="Suggestions",
|
||||
@ -503,17 +469,14 @@ class DocumentTypeViewSet(ModelViewSet, PermissionsAwareDocumentCountMixin):
|
||||
),
|
||||
thumb=extend_schema(
|
||||
description="View the document thumbnail",
|
||||
parameters=[
|
||||
OpenApiParameter(
|
||||
name="id",
|
||||
type=OpenApiTypes.STR,
|
||||
location=OpenApiParameter.PATH,
|
||||
),
|
||||
],
|
||||
responses={200: OpenApiTypes.BINARY},
|
||||
),
|
||||
preview=extend_schema(
|
||||
description="View the document preview",
|
||||
responses={200: OpenApiTypes.BINARY},
|
||||
),
|
||||
share_links=extend_schema(
|
||||
description="View share links for the document",
|
||||
parameters=[
|
||||
OpenApiParameter(
|
||||
name="id",
|
||||
@ -521,7 +484,12 @@ class DocumentTypeViewSet(ModelViewSet, PermissionsAwareDocumentCountMixin):
|
||||
location=OpenApiParameter.PATH,
|
||||
),
|
||||
],
|
||||
responses={200: OpenApiTypes.BINARY},
|
||||
responses={
|
||||
200: ShareLinkSerializer(many=True),
|
||||
400: None,
|
||||
403: None,
|
||||
404: None,
|
||||
},
|
||||
),
|
||||
)
|
||||
class DocumentViewSet(
|
||||
@ -657,7 +625,7 @@ class DocumentViewSet(
|
||||
else:
|
||||
return None
|
||||
|
||||
@action(methods=["get"], detail=True)
|
||||
@action(methods=["get"], detail=True, filter_backends=[])
|
||||
@method_decorator(cache_control(no_cache=True))
|
||||
@method_decorator(
|
||||
condition(etag_func=metadata_etag, last_modified_func=metadata_last_modified),
|
||||
@ -716,7 +684,7 @@ class DocumentViewSet(
|
||||
|
||||
return Response(meta)
|
||||
|
||||
@action(methods=["get"], detail=True)
|
||||
@action(methods=["get"], detail=True, filter_backends=[])
|
||||
@method_decorator(cache_control(no_cache=True))
|
||||
@method_decorator(
|
||||
condition(
|
||||
@ -767,7 +735,7 @@ class DocumentViewSet(
|
||||
|
||||
return Response(resp_data)
|
||||
|
||||
@action(methods=["get"], detail=True)
|
||||
@action(methods=["get"], detail=True, filter_backends=[])
|
||||
@method_decorator(cache_control(no_cache=True))
|
||||
@method_decorator(
|
||||
condition(etag_func=preview_etag, last_modified_func=preview_last_modified),
|
||||
@ -779,7 +747,7 @@ class DocumentViewSet(
|
||||
except (FileNotFoundError, Document.DoesNotExist):
|
||||
raise Http404
|
||||
|
||||
@action(methods=["get"], detail=True)
|
||||
@action(methods=["get"], detail=True, filter_backends=[])
|
||||
@method_decorator(cache_control(no_cache=True))
|
||||
@method_decorator(last_modified(thumbnail_last_modified))
|
||||
def thumb(self, request, pk=None):
|
||||
@ -838,6 +806,7 @@ class DocumentViewSet(
|
||||
methods=["get", "post", "delete"],
|
||||
detail=True,
|
||||
permission_classes=[PaperlessNotePermissions],
|
||||
filter_backends=[],
|
||||
)
|
||||
def notes(self, request, pk=None):
|
||||
currentUser = request.user
|
||||
@ -945,7 +914,7 @@ class DocumentViewSet(
|
||||
},
|
||||
)
|
||||
|
||||
@action(methods=["get"], detail=True)
|
||||
@action(methods=["get"], detail=True, filter_backends=[])
|
||||
def share_links(self, request, pk=None):
|
||||
currentUser = request.user
|
||||
try:
|
||||
@ -963,21 +932,16 @@ class DocumentViewSet(
|
||||
|
||||
if request.method == "GET":
|
||||
now = timezone.now()
|
||||
links = [
|
||||
{
|
||||
"id": c.pk,
|
||||
"created": c.created,
|
||||
"expiration": c.expiration,
|
||||
"slug": c.slug,
|
||||
}
|
||||
for c in ShareLink.objects.filter(document=doc)
|
||||
links = (
|
||||
ShareLink.objects.filter(document=doc)
|
||||
.only("pk", "created", "expiration", "slug")
|
||||
.exclude(expiration__lt=now)
|
||||
.order_by("-created")
|
||||
]
|
||||
return Response(links)
|
||||
)
|
||||
serializer = ShareLinkSerializer(links, many=True)
|
||||
return Response(serializer.data)
|
||||
|
||||
@action(methods=["get"], detail=True, name="Audit Trail")
|
||||
@action(methods=["get"], detail=True, name="Audit Trail", filter_backends=[])
|
||||
def history(self, request, pk=None):
|
||||
if not settings.AUDIT_LOG_ENABLED:
|
||||
return HttpResponseBadRequest("Audit log is disabled")
|
||||
|
Loading…
x
Reference in New Issue
Block a user