fnp
/
audio.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
5ee0595
)
Update Django, add search.
author
Radek Czajka
<rczajka@rczajka.pl>
Tue, 18 Aug 2020 14:04:34 +0000
(16:04 +0200)
committer
Radek Czajka
<rczajka@rczajka.pl>
Tue, 18 Aug 2020 14:04:34 +0000
(16:04 +0200)
requirements.txt
patch
|
blob
|
history
src/archive/templates/archive/audiobook_list.html
patch
|
blob
|
history
src/archive/views.py
patch
|
blob
|
history
src/audiobooks/settings.py
patch
|
blob
|
history
diff --git
a/requirements.txt
b/requirements.txt
index
c355845
..
bfe2ad6
100644
(file)
--- a/
requirements.txt
+++ b/
requirements.txt
@@
-1,6
+1,6
@@
-i https://py.mdrn.pl:8443/simple
-i https://py.mdrn.pl:8443/simple
-Django==3.
0.6
+Django==3.
1
django-cas-ng==4.1.1
django-bootstrap4==1.1.1
django-pglocks==1.0.4
django-cas-ng==4.1.1
django-bootstrap4==1.1.1
django-pglocks==1.0.4
diff --git
a/src/archive/templates/archive/audiobook_list.html
b/src/archive/templates/archive/audiobook_list.html
index
f4a49a9
..
b006726
100644
(file)
--- a/
src/archive/templates/archive/audiobook_list.html
+++ b/
src/archive/templates/archive/audiobook_list.html
@@
-13,6
+13,14
@@
{% block file-list-info %}
{% block file-list-info %}
+ <form>
+ <div class="input-group">
+ <input class="form-control" name="s" value="{{ request.GET.s }}">
+ <div class="input-group-append">
+ <button class="btn btn-primary">Szukaj</button>
+ </div>
+ </div>
+ </form>
{% endblock %}
{% block file-list-wrapper %}
{% endblock %}
{% block file-list-wrapper %}
diff --git
a/src/archive/views.py
b/src/archive/views.py
index
2170aff
..
fab7a1c
100644
(file)
--- a/
src/archive/views.py
+++ b/
src/archive/views.py
@@
-5,6
+5,7
@@
from urllib.parse import quote
from archive import settings
from django.contrib.auth.decorators import permission_required
from archive import settings
from django.contrib.auth.decorators import permission_required
+from django.contrib.postgres.search import SearchVector
from django.urls import reverse
from django.db.models import Q, Max
from django.http import Http404, HttpResponse
from django.urls import reverse
from django.db.models import Q, Max
from django.http import Http404, HttpResponse
@@
-229,7
+230,11
@@
def list_publishing(request):
class AudiobookList(ListView):
class AudiobookList(ListView):
- queryset = models.Audiobook.objects.all()
+ def get_queryset(self):
+ qs = models.Audiobook.objects.all()
+ if 's' in self.request.GET:
+ qs = qs.annotate(s=SearchVector('title', 'slug')).filter(s=self.request.GET['s'])
+ return qs
@permission_required('archive.change_audiobook')
@permission_required('archive.change_audiobook')
diff --git
a/src/audiobooks/settings.py
b/src/audiobooks/settings.py
index
901da0f
..
f36fe81
100644
(file)
--- a/
src/audiobooks/settings.py
+++ b/
src/audiobooks/settings.py
@@
-125,6
+125,7
@@
INSTALLED_APPS = (
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
+ 'django.contrib.postgres',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'bootstrap4',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'bootstrap4',