add oshash to changelog, keep upload filename, show direct upload instance
This commit is contained in:
parent
800725d54c
commit
ffb512a304
2 changed files with 18 additions and 3 deletions
|
@ -336,7 +336,9 @@ class File(models.Model):
|
||||||
|
|
||||||
def done_cb():
|
def done_cb():
|
||||||
if done:
|
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()
|
self.parse_info()
|
||||||
# reject invalid uploads
|
# reject invalid uploads
|
||||||
if self.info.get('oshash') != self.oshash:
|
if self.info.get('oshash') != self.oshash:
|
||||||
|
@ -486,6 +488,13 @@ class File(models.Model):
|
||||||
data['instances'] = []
|
data['instances'] = []
|
||||||
if 'path' in data:
|
if 'path' in data:
|
||||||
data['path'] = os.path.basename(data['path'])
|
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
|
return data
|
||||||
|
|
||||||
def all_paths(self):
|
def all_paths(self):
|
||||||
|
|
|
@ -195,7 +195,9 @@ def addMedia(request, data):
|
||||||
response['data']['item'] = f.item.public_id
|
response['data']['item'] = f.item.public_id
|
||||||
response['data']['itemUrl'] = request.build_absolute_uri('/%s' % f.item.public_id)
|
response['data']['itemUrl'] = request.build_absolute_uri('/%s' % f.item.public_id)
|
||||||
if not f.available:
|
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:
|
else:
|
||||||
if 'item' in data:
|
if 'item' in data:
|
||||||
i = Item.objects.get(public_id=data['item'])
|
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):
|
if 'info' in data and data['info'] and isinstance(data['info'], dict):
|
||||||
f.info = data['info']
|
f.info = data['info']
|
||||||
f.info['extension'] = extension
|
f.info['extension'] = extension
|
||||||
|
if 'filename' in data:
|
||||||
|
f.info['filename'] = data['filename']
|
||||||
f.parse_info()
|
f.parse_info()
|
||||||
f.save()
|
f.save()
|
||||||
response['data']['item'] = i.public_id
|
response['data']['item'] = i.public_id
|
||||||
response['data']['itemUrl'] = request.build_absolute_uri('/%s' % 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)
|
return render_to_json_response(response)
|
||||||
actions.register(addMedia, cache=False)
|
actions.register(addMedia, cache=False)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue