create new item if unregistered file gets uploaded

This commit is contained in:
j 2016-08-25 17:13:38 +02:00
parent 181f27b93a
commit 8136a2c2f5

View file

@ -321,14 +321,19 @@ def direct_upload(request):
t = file.extract_stream() t = file.extract_stream()
response['resultUrl'] = t.task_id response['resultUrl'] = t.task_id
except: except:
print('ERROR: rabbitmq is down')
pass pass
return render_to_json_response(response) return render_to_json_response(response)
# init upload # init upload
else: else:
file, created = models.File.objects.get_or_create(oshash=oshash) file, created = models.File.objects.get_or_create(oshash=oshash)
if file.editable(request.user): if file.editable(request.user):
# remove previous uploads if created:
if not created: if not file.item:
file.item = get_item({
'title': oshash
}, user=request.user)
else: # remove previous uploads
file.streams.all().delete() file.streams.all().delete()
file.delete_frames() file.delete_frames()
if file.item.rendered and file.selected: if file.item.rendered and file.selected: