本文整理汇总了Python中playlists.models.PlaylistTrack.freeform_track_title方法的典型用法代码示例。如果您正苦于以下问题:Python PlaylistTrack.freeform_track_title方法的具体用法?Python PlaylistTrack.freeform_track_title怎么用?Python PlaylistTrack.freeform_track_title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类playlists.models.PlaylistTrack
的用法示例。
在下文中一共展示了PlaylistTrack.freeform_track_title方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import freeform_track_title [as 别名]
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
示例2: save
# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import freeform_track_title [as 别名]
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