Commit 7a3935d5 authored by fred's avatar fred
Browse files

turn episode main_sound method into a property

parent dd04fd98
......@@ -185,11 +185,24 @@ class Episode(models.Model):
def has_sound(self):
return (self.soundfile_set.count() > 0)
def main_sound(self, podcastable=True):
_main_sound = False
@property
def main_sound(self):
if self._main_sound is not False:
return self._main_sound
t = self.soundfile_set.exclude(podcastable=False).exclude(fragment=True)
if t:
return t[0]
return None
self._main_sound = t[0]
else:
self._main_sound = None
return self._main_sound
@main_sound.setter
def main_sound(self, value):
self._main_sound = value
class Diffusion(models.Model):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment