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

added new field attch_ref to allow upload same file name on attachment

parent 6bfa644b
...@@ -40,14 +40,17 @@ class MasterAttachmentViewSet(viewsets.ModelViewSet): ...@@ -40,14 +40,17 @@ class MasterAttachmentViewSet(viewsets.ModelViewSet):
@transaction.atomic @transaction.atomic
def create(self, request, *args, **kwargs): def create(self, request, *args, **kwargs):
attachments = [] attachments = []
for instance in self.request.data.getlist('url'): for instance in self.request.data:
body = {} body = {}
data = MasterAttachment.objects.create(url=instance) data = MasterAttachment.objects.create(
url=instance,
attch_ref=str(request.data[instance])
)
file_name = str(data.url).split('/')
body['id'] = data.id body['id'] = data.id
body['file_name'] = instance.name body['file_name'] = str(request.data[instance])
body['attch_ref'] = instance
attachments.append(body) attachments.append(body)
return Response( return Response(
......
# Generated by Django 2.2 on 2019-10-15 18:29
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('entities', '0019_auto_20191015_1721'),
]
operations = [
migrations.AddField(
model_name='masterattachment',
name='attch_ref',
field=models.TextField(default=1),
preserve_default=False,
),
]
...@@ -448,6 +448,7 @@ class MasterAttachment(models.Model): ...@@ -448,6 +448,7 @@ class MasterAttachment(models.Model):
upload_to='uploads/', upload_to='uploads/',
blank=True, blank=True,
null=True) null=True)
attch_ref = models.TextField()
class Meta: class Meta:
db_table = 'master_attachments' db_table = 'master_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