Skip to content

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

Add url validation for fulfillment tracking number

Przemysław Łada3284672f42b5
diff --git a/saleor/order/models.py b/saleor/order/models.py
index 5c5caa96b4..0f7420c76f 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -1,5 +1,6 @@
from decimal import Decimal
from operator import attrgetter
+from re import match
from typing import Optional
from uuid import uuid4
@@ -458,6 +459,10 @@ class Fulfillment(ModelWithMetadata):
def get_total_quantity(self):
return sum([line.quantity for line in self])
+ @property
+ def is_tracking_number_url(self):
+ return bool(match(r"^[-\w]+://", self.tracking_number))
+
class FulfillmentLine(models.Model):
order_line = models.ForeignKey(