mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-10 08:42:20 +01:00
Fixes on arrows in the main screen
This commit is contained in:
@ -201,7 +201,14 @@ def move_up(request):
|
||||
@require_http_methods(["POST"])
|
||||
@api_auth_required
|
||||
def move_down(request):
|
||||
# print('')
|
||||
# print(request)
|
||||
# print('')
|
||||
ide=(request.POST.get('id'))
|
||||
# print('')
|
||||
playlist_song = get_object_or_404(PlaylistSong, id=request.POST.get('id'))
|
||||
# print(playlist_song)
|
||||
# print('')
|
||||
if playlist_song.user != request.user and not request.user.has_perm('queues.can_move'):
|
||||
return HttpResponseForbidden()
|
||||
playlist_song.move_down()
|
||||
|
||||
@ -194,12 +194,18 @@ function renderQueue(playNextAt, now)
|
||||
{
|
||||
$('.queuebody').empty();
|
||||
var timeToPlay = playNextAt - now;
|
||||
var canDeletePrevious = false;
|
||||
$.each(queue, function (id, song) {
|
||||
var requestedBy = song.requested_by;
|
||||
var canDelete = song.can_move_down || canMoveSongs;
|
||||
var canMoveDown = canDelete && id < queue.length - 1;
|
||||
var canMoveUp = canMoveSongs && id != queue.length -5 || canDeletePrevious && id < queue.length - 5;
|
||||
var canMoveDown = canDelete && id < queue.length - 6 || canMoveSongs && id < queue.length - 1 && id != queue.length - 6;
|
||||
var artist = song.song.artist.trim() === '' ? '?' : song.song.artist;
|
||||
var title = song.song.title.trim() === '' ? '?' : song.song.title;
|
||||
var prevId = song.id - 1;
|
||||
console.log(song.id, id);
|
||||
console.log(song);
|
||||
console.log(queue);
|
||||
|
||||
showTime = showTimeToPlay ? (timeToPlay < 0 ? '' : timeToPlay.secondsToMMSS()) : (playNextAt < now ? '' : playNextAt.timestampToHHMMSS())
|
||||
|
||||
@ -207,14 +213,15 @@ function renderQueue(playNextAt, now)
|
||||
+ '</td><td class="title">' + title + '</td><td class="hidden-xs requested-by">' + requestedBy
|
||||
+ '</td><td class="hidden-xs plays-at" style="text-align: right;">' + showTime
|
||||
+ '</td><td>' + '<a href="#" class="glyphicon glyphicon-arrow-up'
|
||||
+ (canMoveSongs && id !== 0 ? '' : ' invisible')
|
||||
+ '" onclick="return moveUp(' + song.id
|
||||
+ (canMoveUp && id !== 0 ? '' : ' invisible')
|
||||
+ '" onclick=" return moveDown(' + prevId
|
||||
+ ')"></a> <a href="#" class="glyphicon glyphicon-arrow-down'
|
||||
+ (canMoveDown ? '' : ' invisible') + '" onclick="return moveDown('
|
||||
+ song.id + ')"></a> <a href="#" class="glyphicon glyphicon-trash'
|
||||
+ (canDelete ? '' : ' invisible') + '" onclick="return cancelSong('
|
||||
+ song.id + ')"></a></td></tr>');
|
||||
timeToPlay += parseInt(song.song.duration);
|
||||
canDeletePrevious = canDelete
|
||||
if(playNextAt >= now)
|
||||
{
|
||||
playNextAt += parseInt(song.song.duration);
|
||||
|
||||
@ -53,8 +53,12 @@ class PlaylistSong(models.Model):
|
||||
self.switch_order(other_song)
|
||||
|
||||
def move_down(self):
|
||||
other_song = PlaylistSong.objects.filter(playlist=self.playlist, id__gt=self.id).order_by('id').first()
|
||||
self.switch_order(other_song)
|
||||
other_song = PlaylistSong.objects.filter(playlist=self.playlist, id__gt=self.id).first()
|
||||
old_id = self.id
|
||||
self.id = other_song.id
|
||||
other_song.id = old_id
|
||||
self.save()
|
||||
other_song.save()
|
||||
|
||||
def switch_order(self, other_song):
|
||||
old_id = self.id
|
||||
|
||||
Reference in New Issue
Block a user