Skip to content

Commit

Permalink
backup for code
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-gray-tangent committed Jul 4, 2024
1 parent 0af1845 commit aa75f8c
Show file tree
Hide file tree
Showing 3 changed files with 221 additions and 93 deletions.
21 changes: 19 additions & 2 deletions app/general/filters.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import django_filters
from django import forms
from django.contrib.postgres.search import SearchQuery, SearchRank, SearchVector
from django_filters import ModelMultipleChoiceFilter, MultipleChoiceFilter

from general.models import DocumentFile
from general.models import DocumentFile, Institution, Language, Subject


class DocumentFileFilter(django_filters.FilterSet):
search = django_filters.CharFilter(method="filter_search", label="Search")
institution = ModelMultipleChoiceFilter(
queryset=Institution.objects.all(), widget=forms.CheckboxSelectMultiple
)
document_type = MultipleChoiceFilter(
choices=DocumentFile.document_type_choices, widget=forms.CheckboxSelectMultiple
)
subjects = ModelMultipleChoiceFilter(
queryset=Subject.objects.all(), widget=forms.CheckboxSelectMultiple
)
languages = ModelMultipleChoiceFilter(
queryset=Language.objects.all(), widget=forms.CheckboxSelectMultiple
)

class Meta:
model = DocumentFile
Expand All @@ -16,7 +30,10 @@ class Meta:
"languages",
]

def filter_search(self, queryset, value):
def filter_search(self, queryset, name, value):
print("name", name)
print("value", value)

if value:
queue = SearchQuery(value)
search_vector = SearchVector("title", "description", "document_data")
Expand Down
Loading

0 comments on commit aa75f8c

Please sign in to comment.