mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 21:52:21 +01:00
Fix user not showing in list of songs.
This commit is contained in:
@ -34,7 +34,7 @@ def songs(request):
|
||||
artist__icontains=request.POST.get('artist', ''),
|
||||
title__icontains=request.POST.get('title', ''),
|
||||
user__name__icontains=request.POST.get('uploader', '')
|
||||
).order_by('artist', 'title')
|
||||
).order_by('artist', 'title').select_related('user')
|
||||
total = len(songs_query)
|
||||
paginator = Paginator(songs_query, pagesize)
|
||||
|
||||
@ -45,7 +45,7 @@ def songs(request):
|
||||
except EmptyPage:
|
||||
songs = paginator.page(paginator.num_pages)
|
||||
|
||||
songs_dict = [song_to_dict(song) for song in songs.object_list]
|
||||
songs_dict = [song_to_dict(song, user=True) for song in songs.object_list]
|
||||
|
||||
return JsonResponse({
|
||||
'total': total,
|
||||
|
||||
@ -2,7 +2,7 @@ import socket, struct, binascii
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
def song_to_dict(song, hash=False):
|
||||
def song_to_dict(song, hash=False, user=False):
|
||||
data = {
|
||||
'id': song.id,
|
||||
'artist': song.artist,
|
||||
@ -13,8 +13,8 @@ def song_to_dict(song, hash=False):
|
||||
if hash:
|
||||
data['hash'] = song.hash
|
||||
|
||||
if hasattr(song, 'uploader_name') and song.uploader_name is not None and len(song.uploader_name) > 1:
|
||||
data['uploader_name'] = song.uploader_name
|
||||
if user and song.user is not None and len(song.user.name) > 1:
|
||||
data['uploader_name'] = song.user.name
|
||||
return data
|
||||
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@ class Queue(models.Model):
|
||||
.filter(Q(playlist=self.playlist_id) | Q(playlist_id=self.random_playlist_id),
|
||||
Q(state=0) | Q(state=1))\
|
||||
.order_by('-state', 'playlist_id', 'order')\
|
||||
.prefetch_related('song', 'user')
|
||||
.select_related('song', 'user')
|
||||
return self.songs
|
||||
|
||||
def current_song(self):
|
||||
|
||||
Reference in New Issue
Block a user