mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-01-30 23:08:59 -06:00
More cleanup
This commit is contained in:
@@ -193,7 +193,7 @@ def annotate_document_count_for_related_queryset(
|
|||||||
queryset,
|
queryset,
|
||||||
through_model,
|
through_model,
|
||||||
source_field: str,
|
source_field: str,
|
||||||
target_field: str,
|
target_field: str = "document_id",
|
||||||
user=None,
|
user=None,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -375,7 +375,6 @@ class PermissionsAwareDocumentCountMixin(BulkPermissionMixin, PassUserMixin):
|
|||||||
document_count_relation = "documents"
|
document_count_relation = "documents"
|
||||||
document_count_through = None # set to relation model to enable through counting
|
document_count_through = None # set to relation model to enable through counting
|
||||||
document_count_source_field = None
|
document_count_source_field = None
|
||||||
document_count_target_field = None
|
|
||||||
|
|
||||||
def get_document_count_filter(self):
|
def get_document_count_filter(self):
|
||||||
request = getattr(self, "request", None)
|
request = getattr(self, "request", None)
|
||||||
@@ -392,7 +391,6 @@ class PermissionsAwareDocumentCountMixin(BulkPermissionMixin, PassUserMixin):
|
|||||||
base_qs,
|
base_qs,
|
||||||
through_model=self.document_count_through,
|
through_model=self.document_count_through,
|
||||||
source_field=self.document_count_source_field,
|
source_field=self.document_count_source_field,
|
||||||
target_field=self.document_count_target_field,
|
|
||||||
user=user,
|
user=user,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -445,7 +443,6 @@ class TagViewSet(PermissionsAwareDocumentCountMixin, ModelViewSet):
|
|||||||
model = Tag
|
model = Tag
|
||||||
document_count_through = Document.tags.through
|
document_count_through = Document.tags.through
|
||||||
document_count_source_field = "tag_id"
|
document_count_source_field = "tag_id"
|
||||||
document_count_target_field = "document_id"
|
|
||||||
|
|
||||||
queryset = Tag.objects.select_related("owner").order_by(
|
queryset = Tag.objects.select_related("owner").order_by(
|
||||||
Lower("name"),
|
Lower("name"),
|
||||||
@@ -494,9 +491,8 @@ class TagViewSet(PermissionsAwareDocumentCountMixin, ModelViewSet):
|
|||||||
Tag.objects.filter(pk__in=descendant_pks | {t.pk for t in all_tags})
|
Tag.objects.filter(pk__in=descendant_pks | {t.pk for t in all_tags})
|
||||||
.select_related("owner")
|
.select_related("owner")
|
||||||
.order_by(*ordering),
|
.order_by(*ordering),
|
||||||
through_model=Document.tags.through,
|
through_model=self.document_count_through,
|
||||||
source_field="tag_id",
|
source_field=self.document_count_source_field,
|
||||||
target_field="document_id",
|
|
||||||
user=user,
|
user=user,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -2900,7 +2896,6 @@ class CustomFieldViewSet(PermissionsAwareDocumentCountMixin, ModelViewSet):
|
|||||||
model = CustomField
|
model = CustomField
|
||||||
document_count_through = CustomFieldInstance
|
document_count_through = CustomFieldInstance
|
||||||
document_count_source_field = "field_id"
|
document_count_source_field = "field_id"
|
||||||
document_count_target_field = "document_id"
|
|
||||||
|
|
||||||
queryset = CustomField.objects.all().order_by("-created")
|
queryset = CustomField.objects.all().order_by("-created")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user