html/text item description

This commit is contained in:
j 2014-01-16 13:11:45 +00:00
parent 6eeb867f80
commit a672ddf1ec

View file

@ -617,11 +617,50 @@ class Item(models.Model):
return i return i
def get_item_description(self): def get_item_description(self):
if settings.USE_IMDB: return ox.strip_tags(
info = tuple([self.data.get(k, 0) for k in ['hue', 'saturation', 'lightness']]) self.get_item_description_html().replace(
description = 'Hue: %.3f, Saturation: %.3f, Lightness: %.3f' % info '</div><div style="margin-top: 8px; text-align: justify">', '; '
else: )
description = ox.strip_tags(self.get('summary', '')) )
def get_item_description_html(self):
description = ''
data = self.get_json()
info = []
for key in [
'director', 'writer', 'producer',
'cinematographer', 'editor', 'actor'
]:
value = data.get(key, [])
if value:
info.append('<b>%s:</b> %s' % (
'Cast' if key == 'actor' else key.capitalize(),
', '.join(value)
))
if info:
description += '<div style="margin-top: 8px; text-align: justify">%s</div>' % '; '.join(info)
info = []
for key in [
'duration', 'aspectratio',
'hue', 'saturation', 'lightness',
'volume', 'cutsperminute'
]:
value = data.get(key, 0)
if value:
info.append('<b>%s:</b> %s' % (
'Aspect Ratio' if key == 'aspectratio'
else 'Cuts per Minute' if key == 'cutsperminute'
else key.capitalize(),
ox.format_duration(value * 1000 if value else 0, milliseconds=False) if key == 'duration'
else '%.3f:1' % value if key == 'aspectratio'
else '%.3f' % value
))
if info:
description += '<div style="margin-top: 8px; text-align: justify">%s</div>' % '; '.join(info)
if not settings.USE_IMDB:
value = data.get('summary', '')
if value:
description += '<div style="margin-top: 8px; text-align: justify"><b style="display: none">Summary:</b> %s</div>' % value
return description return description
def oxdb_id(self): def oxdb_id(self):