mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-10 06:42:21 +01:00
delete move_up and switch_order functions
This commit is contained in:
@ -13,7 +13,6 @@ urlpatterns = [
|
|||||||
url(r'^request', views.request),
|
url(r'^request', views.request),
|
||||||
url(r'^report', views.report),
|
url(r'^report', views.report),
|
||||||
url(r'^skip', views.skip),
|
url(r'^skip', views.skip),
|
||||||
url(r'^moveup', views.move_up),
|
|
||||||
url(r'^movedown', views.move_down),
|
url(r'^movedown', views.move_down),
|
||||||
url(r'^cancel', views.cancel),
|
url(r'^cancel', views.cancel),
|
||||||
url(r'^upload', views.upload),
|
url(r'^upload', views.upload),
|
||||||
|
|||||||
@ -188,27 +188,10 @@ def skip(request):
|
|||||||
return JsonResponse({})
|
return JsonResponse({})
|
||||||
|
|
||||||
|
|
||||||
@require_http_methods(["POST"])
|
|
||||||
@api_auth_required
|
|
||||||
def move_up(request):
|
|
||||||
if not request.user.has_perm('queues.can_move'):
|
|
||||||
return HttpResponseForbidden()
|
|
||||||
playlist_song = get_object_or_404(PlaylistSong, id=request.POST.get('id'))
|
|
||||||
playlist_song.move_up()
|
|
||||||
return JsonResponse({})
|
|
||||||
|
|
||||||
|
|
||||||
@require_http_methods(["POST"])
|
@require_http_methods(["POST"])
|
||||||
@api_auth_required
|
@api_auth_required
|
||||||
def move_down(request):
|
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'))
|
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'):
|
if playlist_song.user != request.user and not request.user.has_perm('queues.can_move'):
|
||||||
return HttpResponseForbidden()
|
return HttpResponseForbidden()
|
||||||
playlist_song.move_down()
|
playlist_song.move_down()
|
||||||
|
|||||||
@ -47,10 +47,6 @@ class PlaylistSong(models.Model):
|
|||||||
)
|
)
|
||||||
state = models.IntegerField(default=0, db_index=True, choices=STATECHOICE)
|
state = models.IntegerField(default=0, db_index=True, choices=STATECHOICE)
|
||||||
|
|
||||||
def move_up(self):
|
|
||||||
other_song = PlaylistSong.objects.filter(playlist=self.playlist, id__lt=self.id)\
|
|
||||||
.order_by('-id').first()
|
|
||||||
self.switch_order(other_song)
|
|
||||||
|
|
||||||
def move_down(self):
|
def move_down(self):
|
||||||
other_song = PlaylistSong.objects.filter(playlist=self.playlist, id__gt=self.id).first()
|
other_song = PlaylistSong.objects.filter(playlist=self.playlist, id__gt=self.id).first()
|
||||||
@ -60,13 +56,6 @@ class PlaylistSong(models.Model):
|
|||||||
self.save()
|
self.save()
|
||||||
other_song.save()
|
other_song.save()
|
||||||
|
|
||||||
def switch_order(self, other_song):
|
|
||||||
old_id = self.id
|
|
||||||
self.id = other_song.id
|
|
||||||
other_song.id = old_id
|
|
||||||
self.save()
|
|
||||||
other_song.save()
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return 'Playlist #' + str(self.playlist_id) + ': ' + str(self.song)
|
return 'Playlist #' + str(self.playlist_id) + ': ' + str(self.song)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user