From 627314dbe1f23355eaac8c794f85c9ef95b7075c Mon Sep 17 00:00:00 2001 From: Ruud Date: Fri, 10 Aug 2012 20:29:42 +0200 Subject: [PATCH] Change release info API structure --- couchpotato/core/settings/model.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/couchpotato/core/settings/model.py b/couchpotato/core/settings/model.py index 553c0357..2ecb48ae 100644 --- a/couchpotato/core/settings/model.py +++ b/couchpotato/core/settings/model.py @@ -103,6 +103,22 @@ class Release(Entity): files = ManyToMany('File', cascade = 'all, delete-orphan', single_parent = True) info = OneToMany('ReleaseInfo', cascade = 'all, delete-orphan') + def to_dict(self, deep = {}, exclude = []): + orig_dict = super(Release, self).to_dict(deep = deep, exclude = exclude) + + new_info = {} + for info in orig_dict.get('info', []): + + value = info['value'] + try: value = int(info['value']) + except: pass + + new_info[info['identifier']] = value + + orig_dict['info'] = new_info + + return orig_dict + class ReleaseInfo(Entity): """Properties that can be bound to a file for off-line usage"""