From a1acc6b3aa8222d644e3bb0f31b4960e2a35501c Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 24 Feb 2014 16:54:58 +0530 Subject: [PATCH] add default values to items without imdb --- pandora/config.0xdb.jsonc | 2 ++ pandora/item/models.py | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/pandora/config.0xdb.jsonc b/pandora/config.0xdb.jsonc index e76d3ce16..c8e8bea8a 100644 --- a/pandora/config.0xdb.jsonc +++ b/pandora/config.0xdb.jsonc @@ -359,6 +359,7 @@ "title": "Mainstream Score", "type": "float", "columnWidth": 60, + "default" 0, "format": {"type": "ColorPercent", "args": [1, true]}, "sort": true }, @@ -367,6 +368,7 @@ "title": "Arthouse Score", "type": "float", "columnWidth": 60, + "default" 0, "format": {"type": "ColorPercent", "args": [1, true]}, "sort": true }, diff --git a/pandora/item/models.py b/pandora/item/models.py index c23e810db..8e2a254d5 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -383,6 +383,17 @@ class Item(models.Model): if key in self.data: del self.data[key] + # update defaults + if settings.USE_IMDB: + defaults = filter(lambda k: 'default' in k, settings.CONFIG['itemKeys']) + for k in defaults: + if len(self.itemId) == 7: + if k['id'] in self.data and self.data[k['id']] == k['default']: + del self.data[k['id']] + else: + if k['id'] not in self.data: + self.data[k['id']] = k['default'] + if self.poster and os.path.exists(self.poster.path): self.poster_height = self.poster.height self.poster_width = self.poster.width