Default profiles

Profile JS fixes
This commit is contained in:
Ruud
2011-09-07 00:11:19 +02:00
parent 1c8f1ae98d
commit 4de1df79ad
8 changed files with 64 additions and 10 deletions
+44
View File
@@ -1,6 +1,7 @@
from couchpotato import get_session
from couchpotato.api import addApiView
from couchpotato.core.event import addEvent, fireEvent
from couchpotato.core.helpers.encoding import toUnicode
from couchpotato.core.helpers.request import jsonified, getParams, getParam
from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin
@@ -17,6 +18,8 @@ class ProfilePlugin(Plugin):
addApiView('profile.save', self.save)
addApiView('profile.delete', self.delete)
addEvent('app.initialize', self.fill)
def all(self):
db = get_session()
@@ -90,3 +93,44 @@ class ProfilePlugin(Plugin):
'success': success,
'message': message
})
def fill(self):
db = get_session();
profiles = [{
'label': 'Best',
'qualities': ['720p', '1080p', 'brrip', 'dvdrip']
}, {
'label': 'HD',
'qualities': ['720p', '1080p']
}]
# Create default quality profile
order = 99
for profile in profiles:
log.info('Creating default profile: %s' % profile.get('label'))
p = Profile(
label = toUnicode(profile.get('label')),
order = order
)
db.add(p)
quality_order = 0
for quality in profile.get('qualities'):
quality = fireEvent('quality.single', identifier = quality, single = True)
profile_type = ProfileType(
quality_id = quality.get('id'),
profile = p,
finish = True,
wait_for = 0,
order = quality_order
)
p.types.append(profile_type)
db.commit()
quality_order += 1
order += 1
return True
@@ -18,6 +18,10 @@
padding: 14px;
background-position: center;
}
.profile .qualities {
min-height: 80px;
}
.profile .formHint {
width: 250px !important;
@@ -49,7 +49,7 @@ var Profile = new Class({
new Element('label', {'text': 'Search for'}),
self.type_container = new Element('ol.types'),
new Element('div.formHint', {
'html': "Search these qualities, from top to bottom. <br />Use the checkbox, if I don't have to search any further."
'html': "Search these qualities (2 minimum), from top to bottom. Use the checkbox, to stop searching after it found this quality."
})
)
);
@@ -68,6 +68,8 @@ var Profile = new Class({
if(self.save_timer) clearTimeout(self.save_timer);
self.save_timer = (function(){
self.addType();
var data = self.getData();
if(data.types.length < 2) return;
@@ -84,8 +86,6 @@ var Profile = new Class({
}
});
self.addType();
}).delay(delay, self)
},