Get default profile
This commit is contained in:
1 parent
0013c612fb
commit
a8d8cb8f10
1 file changed
+12
-2
@@ -12,8 +12,11 @@ log = CPLog(__name__)
|
|||||||
|
|
||||||
class ProfilePlugin(Plugin):
|
class ProfilePlugin(Plugin):
|
||||||
|
|
||||||
|
to_dict = {'types': {}}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
addEvent('profile.all', self.all)
|
addEvent('profile.all', self.all)
|
||||||
|
addEvent('profile.default', self.default)
|
||||||
|
|
||||||
addApiView('profile.save', self.save)
|
addApiView('profile.save', self.save)
|
||||||
addApiView('profile.save_order', self.saveOrder)
|
addApiView('profile.save_order', self.saveOrder)
|
||||||
@@ -28,7 +31,7 @@ class ProfilePlugin(Plugin):
|
|||||||
|
|
||||||
temp = []
|
temp = []
|
||||||
for profile in profiles:
|
for profile in profiles:
|
||||||
temp.append(profile.to_dict(deep = {'types': {}}))
|
temp.append(profile.to_dict(self.to_dict))
|
||||||
|
|
||||||
return temp
|
return temp
|
||||||
|
|
||||||
@@ -64,13 +67,20 @@ class ProfilePlugin(Plugin):
|
|||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
profile_dict = p.to_dict(deep = {'types': {}})
|
profile_dict = p.to_dict(self.to_dict)
|
||||||
|
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True,
|
'success': True,
|
||||||
'profile': profile_dict
|
'profile': profile_dict
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def default(self):
|
||||||
|
|
||||||
|
db = get_session()
|
||||||
|
default = db.query(Profile).first()
|
||||||
|
|
||||||
|
return default.to_dict(self.to_dict)
|
||||||
|
|
||||||
def saveOrder(self):
|
def saveOrder(self):
|
||||||
|
|
||||||
params = getParams()
|
params = getParams()
|
||||||
|
|||||||
Reference in new issue
Block a user