Beispiel #1
0
def bootstrap(request):
    # Don't create dummy playlist tracks if playlist tracks already exist!
    pl_tracks = PlaylistTrack.all().fetch(1)
    if len(pl_tracks) > 0:
        return HttpResponse(status=404)

    playlist = ChirpBroadcast()

    minutes = 0
    tracks = Track.all().fetch(100)
    for track in tracks:
        pl_track = PlaylistTrack(playlist=playlist,
                                 selector=request.user,
                                 established=datetime.now() -
                                 timedelta(minutes=minutes),
                                 artist=track.album.album_artist,
                                 album=track.album,
                                 track=track)
        pl_track.put()
        if minutes > 0 and minutes % 25 == 0:
            pl_break = PlaylistBreak(playlist=playlist,
                                     established=datetime.now() -
                                     timedelta(minutes=minutes - 1))
            pl_break.put()
        minutes += 5

    return HttpResponseRedirect("/playlists/")
Beispiel #2
0
def bootstrap(request):
    # Don't create dummy playlist tracks if playlist tracks already exist!
    pl_tracks = PlaylistTrack.all().fetch(1)
    if len(pl_tracks) > 0:
        return HttpResponse(status=404)

    playlist = ChirpBroadcast()

    minutes = 0
    tracks = Track.all().fetch(100)
    for track in tracks:
        pl_track = PlaylistTrack(
            playlist=playlist,
            selector=request.user,
            established=datetime.now() - timedelta(minutes=minutes),
            artist=track.album.album_artist,
            album=track.album,
            track=track,
        )
        pl_track.put()
        if minutes > 0 and minutes % 25 == 0:
            pl_break = PlaylistBreak(playlist=playlist, established=datetime.now() - timedelta(minutes=minutes - 1))
            pl_break.put()
        minutes += 5

    return HttpResponseRedirect("/playlists/")
Beispiel #3
0
    def test_break(self):
        playlist = ChirpBroadcast()
        selector = create_dj()

        track = PlaylistTrack(selector=selector,
                              playlist=playlist,
                              freeform_artist_name="The Meters",
                              freeform_album_title="Chicken Strut",
                              freeform_track_title="Hand Clapping Song")
        track.put()
        time.sleep(0.4)

        pl_break = PlaylistBreak(playlist=playlist)
        pl_break.put()

        self.assertEqual([type(e) for e in playlist.recent_tracks],
                         [PlaylistTrack])

        self.assertEqual([type(e) for e in playlist.recent_events],
                         [PlaylistBreak, PlaylistTrack])
Beispiel #4
0
def create_event(request):
    vars = get_vars(request)

    if request.method == "POST":

        # special case...
        if request.POST.get("submit") == "Add Break":
            b = PlaylistBreak(playlist=vars["playlist"])
            b.put()
            vars["add_break"] = True
            # errors should not display on add break, reset internal hash
            vars["form"]._errors = {}

        elif vars["form"].is_valid():
            track = vars["form"].save()
            playlist_event_listeners.create(track)
            return HttpResponseRedirect(reverse("playlists_landing_page"))

    vars["playlist_events"] = get_playlist_history(vars["playlist"])

    return landing_page(request, vars)
Beispiel #5
0
def create_event(request):
    vars = get_vars(request)

    if request.method == 'POST':

        # special case...
        if request.POST.get('submit') == 'Add Break':
            b = PlaylistBreak(playlist=vars['playlist'])
            b.put()
            vars['add_break'] = True
            # errors should not display on add break, reset internal hash
            vars['form']._errors = {}

        elif vars['form'].is_valid():
            track = vars['form'].save()
            playlist_event_listeners.create(track)
            return HttpResponseRedirect(reverse('playlists_landing_page'))

    vars['playlist_events'] = get_playlist_history(vars['playlist'])

    return landing_page(request, vars)
Beispiel #6
0
def create_event(request):
    vars = get_vars(request)

    if request.method == 'POST':

        # special case...
        if request.POST.get('submit') == 'Add Break':
            b = PlaylistBreak(playlist=vars['playlist'])
            b.put()
            vars['add_break'] = True
            # errors should not display on add break, reset internal hash
            vars['form']._errors = {}

        elif vars['form'].is_valid():
            track = vars['form'].save()
            playlist_event_listeners.create(track)
            return HttpResponseRedirect(reverse('playlists_landing_page'))

    vars['playlist_events'] = get_playlist_history(vars['playlist'])

    return landing_page(request, vars)
 def test_break(self):
     playlist = ChirpBroadcast()
     selector = create_dj()
     
     track = PlaylistTrack(
         selector=selector,
         playlist=playlist,
         freeform_artist_name="The Meters",
         freeform_album_title="Chicken Strut",
         freeform_track_title="Hand Clapping Song"
     )
     track.put()
     time.sleep(0.4)
     
     pl_break = PlaylistBreak(playlist=playlist)
     pl_break.put()
     
     self.assertEqual(
         [type(e) for e in playlist.recent_tracks],
         [PlaylistTrack])
     
     self.assertEqual(
         [type(e) for e in playlist.recent_events],
         [PlaylistBreak, PlaylistTrack])