diff --git a/pandora/archive/views.py b/pandora/archive/views.py index 068f83bde..e5aae6124 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -280,6 +280,47 @@ def moveFiles(request): return render_to_json_response(response) actions.register(moveFiles, cache=False) +@login_required_json +def editFiles(request): + ''' + change file / item link + param data { + ids: ids of files + part: + language: + ignore: boolean + } + + return { + status: {'code': int, 'text': string}, + data: { + } + } + ''' + data = json.loads(request.POST['data']) + files = models.File.objects.filter(oshash__in=data['ids']) + response = json_response() + #FIXME: only editable files! + if True: + if 'ignore' in data: + models.Instance.objects.filter(file__in=files).update(ignore=data['ignore']) + files.update(auto=True) + #FIXME: is this to slow to run sync? + for i in Item.objects.filter(files__in=files).distinct(): + i.update_selected() + i.update_wanted() + response = json_response(status=200, text='updated') + updates = {} + for key in ('part', 'language'): + if key in data: + updates[key] = data[key] + if updates: + files.update(**updates) + response = json_response(status=200, text='updated') + else: + response = json_response(status=403, text='permissino denied') + return render_to_json_response(response) +actions.register(editFiles, cache=False) @login_required_json def editFile(request): diff --git a/static/js/pandora/filesView.js b/static/js/pandora/filesView.js index 75314d1a0..e67162cfb 100644 --- a/static/js/pandora/filesView.js +++ b/static/js/pandora/filesView.js @@ -33,15 +33,27 @@ pandora.ui.filesView = function(options, self) { }) .appendTo(self.$toolbar); - self.$moveButton = Ox.Button({ + self.$ignoreButton = Ox.Button({ disabled: 'true', - title: 'Move Selected Files...' + title: 'Ignore Selected Files...' }) .css({ float: 'right', margin: '4px' }) - .appendTo(self.$toolbar); + .appendTo(self.$toolbar) + .bindEvent({ + click: function() { + var data = { + ids: self.selected, + ignore: true + }; + pandora.api.editFiles(data, function(result) { + Ox.Request.clearCache(); + self.$filesList.reloadList(); + }); + } + }); self.$filesList = Ox.TextList({ columns: [ @@ -417,6 +429,9 @@ pandora.ui.filesView = function(options, self) { self.$moveButton.options({ disabled: self.selected.length === 0 }); + self.$ignoreButton.options({ + disabled: self.selected.length === 0 + }); } return that;