X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/357027375ff8867f42ca34bcbfb5a78b5b185fc3..02fb0f76b6b1e69383b8fc61d3aa819d6598f9f8:/src/catalogue/models/source.py?ds=sidebyside diff --git a/src/catalogue/models/source.py b/src/catalogue/models/source.py index 9aff4efec..77b1a677b 100644 --- a/src/catalogue/models/source.py +++ b/src/catalogue/models/source.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # @@ -17,7 +16,7 @@ class Source(models.Model): verbose_name_plural = _('sources') app_label = 'catalogue' - def __unicode__(self): + def __str__(self): return self.netloc def save(self, *args, **kwargs): @@ -26,7 +25,7 @@ class Source(models.Model): str(self.pk) old_self = type(self).objects.get(pk=self) except type(self).DoesNotExist: - old_name = u'' + old_name = '' old_netloc = self.netloc else: old_name = old_self.name @@ -38,8 +37,7 @@ class Source(models.Model): # and invalidate their cached includes. if old_name != self.name or old_netloc != self.netloc: for book in Book.objects.all(): - source = book.extra_info.get('source_url', '') - if self.netloc in source or (old_netloc != self.netloc - and old_netloc in source): - book.flush_includes() + source = book.get_extra_info_json().get('source_url', '') + if self.netloc in source or (old_netloc != self.netloc and old_netloc in source): + book.clear_cache() return ret