Commit b1393cf1 authored by John Red Medrano's avatar John Red Medrano

refactor upload

parent 534df044
......@@ -40,18 +40,16 @@ class MasterAttachmentViewSet(viewsets.ModelViewSet):
@transaction.atomic
def create(self, request, *args, **kwargs):
attachments = []
for instance in self.request.data:
for key in request.data.keys():
for instance in self.request.data.getlist(key):
body = {}
data = MasterAttachment.objects.create(
url=instance,
attch_ref=str(request.data[instance])
)
body = {}
data = MasterAttachment.objects.create(url=instance)
body['id'] = data.id
body['file_name'] = str(request.data[instance])
body['attch_ref'] = instance
attachments.append(body)
file_name = str(data.url).split('/')
body['id'] = data.id
body['file_name'] = instance.name
attachments.append(body)
return Response(
{"results": attachments},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment