X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/2ca0264b141985f70fe1876b10fcb3539c598967..f358d7768f7f0c73358b712e0e37c100843091d4:/apps/catalogue/models.py?ds=sidebyside diff --git a/apps/catalogue/models.py b/apps/catalogue/models.py index b6586763b..133440b3b 100644 --- a/apps/catalogue/models.py +++ b/apps/catalogue/models.py @@ -202,7 +202,8 @@ class Book(models.Model): short_text = '' if (len(MarkupString(text)) > 240): short_text = unicode(MarkupString(text)[:160]) - new_fragment = Fragment(text=text, short_text=short_text, anchor=fragment.id, book=book) + new_fragment, created = Fragment.objects.get_or_create(anchor=fragment.id, book=book, + defaults={'text': text, 'short_text': short_text}) try: theme_names = [s.strip() for s in fragment.themes.split(',')]