Merge branch 'master' into broken_gitenberg_ebooks

pull/1/head
eric 2016-05-16 17:06:47 -04:00
commit 312ad30329
1 changed files with 8 additions and 2 deletions

View File

@ -2062,10 +2062,16 @@ class Ebook(models.Model):
def set_free_flag(sender, instance, created, **kwargs): def set_free_flag(sender, instance, created, **kwargs):
if created: if created:
if not instance.edition.work.is_free: if not instance.edition.work.is_free and instance.active:
instance.edition.work.is_free = True instance.edition.work.is_free = True
instance.edition.work.save() instance.edition.work.save()
elif not instance.active and instance.edition.work.is_free==True and instance.edition.work.ebooks().count()==0:
instance.edition.work.is_free = False
instance.edition.work.save()
elif instance.active and instance.edition.work.is_free==False and instance.edition.work.ebooks().count()>0:
instance.edition.work.is_free = True
instance.edition.work.save()
post_save.connect(set_free_flag,sender=Ebook) post_save.connect(set_free_flag,sender=Ebook)
def reset_free_flag(sender, instance, **kwargs): def reset_free_flag(sender, instance, **kwargs):