mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-05-03 11:29:28 -05:00
Better search endpoints schema
This commit is contained in:
parent
313431ead8
commit
a92dd74a42
@ -442,7 +442,7 @@ class TagSerializerVersion1(MatchingModelSerializer, OwnedObjectSerializer):
|
|||||||
|
|
||||||
|
|
||||||
class TagSerializer(MatchingModelSerializer, OwnedObjectSerializer):
|
class TagSerializer(MatchingModelSerializer, OwnedObjectSerializer):
|
||||||
def get_text_color(self, obj):
|
def get_text_color(self, obj) -> str:
|
||||||
try:
|
try:
|
||||||
h = obj.color.lstrip("#")
|
h = obj.color.lstrip("#")
|
||||||
rgb = tuple(int(h[i : i + 2], 16) / 256 for i in (0, 2, 4))
|
rgb = tuple(int(h[i : i + 2], 16) / 256 for i in (0, 2, 4))
|
||||||
@ -1003,7 +1003,7 @@ class DocumentSerializer(
|
|||||||
|
|
||||||
# return full permissions if we're doing a PATCH or PUT
|
# return full permissions if we're doing a PATCH or PUT
|
||||||
context = kwargs.get("context")
|
context = kwargs.get("context")
|
||||||
if (
|
if context is not None and (
|
||||||
context.get("request").method == "PATCH"
|
context.get("request").method == "PATCH"
|
||||||
or context.get("request").method == "PUT"
|
or context.get("request").method == "PUT"
|
||||||
):
|
):
|
||||||
|
@ -1558,6 +1558,45 @@ class SearchAutoCompleteView(GenericAPIView):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@extend_schema_view(
|
||||||
|
get=extend_schema(
|
||||||
|
description="Global search",
|
||||||
|
parameters=[
|
||||||
|
OpenApiParameter(
|
||||||
|
name="query",
|
||||||
|
required=True,
|
||||||
|
type=str,
|
||||||
|
description="Query to search for",
|
||||||
|
),
|
||||||
|
OpenApiParameter(
|
||||||
|
name="db_only",
|
||||||
|
required=False,
|
||||||
|
type=bool,
|
||||||
|
description="Search only the database",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
responses={
|
||||||
|
(200, "application/json"): inline_serializer(
|
||||||
|
name="SearchResult",
|
||||||
|
fields={
|
||||||
|
"total": serializers.IntegerField(),
|
||||||
|
"documents": DocumentSerializer(many=True),
|
||||||
|
"saved_views": SavedViewSerializer(many=True),
|
||||||
|
"tags": TagSerializer(many=True),
|
||||||
|
"correspondents": CorrespondentSerializer(many=True),
|
||||||
|
"document_types": DocumentTypeSerializer(many=True),
|
||||||
|
"storage_paths": StoragePathSerializer(many=True),
|
||||||
|
"users": UserSerializer(many=True),
|
||||||
|
"groups": GroupSerializer(many=True),
|
||||||
|
"mail_rules": MailRuleSerializer(many=True),
|
||||||
|
"mail_accounts": MailAccountSerializer(many=True),
|
||||||
|
"workflows": WorkflowSerializer(many=True),
|
||||||
|
"custom_fields": CustomFieldSerializer(many=True),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
class GlobalSearchView(PassUserMixin):
|
class GlobalSearchView(PassUserMixin):
|
||||||
permission_classes = (IsAuthenticated,)
|
permission_classes = (IsAuthenticated,)
|
||||||
serializer_class = SearchResultSerializer
|
serializer_class = SearchResultSerializer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user