From ffb512a3046945d6af3a2e2f0d9f5bbdfc8d5a8c Mon Sep 17 00:00:00 2001 From: j Date: Sat, 29 Aug 2020 23:32:57 +0200 Subject: [PATCH] add oshash to changelog, keep upload filename, show direct upload instance --- pandora/archive/models.py | 11 ++++++++++- pandora/archive/views.py | 10 ++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pandora/archive/models.py b/pandora/archive/models.py index 05882c40..620494e9 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -336,7 +336,9 @@ class File(models.Model): def done_cb(): if done: - self.info.update(ox.avinfo(self.data.path)) + info = ox.avinfo(self.data.path) + del info['path'] + self.info.update(info) self.parse_info() # reject invalid uploads if self.info.get('oshash') != self.oshash: @@ -486,6 +488,13 @@ class File(models.Model): data['instances'] = [] if 'path' in data: data['path'] = os.path.basename(data['path']) + if 'instances' in data and 'filename' in self.info and self.data: + data['instances'].append({ + 'ignore': False, + 'path': self.info['filename'], + 'user': f.item.user.username, + 'volume': 'Direct Upload' + }) return data def all_paths(self): diff --git a/pandora/archive/views.py b/pandora/archive/views.py index 848bfc7e..fd026c1f 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -195,7 +195,9 @@ def addMedia(request, data): response['data']['item'] = f.item.public_id response['data']['itemUrl'] = request.build_absolute_uri('/%s' % f.item.public_id) if not f.available: - add_changelog(request, data, f.item.public_id) + changelog_data = data.copy() + changelog_data['oshash'] = oshash + add_changelog(request, changelog_data, f.item.public_id) else: if 'item' in data: i = Item.objects.get(public_id=data['item']) @@ -220,11 +222,15 @@ def addMedia(request, data): if 'info' in data and data['info'] and isinstance(data['info'], dict): f.info = data['info'] f.info['extension'] = extension + if 'filename' in data: + f.info['filename'] = data['filename'] f.parse_info() f.save() response['data']['item'] = i.public_id response['data']['itemUrl'] = request.build_absolute_uri('/%s' % i.public_id) - add_changelog(request, data, i.public_id) + changelog_data = data.copy() + changelog_data['oshash'] = oshash + add_changelog(request, changelog_data, i.public_id) return render_to_json_response(response) actions.register(addMedia, cache=False)