From 910d95f9b25074d10da0736aa43b4be9f8a16236 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 19 Jun 2018 23:33:16 +0200 Subject: [PATCH] refactor update_cache --- pandora/item/models.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pandora/item/models.py b/pandora/item/models.py index f255500c8..878ae4322 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -1375,6 +1375,10 @@ class Item(models.Model): get_sequences(self.public_id) tasks.load_subtitles.delay(self.public_id) + def update_cache(self, **kwargs): + self.cache = self.get_json() + Item.objects.filter(id=self.id).update(cache=self.cache, **kwargs) + def save_poster(self, data): self.poster.name = self.path('poster.jpg') poster = self.poster.path @@ -1384,10 +1388,8 @@ class Item(models.Model): self.poster_width = self.poster.width self.clear_poster_cache(self.poster.path) if self.cache.get('posterRatio') != self.poster_width / self.poster_height: - self.cache = self.get_json() - Item.objects.filter(id=self.id).update(cache=self.cache, - poster_width=self.poster_width, - poster_height=self.poster_height) + self.update_cache(poster_width=self.poster_width, + poster_height=self.poster_height) def prefered_poster_url(self): if settings.DATA_SERVICE: