Logic error with admin requests.
This commit is contained in:
parent
98fa88bd20
commit
11d6b102af
2 changed files with 3 additions and 2 deletions
|
@ -24,12 +24,13 @@ def update_song_plays(sender, instance, created, update_fields, **kwargs):
|
||||||
"""
|
"""
|
||||||
if not created and update_fields:
|
if not created and update_fields:
|
||||||
song = instance.song
|
song = instance.song
|
||||||
|
user = instance.profile.user
|
||||||
if 'played_at' in update_fields:
|
if 'played_at' in update_fields:
|
||||||
song.last_played = instance.played_at
|
song.last_played = instance.played_at
|
||||||
song.num_played = F('num_played') + 1
|
song.num_played = F('num_played') + 1
|
||||||
song.save()
|
song.save()
|
||||||
if 'queued_at' in update_fields:
|
if 'queued_at' in update_fields:
|
||||||
if song.is_song and not instance.profile.user.is_staff:
|
if song.is_song and (not user.is_staff or user.is_dj):
|
||||||
queued = instance.queued_at
|
queued = instance.queued_at
|
||||||
song.next_play = song.get_date_when_requestable(queued)
|
song.next_play = song.get_date_when_requestable(queued)
|
||||||
song.save()
|
song.save()
|
||||||
|
|
|
@ -285,7 +285,7 @@ class Song(Disableable, Publishable, Timestampable, models.Model):
|
||||||
period (or at all)?
|
period (or at all)?
|
||||||
'''
|
'''
|
||||||
if self._is_song() and self._is_available():
|
if self._is_song() and self._is_available():
|
||||||
return self.get_date_when_requestable() <= timezone.now()
|
return self.next_play is None or self.next_play <= timezone.now()
|
||||||
return False
|
return False
|
||||||
_is_playable.boolean = True
|
_is_playable.boolean = True
|
||||||
is_playable = property(_is_playable)
|
is_playable = property(_is_playable)
|
||||||
|
|
Loading…
Reference in a new issue