mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-08 15:55:31 +01:00
filter by title or title+content fixes #636
This commit is contained in:
parent
e466c31bb3
commit
efa7b7b0b5
7 changed files with 116 additions and 36 deletions
|
|
@ -1,3 +1,4 @@
|
|||
from django.db.models import Q
|
||||
from django_filters.rest_framework import BooleanFilter, FilterSet, Filter
|
||||
|
||||
from .models import Correspondent, Document, Tag, DocumentType, Log
|
||||
|
|
@ -70,6 +71,16 @@ class InboxFilter(Filter):
|
|||
return qs
|
||||
|
||||
|
||||
class TitleContentFilter(Filter):
|
||||
|
||||
def filter(self, qs, value):
|
||||
if value:
|
||||
return qs.filter(Q(title__icontains=value) |
|
||||
Q(content__icontains=value))
|
||||
else:
|
||||
return qs
|
||||
|
||||
|
||||
class DocumentFilterSet(FilterSet):
|
||||
|
||||
is_tagged = BooleanFilter(
|
||||
|
|
@ -85,6 +96,8 @@ class DocumentFilterSet(FilterSet):
|
|||
|
||||
is_in_inbox = InboxFilter()
|
||||
|
||||
title_content = TitleContentFilter()
|
||||
|
||||
class Meta:
|
||||
model = Document
|
||||
fields = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue