cancelDownloads

This commit is contained in:
j 2014-05-18 12:44:56 +02:00
parent e4ca454c41
commit 30357763e8
3 changed files with 20 additions and 15 deletions

View file

@ -169,22 +169,23 @@ def download(request):
actions.register(download, cache=False) actions.register(download, cache=False)
@returns_json @returns_json
def cancelDownload(request): def cancelDownloads(request):
response = {} response = {}
data = json.loads(request.form['data']) if 'data' in request.form else {} data = json.loads(request.form['data']) if 'data' in request.form else {}
item = models.Item.get(data['id']) ids = data['ids']
if item: if ids:
item.transferprogress = None for item in models.Item.query.filter(models.Item.id.in_(ids)):
item.transferadded = None item.transferprogress = None
p = state.user() item.transferadded = None
if p in item.users: p = state.user()
item.users.remove(p) if p in item.users:
for l in item.lists.filter_by(user_id=settings.USER_ID): item.users.remove(p)
l.remove(item) for l in item.lists.filter_by(user_id=settings.USER_ID):
item.update() l.remove(item)
item.update()
response = {'status': 'cancelled'} response = {'status': 'cancelled'}
return response return response
actions.register(cancelDownload, cache=False) actions.register(cancelDownloads, cache=False)
@returns_json @returns_json
def scan(request): def scan(request):

View file

@ -99,6 +99,5 @@ def api_cancelPeering(app, user_id, message):
user.info['message'] = message user.info['message'] = message
user.update_peering(False) user.update_peering(False)
trigger_event('peering', user.json()) trigger_event('peering', user.json())
user.peered = False
return True return True
return False return False

View file

@ -65,7 +65,12 @@ oml.ui.transfersDialog = function() {
}) })
.bindEvent({ .bindEvent({
click: function() { click: function() {
// ... var ids = $list.options('selected');
ids && ids.length && oml.api.cancelDownloads({
ids: ids
}, function() {
$list.reloadList(true);
});
} }
}) })
.appendTo($item), .appendTo($item),
@ -122,4 +127,4 @@ oml.ui.transfersDialog = function() {
return that; return that;
}; };