From 3417eb9281fa14bcc1bd311308084a3ee52a4f95 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 27 Jan 2012 23:22:54 +0100 Subject: [PATCH] width/height --- pandora/item/models.py | 11 ++++++++--- pandora/monkey_patch/models.py | 5 +++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pandora/item/models.py b/pandora/item/models.py index 2625a530..54b1884d 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -718,9 +718,14 @@ class Item(models.Model): if videos.count() > 0: s.duration = sum([v.duration for v in videos]) v = videos[0] - s.resolution = v.width * v.height - s.width = v.width - s.height = v.height + if v.is_audio: + s.resolution = None + s.width = None + s.height = None + else: + s.resolution = v.width * v.height + s.width = v.width + s.height = v.height if not s.aspectratio: s.aspectratio = float(utils.parse_decimal(v.display_aspect_ratio)) s.pixels = sum([v.pixels for v in videos]) diff --git a/pandora/monkey_patch/models.py b/pandora/monkey_patch/models.py index 47416fd4..986ac9d9 100644 --- a/pandora/monkey_patch/models.py +++ b/pandora/monkey_patch/models.py @@ -13,12 +13,13 @@ NEW_LENGTH = { def monkey_patch_username(): for field in NEW_LENGTH: - f= User._meta.get_field(field) + f = User._meta.get_field(field) f.max_length = NEW_LENGTH[field] for v in f.validators: if isinstance(v, MaxLengthValidator): v.limit_value = NEW_LENGTH[field] - f= Group._meta.get_field('name') + + f = Group._meta.get_field('name') f.max_length = 255 for v in f.validators: if isinstance(v, MaxLengthValidator):