Merge both search-fields into one

This commit is contained in:
Olaf Slomp
2019-10-31 10:32:07 +01:00
committed by Daan Sprenkels
parent 581e14f7ef
commit 4c9a431f8a
3 changed files with 4 additions and 7 deletions

View File

@ -95,8 +95,7 @@ def songs(request):
def search_songs(): def search_songs():
queries = [Q(deleted=False)] queries = [Q(deleted=False)]
queries.extend([Q(Q(artist__icontains=word) | Q(title__icontains=word)) for word in request.POST.get('all', '').split()]) queries.extend([Q(Q(artist__icontains=word) | Q(title__icontains=word) | Q(user__name__icontains=word)) for word in request.POST.get('all', '').split()])
queries.extend([Q(user__name__icontains=word) for word in request.POST.get('uploader', '').split()])
filter_query = queries.pop() filter_query = queries.pop()
for query in queries: for query in queries:

View File

@ -310,10 +310,9 @@ function refreshSeconds(playNextAt, now) {
function getSongs() { function getSongs() {
var all = $('#search-all').val(); var all = $('#search-all').val();
var uploader = $('#search-uploader').val();
var page = $('.pagenum').val(); var page = $('.pagenum').val();
var pagesize = $('.pagesize').val(); var pagesize = $('.pagesize').val();
$.post('/api/songs', {all: all, uploader: uploader, page: page, pagesize: pagesize, csrfmiddlewaretoken: csrf_token}, function (result) { $.post('/api/songs', {all: all, page: page, pagesize: pagesize, csrfmiddlewaretoken: csrf_token}, function (result) {
$('#request-table tbody').empty(); $('#request-table tbody').empty();
songs = result.data; songs = result.data;
$.each(songs, function (id, song) { $.each(songs, function (id, song) {
@ -413,4 +412,4 @@ function createAlert(type, message) {
message + message +
'</div>'; '</div>';
$('body > div.container > div.alert-location').prepend(alertText); $('body > div.container > div.alert-location').prepend(alertText);
} }

View File

@ -60,8 +60,7 @@
<th>Report</th> <th>Report</th>
</tr> </tr>
<tr> <tr>
<th colspan="2"><input id="search-all" class="search-input" type="text"></th> <th colspan="5"><input id="search-all" class="search-input" type="text"></th>
<th colspan="3"><input id="search-uploader" class="search-input" type="text"></th>
</tr> </tr>
</thead> </thead>
<tfoot> <tfoot>