Exemple #1
0
def times_to_songs(request, times):
    times = times.split(",")
    songs = []
    for target_time in times:
	song = RadioPlay.objects.order_by('-time').filter(time__lte=target_time)
	if song:
	    song22 = song[0].song
            fav = UserFavorites(song=song22)
            fav.save()
            songs.append(song22)
    if len(songs) <= 0:
	return HttpResponse(simplejson.dumps([{"album": "not found", "song_id": 1, "title": "not found", "artist": "not found", "song_year": "", "label": ""}]))
    songs = [song.gather_fields() for song in songs]
    return HttpResponse(simplejson.dumps(songs))
Exemple #2
0
def add_to_favorites(request, song_id):
    favorite = UserFavorites(song=Song.objects.get(id=song_id))
    favorite.save()
    return redirect("http://mooncolony.org:8000/play_favorites")