|
@@ -68,7 +68,7 @@ class ProductViewSet(CustomModelViewSet):
|
|
|
try:
|
|
|
with transaction.atomic():
|
|
|
instance = self.get_object()
|
|
|
- upload = Upload.objects._addnew(banner_img, 'commodity_image')
|
|
|
+ upload = Upload.objects._addnew(banner_img, 'commodity_image/')
|
|
|
if upload:
|
|
|
if instance.main_image_id:
|
|
|
img = Upload.objects.filter(id=instance.main_image_id).first()
|
|
@@ -91,7 +91,7 @@ class ProductViewSet(CustomModelViewSet):
|
|
|
for i in range(10):
|
|
|
file = request.data.get('file{}'.format(i))
|
|
|
if file:
|
|
|
- upload = Upload.objects._addnew(file, 'commodity_image')
|
|
|
+ upload = Upload.objects._addnew(file, 'commodity_image/')
|
|
|
ProductImages.objects.create(product_id=instance.id,
|
|
|
image_id=upload.id)
|
|
|
|
|
@@ -193,7 +193,8 @@ class OrderUploadView(CreateAPIView):
|
|
|
for image in images:
|
|
|
image.image.del_images()
|
|
|
image.delete()
|
|
|
- upload = Upload.objects._addnew(file, 'user_image')
|
|
|
+ path = instance.get_path(type)
|
|
|
+ upload = Upload.objects._addnew(file, path)
|
|
|
if upload:
|
|
|
OrderImages.objects.create(order=instance, type=type, image=upload, )
|
|
|
edit = OrderDetailEdit.objects.filter(type=OrderDetailEdit.ONE, order=instance,
|
|
@@ -439,7 +440,8 @@ class OrderViewSet(CustomModelViewSet):
|
|
|
for image in images:
|
|
|
image.image.del_images()
|
|
|
image.delete()
|
|
|
- upload = Upload.objects._addnew(file, 'user_image')
|
|
|
+ path = instance.get_path(type)
|
|
|
+ upload = Upload.objects._addnew(file, path)
|
|
|
if upload:
|
|
|
OrderImages.objects.create(order=instance, type=type, image=upload, )
|
|
|
edit = OrderDetailEdit.objects.filter(type=OrderDetailEdit.ONE, order=instance,
|