本文整理汇总了Python中playlists.models.PlaylistTrack.all方法的典型用法代码示例。如果您正苦于以下问题:Python PlaylistTrack.all方法的具体用法?Python PlaylistTrack.all怎么用?Python PlaylistTrack.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类playlists.models.PlaylistTrack
的用法示例。
在下文中一共展示了PlaylistTrack.all方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bootstrap
# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import all [as 别名]
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/")
示例2: clear_data
# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import all [as 别名]
def clear_data():
for pl in Playlist.all():
for track in PlaylistTrack.all().filter('playlist =', pl):
track.delete()
pl.delete()
for ob in PlayCount.all():
ob.delete()
示例3: clear_data
# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import all [as 别名]
def clear_data():
for pl in Playlist.all():
for track in PlaylistTrack.all().filter('playlist =', pl):
track.delete()
pl.delete()
for u in User.all():
u.delete()
示例4: get_json
# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import all [as 别名]
def get_json(self):
playlist_key = chirp_playlist_key()
recent_tracks = list(PlaylistTrack.all().filter("playlist =", playlist_key).order("-established").fetch(6))
return {
"now_playing": self.track_as_data(recent_tracks.pop(0)),
# Last 5 played tracks:
"recently_played": [self.track_as_data(t) for t in recent_tracks],
}
示例5: filter_tracks_by_date_range
# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import all [as 别名]
def filter_tracks_by_date_range(from_date, to_date):
fd = datetime(from_date.year, from_date.month, from_date.day, 0, 0, 0)
td = datetime(to_date.year, to_date.month, to_date.day, 23, 59, 59)
playlist = chirp_playlist_key()
pl = PlaylistTrack.all().filter("playlist =", playlist)
pl = pl.filter("established >=", fd)
pl = pl.filter("established <=", td)
pl = pl.order("-established")
return pl
示例6: test_chirp_playlist_key
# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import all [as 别名]
def test_chirp_playlist_key(self):
playlist_key = chirp_playlist_key()
track = PlaylistTrack(
selector=create_dj(),
playlist=playlist_key,
freeform_artist_name="Stevie Wonder",
freeform_album_title="Talking Book",
freeform_track_title='You Are The Sunshine Of My Life',
freeform_label='Warner Bros.',
)
track.put()
trk = PlaylistTrack.all().filter('playlist =', playlist_key)
self.assertEqual(trk[0].artist_name, 'Stevie Wonder')
playlist_key = chirp_playlist_key() # from cache
trk = PlaylistTrack.all().filter('playlist =', playlist_key)
self.assertEqual(trk[0].artist_name, 'Stevie Wonder')
示例7: get_json
# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import all [as 别名]
def get_json(self):
playlist_key = chirp_playlist_key()
recent_tracks = list(PlaylistTrack.all()
.filter('playlist =', playlist_key)
.order('-established')
.fetch(6))
return {
'now_playing': self.track_as_data(recent_tracks.pop(0)),
# Last 5 played tracks:
'recently_played': [self.track_as_data(t) for t in recent_tracks]
}
示例8: test_delete_link_appears_for_current_user
# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import all [as 别名]
def test_delete_link_appears_for_current_user(self):
resp = self.client.get(reverse('playlists_landing_page'))
assert '[delete]' in resp.content
for track in PlaylistTrack.all():
track.delete()
other_user = User(email="[email protected]")
other_user.roles.append(auth.roles.DJ)
other_user.put()
other_track = PlaylistTrack(
playlist=self.playlist,
selector=other_user,
freeform_artist_name="Peaches",
freeform_track_title="Rock Show")
other_track.put()
resp = self.client.get(reverse('playlists_landing_page'))
assert '[delete]' not in resp.content