Delete release

This commit is contained in:
Ruud
2011-09-11 01:29:49 +02:00
parent cb5fc694ab
commit c0c0628708
3 changed files with 32 additions and 14 deletions
+11 -12
View File
@@ -249,7 +249,8 @@ var ReleaseAction = new Class({
'events': {
'click': function(e){
(e).stop();
self.delete(release);
self.del(release);
this.getParent('.item').destroy();
}
}
})
@@ -259,12 +260,18 @@ var ReleaseAction = new Class({
}
self.movie.slide('in');
},
get: function(release, type){
var self = this;
return (release.info.filter(function(info){
return type == info.identifier
}).pick() || {}).value
},
download: function(release){
var self = this;
p(release)
Api.request('release.download', {
'data': {
'id': release.id
@@ -272,7 +279,7 @@ var ReleaseAction = new Class({
});
},
delete: function(release){
del: function(release){
var self = this;
Api.request('release.delete', {
@@ -281,14 +288,6 @@ var ReleaseAction = new Class({
}
})
},
get: function(release, type){
var self = this;
return (release.info.filter(function(info){
return type == info.identifier
}).pick() || {}).value
}
});
+15
View File
@@ -16,6 +16,7 @@ class Release(Plugin):
addEvent('release.add', self.add)
addApiView('release.download', self.download)
addApiView('release.delete', self.delete)
def add(self, group):
db = get_session()
@@ -77,6 +78,20 @@ class Release(Plugin):
# Check database and update/insert if necessary
return fireEvent('file.add', path = file, part = self.getPartNumber(file), type = self.file_types[type], properties = properties, single = True)
def delete(self):
db = get_session()
id = getParam('id')
rel = db.query(Relea).filter_by(id = id).first()
if rel:
rel.delete()
db.commit()
return jsonified({
'success': True
})
def download(self):
db = get_session()
+6 -2
View File
@@ -6,6 +6,7 @@ from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin
from couchpotato.core.settings.model import Movie, Release, ReleaseInfo
from couchpotato.environment import Env
from sqlalchemy.exc import InterfaceError
import re
import traceback
@@ -85,14 +86,17 @@ class Searcher(Plugin):
for info in nzb:
try:
if not isinstance(nzb[info], (str, unicode)):
continue
rls_info = ReleaseInfo(
identifier = info,
value = nzb[info]
)
rls.info.append(rls_info)
except Exception:
db.commit()
except InterfaceError:
log.debug('Couldn\'t add %s to ReleaseInfo: %s' % (info, traceback.format_exc()))
db.commit()
for nzb in sorted_results: