mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-02-18 00:29:35 -06:00
Fix more typing failures
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
from typing import Any
|
||||||
|
|
||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.models import Group
|
||||||
from django.contrib.auth.models import Permission
|
from django.contrib.auth.models import Permission
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
@@ -199,12 +201,12 @@ def get_document_count_filter_for_user(user):
|
|||||||
|
|
||||||
|
|
||||||
def annotate_document_count_for_related_queryset(
|
def annotate_document_count_for_related_queryset(
|
||||||
queryset,
|
queryset: QuerySet[Any],
|
||||||
through_model,
|
through_model: Any,
|
||||||
related_object_field: str,
|
related_object_field: str,
|
||||||
target_field: str = "document_id",
|
target_field: str = "document_id",
|
||||||
user=None,
|
user: User | None = None,
|
||||||
):
|
) -> QuerySet[Any]:
|
||||||
"""
|
"""
|
||||||
Annotate a queryset with permissions-aware document counts using a subquery
|
Annotate a queryset with permissions-aware document counts using a subquery
|
||||||
against a relation table.
|
against a relation table.
|
||||||
@@ -234,11 +236,11 @@ def annotate_document_count_for_related_queryset(
|
|||||||
|
|
||||||
|
|
||||||
def get_objects_for_user_owner_aware(
|
def get_objects_for_user_owner_aware(
|
||||||
user,
|
user: User | None,
|
||||||
perms,
|
perms: str | list[str],
|
||||||
Model,
|
Model: Any,
|
||||||
*,
|
*,
|
||||||
include_deleted=False,
|
include_deleted: bool = False,
|
||||||
) -> QuerySet:
|
) -> QuerySet:
|
||||||
"""
|
"""
|
||||||
Returns objects the user owns, are unowned, or has explicit perms.
|
Returns objects the user owns, are unowned, or has explicit perms.
|
||||||
@@ -314,7 +316,7 @@ class AcknowledgeTasksPermissions(BasePermission):
|
|||||||
"POST": ["documents.change_paperlesstask"],
|
"POST": ["documents.change_paperlesstask"],
|
||||||
}
|
}
|
||||||
|
|
||||||
def has_permission(self, request, view):
|
def has_permission(self, request: Any, view: Any) -> bool:
|
||||||
if not request.user or not request.user.is_authenticated: # pragma: no cover
|
if not request.user or not request.user.is_authenticated: # pragma: no cover
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -2952,7 +2952,7 @@ class TrashSerializer(SerializerWithPerms):
|
|||||||
write_only=True,
|
write_only=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def validate_documents(self, documents):
|
def validate_documents(self, documents: list[int]) -> list[int]:
|
||||||
count = Document.deleted_objects.filter(id__in=documents).count()
|
count = Document.deleted_objects.filter(id__in=documents).count()
|
||||||
if not count == len(documents):
|
if not count == len(documents):
|
||||||
raise serializers.ValidationError(
|
raise serializers.ValidationError(
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ class PermissionsAwareDocumentCountMixin(BulkPermissionMixin, PassUserMixin):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Default is simple relation path, override for through-table/count specialization.
|
# Default is simple relation path, override for through-table/count specialization.
|
||||||
document_count_through = None
|
document_count_through: type[Model] | None = None
|
||||||
document_count_source_field: str | None = None
|
document_count_source_field: str | None = None
|
||||||
|
|
||||||
def _get_document_count_source_field(self) -> str:
|
def _get_document_count_source_field(self) -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user