Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Adjust minimum validators

Patrick Emmanueld44af7954da1
diff --git a/saleor/checkout/migrations/0014_auto_20180920_1043.py b/saleor/checkout/migrations/0014_auto_20180920_1043.py
new file mode 100644
index 0000000000..6c588d1102
--- /dev/null
+++ b/saleor/checkout/migrations/0014_auto_20180920_1043.py
@@ -0,0 +1,19 @@
+# Generated by Django 2.0.8 on 2018-09-20 15:43
+
+import django.core.validators
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('checkout', '0013_auto_20180913_0841'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='cartline',
+ name='quantity',
+ field=models.PositiveIntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(999)]),
+ ),
+ ]
diff --git a/saleor/checkout/models.py b/saleor/checkout/models.py
index 58da266254..d2739ca79e 100644
--- a/saleor/checkout/models.py
+++ b/saleor/checkout/models.py
@@ -122,7 +122,7 @@ class CartLine(models.Model):
variant = models.ForeignKey(
'product.ProductVariant', related_name='+', on_delete=models.CASCADE)
quantity = models.PositiveIntegerField(
- validators=[MinValueValidator(0), MaxValueValidator(999)])
+ validators=[MinValueValidator(1), MaxValueValidator(999)])
data = JSONField(blank=True, default=dict)
class Meta:
diff --git a/saleor/order/migrations/0061_auto_20180920_1043.py b/saleor/order/migrations/0061_auto_20180920_1043.py
new file mode 100644
index 0000000000..cd488feca3
--- /dev/null
+++ b/saleor/order/migrations/0061_auto_20180920_1043.py
@@ -0,0 +1,24 @@
+# Generated by Django 2.0.8 on 2018-09-20 15:43
+
+import django.core.validators
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('order', '0060_auto_20180919_0731'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='fulfillmentline',
+ name='quantity',
+ field=models.IntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(999)]),
+ ),
+ migrations.AlterField(
+ model_name='orderline',
+ name='quantity',
+ field=models.IntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(999)]),
+ ),
+ ]
diff --git a/saleor/order/models.py b/saleor/order/models.py
index ae53089ab7..b299a67a7a 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -205,7 +205,7 @@ class OrderLine(models.Model):
product_sku = models.CharField(max_length=32)
is_shipping_required = models.BooleanField()
quantity = models.IntegerField(
- validators=[MinValueValidator(0), MaxValueValidator(999)])
+ validators=[MinValueValidator(1), MaxValueValidator(999)])
quantity_fulfilled = models.IntegerField(
validators=[MinValueValidator(0), MaxValueValidator(999)], default=0)
unit_price_net = MoneyField(
@@ -275,7 +275,7 @@ class FulfillmentLine(models.Model):
fulfillment = models.ForeignKey(
Fulfillment, related_name='lines', on_delete=models.CASCADE)
quantity = models.IntegerField(
- validators=[MinValueValidator(0), MaxValueValidator(999)])
+ validators=[MinValueValidator(1), MaxValueValidator(999)])
class Payment(BasePayment):