forked from rc/aircox
update episode cover
This commit is contained in:
parent
a01513b944
commit
fee668d130
|
@ -86,6 +86,7 @@ class Program(Page):
|
|||
super().__init__(*kargs, **kwargs)
|
||||
if self.slug:
|
||||
self.__initial_path = self.path
|
||||
self.__initial_cover = self.cover
|
||||
|
||||
@classmethod
|
||||
def get_from_path(cl, path):
|
||||
|
@ -133,6 +134,7 @@ class Program(Page):
|
|||
|
||||
super().save(*kargs, **kwargs)
|
||||
|
||||
# TODO: move in signals
|
||||
path_ = getattr(self, '__initial_path', None)
|
||||
if path_ is not None and path_ != self.path and \
|
||||
os.path.exists(path_) and not os.path.exists(self.path):
|
||||
|
|
|
@ -56,6 +56,13 @@ def program_post_save(sender, instance, created, *args, **kwargs):
|
|||
Episode.object.parent(instance).filter(diffusion__isnull=True) \
|
||||
.delete()
|
||||
|
||||
cover_ = getattr(instance, '__initial_cover', None)
|
||||
if cover_ is None and instance.cover is not None:
|
||||
Episode.objects.parent(instance) \
|
||||
.filter(cover__isnull=True) \
|
||||
.update(cover=instance.cover)
|
||||
|
||||
|
||||
|
||||
@receiver(signals.pre_save, sender=Schedule)
|
||||
def schedule_pre_save(sender, instance, *args, **kwargs):
|
||||
|
|
Loading…
Reference in New Issue
Block a user