restore composer.json, add mysqli extension
This commit is contained in:
22
core/apps/vendors/migrations/0007_remove_productvariantmodel_image_url_and_more.py
vendored
Normal file
22
core/apps/vendors/migrations/0007_remove_productvariantmodel_image_url_and_more.py
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
# Generated by Django 6.0.4 on 2026-04-13 12:28
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("vendors", "0006_productattributemodel_productvariantmodel"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name="productvariantmodel",
|
||||
name="image_url",
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="productvariantmodel",
|
||||
name="image",
|
||||
field=models.ImageField(blank=True, null=True, upload_to="variants/", verbose_name="image"),
|
||||
),
|
||||
]
|
||||
2
core/apps/vendors/models/product_variant.py
vendored
2
core/apps/vendors/models/product_variant.py
vendored
@@ -14,7 +14,7 @@ class ProductVariantModel(AbstractBaseModel):
|
||||
price = models.DecimalField(verbose_name=_("price"), max_digits=12, decimal_places=2, default=0)
|
||||
sku = models.CharField(verbose_name=_("SKU"), max_length=255, null=True, blank=True)
|
||||
quantity = models.IntegerField(verbose_name=_("quantity"), default=-1)
|
||||
image_url = models.URLField(verbose_name=_("image url"), max_length=1000, null=True, blank=True)
|
||||
image = models.ImageField(verbose_name=_("image"), upload_to="variants/", null=True, blank=True)
|
||||
attribute_data = models.JSONField(verbose_name=_("attribute data"), null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
|
||||
@@ -22,12 +22,24 @@ class ProductVariantSerializer(serializers.ModelSerializer):
|
||||
"price",
|
||||
"sku",
|
||||
"quantity",
|
||||
"image_url",
|
||||
"image",
|
||||
"attribute_data",
|
||||
]
|
||||
|
||||
def to_representation(self, instance):
|
||||
ret = super().to_representation(instance)
|
||||
|
||||
# Absolute URL for variant image
|
||||
request = self.context.get("request")
|
||||
image = ret.get("image")
|
||||
if image and isinstance(image, str) and not image.startswith("http"):
|
||||
if not image.startswith("/resources/"):
|
||||
image = f"/resources/media/{image.lstrip('/')}"
|
||||
if request:
|
||||
ret["image"] = request.build_absolute_uri(image)
|
||||
else:
|
||||
ret["image"] = image
|
||||
|
||||
attr_data = ret.get("attribute_data")
|
||||
|
||||
if attr_data and isinstance(attr_data, list):
|
||||
|
||||
Reference in New Issue
Block a user