Ejemplo n.º 1
0
def addSongsToPlaylist(libIds, library, activePlayer, user):
  for lib_id in libIds:
    libEntry = LibraryEntry.objects.get(library=library, lib_id=lib_id)

    addedEntry = ActivePlaylistEntry(song=libEntry, adder=user, player=activePlayer)
    addedEntry.save()

    Vote(playlist_entry=addedEntry, user=user, weight=1).save()
Ejemplo n.º 2
0
def addSongsToPlaylist(songs, activePlayer, user):
  for song in songs:
    libEntry = LibraryEntry.objects.get(library__id=int(song['library_id']), lib_id=song['id'])

    addedEntry = ActivePlaylistEntry(song=libEntry, adder=user, player=activePlayer)
    addedEntry.save()

    Vote(playlist_entry=addedEntry, user=user, weight=1).save()
Ejemplo n.º 3
0
def addSong2ActivePlaylist(song, event_id, adding_user):
  toReturn = ActivePlaylistEntry(
    song=LibraryEntry.objects.get(pk=song['lib_id']),
    adder=adding_user,
    event=Event.objects.get(pk=event_id),
    client_request_id=song['client_request_id'])
  toReturn.save()
  UpVote(playlist_entry=toReturn, user=adding_user).save()
  return toReturn
Ejemplo n.º 4
0
def addSongsToPlaylist(libIds, activePlayer, user):
  for lib_id in libIds:
    libEntry = LibraryEntry.objects.get(player=activePlayer, player_lib_song_id=lib_id,
      is_deleted=False, is_banned=False)

    addedEntry = ActivePlaylistEntry(song=libEntry, adder=user)
    addedEntry.save()

    Vote(playlist_entry=addedEntry, user=user, weight=1).save()
Ejemplo n.º 5
0
def addSongsToPlaylist(libIds, activePlayer, user):
    for lib_id in libIds:
        libEntry = LibraryEntry.objects.get(player=activePlayer,
                                            player_lib_song_id=lib_id,
                                            is_deleted=False,
                                            is_banned=False)

        addedEntry = ActivePlaylistEntry(song=libEntry, adder=user)
        addedEntry.save()

        Vote(playlist_entry=addedEntry, user=user, weight=1).save()
Ejemplo n.º 6
0
def add2ActivePlaylist(request, song_id, library_id, player):
  player.lockActivePlaylist()
  if ActivePlaylistEntry.isQueued(song_id, library_id, player):
    voteSong(player, request.udjuser, song_id, library_id, 1)
    return HttpResponse()
  elif ActivePlaylistEntry.isPlaying(song_id, library_id, player):
    return HttpResponse()

  if LibraryEntry.songExsitsAndNotBanned(song_id, int(library_id), player):
    addSongsToPlaylist([{'id' : song_id , 'library_id' : library_id}], player, request.udjuser)
  else:
    return HttpResponseMissingResource('song')

  return HttpResponse(status=201)
Ejemplo n.º 7
0
def add2ActivePlaylist(user, lib_id, default_library, player):
  player.lockActivePlaylist()
  if ActivePlaylistEntry.isQueued(lib_id, default_library, player):
    voteSong(player, user, lib_id, 1)
    return HttpResponse()
  elif ActivePlaylistEntry.isPlaying(lib_id, default_library, player):
    return HttpResponse()

  if LibraryEntry.songExsitsAndNotBanned(lib_id, default_library, player):
    addSongsToPlaylist([lib_id], default_library, player, user)
  else:
    toReturn = HttpResponseNotFound()
    toReturn[MISSING_RESOURCE_HEADER] = 'song'
    return toReturn

  return HttpResponse(status=201)
Ejemplo n.º 8
0
def add2ActivePlaylist(user, lib_id, player):
  player.lockActivePlaylist()
  if ActivePlaylistEntry.isQueued(lib_id, player):
    voteSong(player, user, lib_id, 1)
    return HttpResponse()
  elif ActivePlaylistEntry.isPlaying(lib_id, player):
    return HttpResponse()

  try:
    addSongsToPlaylist([lib_id], player, user)
  except ObjectDoesNotExist:
    toReturn = HttpResponseNotFound()
    toReturn[MISSING_RESOURCE_HEADER] = 'song'
    return toReturn

  return HttpResponse(status=201)
Ejemplo n.º 9
0
def add2ActivePlaylist(user, lib_id, activePlayer):

  if ActivePlaylistEntry.isQueuedOrPlaying(lib_id, activePlayer):
    return HttpResponse(status=409)

  try:
    addSongsToPlaylist([lib_id], activePlayer, user)
  except ObjectDoesNotExist:
    toReturn = HttpResponseNotFound()
    toReturn[MISSING_RESOURCE_HEADER] = 'song'
    return toReturn

  return HttpResponse(status=201)
Ejemplo n.º 10
0
def add2ActivePlaylist(user, lib_id, activePlayer):
    activePlayer.lockActivePlaylist()
    if ActivePlaylistEntry.isQueuedOrPlaying(lib_id, activePlayer):
        return HttpResponse(status=409)

    try:
        addSongsToPlaylist([lib_id], activePlayer, user)
    except ObjectDoesNotExist:
        toReturn = HttpResponseNotFound()
        toReturn[MISSING_RESOURCE_HEADER] = 'song'
        return toReturn

    return HttpResponse(status=201)
Ejemplo n.º 11
0
def getNotOnPlaylist(libIds, player):
  notOnPlaylist = []
  for libId in libIds:
    if not ActivePlaylistEntry.isQueued(libId, player):
      notOnPlaylist.append(libId)
  return notOnPlaylist
Ejemplo n.º 12
0
def getAlreadyOnPlaylist(libIds, player):
  alreadyOnPlaylist = []
  for libId in libIds:
    if ActivePlaylistEntry.isQueuedOrPlaying(libId, player):
      alreadyOnPlaylist.append(libId)
  return alreadyOnPlaylist
Ejemplo n.º 13
0
def getNotOnPlaylist(libIds, player):
    notOnPlaylist = []
    for libId in libIds:
        if not ActivePlaylistEntry.isQueued(libId, player):
            notOnPlaylist.append(libId)
    return notOnPlaylist
Ejemplo n.º 14
0
def getAlreadyOnPlaylist(libIds, library, player):
  return filter(lambda x: ActivePlaylistEntry.isQueuedOrPlaying(x, library, player), libIds)
Ejemplo n.º 15
0
def getNotOnPlaylist(songs, player):
  return filter(lambda x: not ActivePlaylistEntry.isQueued(x['id'], x['library_id'], player), songs)
Ejemplo n.º 16
0
def getAlreadyOnPlaylist(songs, player):
  return filter(lambda x: ActivePlaylistEntry.isQueuedOrPlaying(x['id'], x['library_id'], player),
                songs)
Ejemplo n.º 17
0
def getNotOnPlaylist(libIds, library, player):
  return filter(lambda x: not ActivePlaylistEntry.isQueued(x, library, player), libIds)
Ejemplo n.º 18
0
def getAlreadyOnPlaylist(libIds, player):
    alreadyOnPlaylist = []
    for libId in libIds:
        if ActivePlaylistEntry.isQueuedOrPlaying(libId, player):
            alreadyOnPlaylist.append(libId)
    return alreadyOnPlaylist