Exemple #1
0
    def save(self):
        if not self.current_user:
            raise ValueError("Cannot save() without a current_user")

        playlist_track = PlaylistTrack(
                            playlist=self.playlist,
                            selector=self.current_user)

        if self.cleaned_data['artist_key']:
            playlist_track.artist = Artist.get(self.cleaned_data['artist_key'])
        else:
            playlist_track.freeform_artist_name = self.cleaned_data['artist']
        if self.cleaned_data['song_key']:
            playlist_track.track = Track.get(self.cleaned_data['song_key'])
        else:
            playlist_track.freeform_track_title = self.cleaned_data['song']
        if self.cleaned_data['album_key']:
            playlist_track.album = Album.get(self.cleaned_data['album_key'])
        elif self.cleaned_data['album']:
            playlist_track.freeform_album_title = self.cleaned_data['album']
        if self.cleaned_data['label']:
            playlist_track.freeform_label = self.cleaned_data['label']
        if self.cleaned_data['song_notes']:
            playlist_track.notes = self.cleaned_data['song_notes']
        if self.cleaned_data['is_heavy_rotation']:
            playlist_track.categories.append('heavy_rotation')
        if self.cleaned_data['is_light_rotation']:
            playlist_track.categories.append('light_rotation')
        if self.cleaned_data['is_local_current']:
            playlist_track.categories.append('local_current')
        if self.cleaned_data['is_local_classic']:
            playlist_track.categories.append('local_classic')
        AutoRetry(playlist_track).save()

        return playlist_track
Exemple #2
0
    def save(self):
        if not self.current_user:
            raise ValueError("Cannot save() without a current_user")

        playlist_track = PlaylistTrack(playlist=self.playlist,
                                       selector=self.current_user)

        if self.cleaned_data['artist_key']:
            playlist_track.artist = Artist.get(self.cleaned_data['artist_key'])
        else:
            playlist_track.freeform_artist_name = self.cleaned_data['artist']
        if self.cleaned_data['song_key']:
            playlist_track.track = Track.get(self.cleaned_data['song_key'])
        else:
            playlist_track.freeform_track_title = self.cleaned_data['song']
        if self.cleaned_data['album_key']:
            playlist_track.album = Album.get(self.cleaned_data['album_key'])
        elif self.cleaned_data['album']:
            playlist_track.freeform_album_title = self.cleaned_data['album']
        if self.cleaned_data['label']:
            playlist_track.freeform_label = self.cleaned_data['label']
        if self.cleaned_data['song_notes']:
            playlist_track.notes = self.cleaned_data['song_notes']
        if self.cleaned_data['is_heavy_rotation']:
            playlist_track.categories.append('heavy_rotation')
        if self.cleaned_data['is_light_rotation']:
            playlist_track.categories.append('light_rotation')
        if self.cleaned_data['is_local_current']:
            playlist_track.categories.append('local_current')
        if self.cleaned_data['is_local_classic']:
            playlist_track.categories.append('local_classic')
        AutoRetry(playlist_track).save()

        return playlist_track
    def save(self):
        if not self.current_user:
            raise ValueError("Cannot save() without a current_user")

        playlist_track = PlaylistTrack(
                            playlist=self.playlist,
                            selector=self.current_user)

        if self.cleaned_data['artist_key']:
            playlist_track.artist = Artist.get(self.cleaned_data['artist_key'])
        else:
            playlist_track.freeform_artist_name = self.cleaned_data['artist']
        if self.cleaned_data['song_key']:
            playlist_track.track = Track.get(self.cleaned_data['song_key'])
        else:
            playlist_track.freeform_track_title = self.cleaned_data['song']
        if self.cleaned_data['album_key']:
            playlist_track.album = Album.get(self.cleaned_data['album_key'])
        elif self.cleaned_data['album']:
            playlist_track.freeform_album_title = self.cleaned_data['album']
        if self.cleaned_data['label']:
            playlist_track.freeform_label = self.cleaned_data['label']
        if self.cleaned_data['song_notes']:
            playlist_track.notes = self.cleaned_data['song_notes']
        if self.cleaned_data['is_heavy_rotation']:
            playlist_track.categories.append('heavy_rotation')
        if self.cleaned_data['is_light_rotation']:
            playlist_track.categories.append('light_rotation')
        if self.cleaned_data['is_local_current']:
            playlist_track.categories.append('local_current')
        if self.cleaned_data['is_local_classic']:
            playlist_track.categories.append('local_classic')
        AutoRetry(playlist_track).save()

        trk = playlist_track
        memcache.set('playlist.last_track', {
            'artist_name': trk.artist_name,
            'track_title': trk.track_title,
            'album_title_display': trk.album_title_display,
            'label_display': trk.label_display,
            'notes': trk.notes,
            'key': str(trk.key()),
            'categories': list(trk.categories),
            'selector_key': str(trk.selector.key()),
            'established_display': trk.established.timetuple()[0:7]
        }, 30)

        return playlist_track
Exemple #4
0
    def save(self):
        if not self.current_user:
            raise ValueError("Cannot save() without a current_user")

        playlist_track = PlaylistTrack(playlist=self.playlist,
                                       selector=self.current_user)

        if self.cleaned_data['artist_key']:
            playlist_track.artist = Artist.get(self.cleaned_data['artist_key'])
        else:
            playlist_track.freeform_artist_name = self.cleaned_data['artist']
        if self.cleaned_data['song_key']:
            playlist_track.track = Track.get(self.cleaned_data['song_key'])
        else:
            playlist_track.freeform_track_title = self.cleaned_data['song']
        if self.cleaned_data['album_key']:
            playlist_track.album = Album.get(self.cleaned_data['album_key'])
        elif self.cleaned_data['album']:
            playlist_track.freeform_album_title = self.cleaned_data['album']
        if self.cleaned_data['label']:
            playlist_track.freeform_label = self.cleaned_data['label']
        if self.cleaned_data['song_notes']:
            playlist_track.notes = self.cleaned_data['song_notes']
        if self.cleaned_data['is_heavy_rotation']:
            playlist_track.categories.append('heavy_rotation')
        if self.cleaned_data['is_light_rotation']:
            playlist_track.categories.append('light_rotation')
        if self.cleaned_data['is_local_current']:
            playlist_track.categories.append('local_current')
        if self.cleaned_data['is_local_classic']:
            playlist_track.categories.append('local_classic')
        AutoRetry(playlist_track).save()

        trk = playlist_track
        memcache.set(
            'playlist.last_track', {
                'artist_name': trk.artist_name,
                'track_title': trk.track_title,
                'album_title_display': trk.album_title_display,
                'label_display': trk.label_display,
                'notes': trk.notes,
                'key': str(trk.key()),
                'categories': list(trk.categories),
                'selector_key': str(trk.selector.key()),
                'established_display': trk.established.timetuple()[0:7]
            }, 30)

        return playlist_track