add default values to items without imdb

This commit is contained in:
j 2014-02-24 16:54:58 +05:30
parent ab2949f815
commit a1acc6b3aa
2 changed files with 13 additions and 0 deletions

View file

@ -359,6 +359,7 @@
"title": "Mainstream Score", "title": "Mainstream Score",
"type": "float", "type": "float",
"columnWidth": 60, "columnWidth": 60,
"default" 0,
"format": {"type": "ColorPercent", "args": [1, true]}, "format": {"type": "ColorPercent", "args": [1, true]},
"sort": true "sort": true
}, },
@ -367,6 +368,7 @@
"title": "Arthouse Score", "title": "Arthouse Score",
"type": "float", "type": "float",
"columnWidth": 60, "columnWidth": 60,
"default" 0,
"format": {"type": "ColorPercent", "args": [1, true]}, "format": {"type": "ColorPercent", "args": [1, true]},
"sort": true "sort": true
}, },

View file

@ -383,6 +383,17 @@ class Item(models.Model):
if key in self.data: if key in self.data:
del self.data[key] 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): if self.poster and os.path.exists(self.poster.path):
self.poster_height = self.poster.height self.poster_height = self.poster.height
self.poster_width = self.poster.width self.poster_width = self.poster.width