fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cite: allow shifting and cites without books.
[wolnelektury.git]
/
apps
/
catalogue
/
models
/
book.py
diff --git
a/apps/catalogue/models/book.py
b/apps/catalogue/models/book.py
index
e6f08a9
..
6a31f4b
100644
(file)
--- a/
apps/catalogue/models/book.py
+++ b/
apps/catalogue/models/book.py
@@
-274,12
+274,14
@@
class Book(models.Model):
cover_changed = old_cover != book.cover_info()
obsolete_children = set(b for b in book.children.all()
if b not in children)
cover_changed = old_cover != book.cover_info()
obsolete_children = set(b for b in book.children.all()
if b not in children)
+ notify_cover_changed = []
for n, child_book in enumerate(children):
for n, child_book in enumerate(children):
+ new_child = child_book.parent != book
child_book.parent = book
child_book.parent_number = n
child_book.save()
child_book.parent = book
child_book.parent_number = n
child_book.save()
- if cover_changed:
-
child_book.parent_cover_changed(
)
+ if
new_child or
cover_changed:
+
notify_cover_changed.append(child_book
)
# Disown unfaithful children and let them cope on their own.
for child in obsolete_children:
child.parent = None
# Disown unfaithful children and let them cope on their own.
for child in obsolete_children:
child.parent = None
@@
-287,7
+289,7
@@
class Book(models.Model):
child.save()
tasks.fix_tree_tags.delay(child)
if old_cover:
child.save()
tasks.fix_tree_tags.delay(child)
if old_cover:
-
child.parent_cover_changed(
)
+
notify_cover_changed.append(child
)
# delete old fragments when overwriting
book.fragments.all().delete()
# delete old fragments when overwriting
book.fragments.all().delete()
@@
-311,6
+313,9
@@
class Book(models.Model):
book.search_index(index_tags=search_index_tags, reuse_index=search_index_reuse)
#index_book.delay(book.id, book_info)
book.search_index(index_tags=search_index_tags, reuse_index=search_index_reuse)
#index_book.delay(book.id, book_info)
+ for child in notify_cover_changed:
+ child.parent_cover_changed()
+
cls.published.send(sender=book)
return book
cls.published.send(sender=book)
return book