From a8d8cb8f10a9f6459d971c9e9a3d2c4f0ba06179 Mon Sep 17 00:00:00 2001 From: Ruud Date: Wed, 25 Jan 2012 14:17:19 +0100 Subject: [PATCH] Get default profile --- couchpotato/core/plugins/profile/main.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/couchpotato/core/plugins/profile/main.py b/couchpotato/core/plugins/profile/main.py index f34849b2..54213e7e 100644 --- a/couchpotato/core/plugins/profile/main.py +++ b/couchpotato/core/plugins/profile/main.py @@ -12,8 +12,11 @@ log = CPLog(__name__) class ProfilePlugin(Plugin): + to_dict = {'types': {}} + def __init__(self): addEvent('profile.all', self.all) + addEvent('profile.default', self.default) addApiView('profile.save', self.save) addApiView('profile.save_order', self.saveOrder) @@ -28,7 +31,7 @@ class ProfilePlugin(Plugin): temp = [] for profile in profiles: - temp.append(profile.to_dict(deep = {'types': {}})) + temp.append(profile.to_dict(self.to_dict)) return temp @@ -64,13 +67,20 @@ class ProfilePlugin(Plugin): db.commit() - profile_dict = p.to_dict(deep = {'types': {}}) + profile_dict = p.to_dict(self.to_dict) return jsonified({ 'success': True, 'profile': profile_dict }) + def default(self): + + db = get_session() + default = db.query(Profile).first() + + return default.to_dict(self.to_dict) + def saveOrder(self): params = getParams()