Skip to content

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

Resolve codeclimate issues

IKarbowiak3a93e4a9d6c4
diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.py
index 18687a6cf8..a4dc94c2c3 100644
--- a/saleor/graphql/product/types/products.py
+++ b/saleor/graphql/product/types/products.py
@@ -815,7 +815,7 @@ class Category(CountableDjangoObjectType, MetadataObjectType):
),
prefetch_related=prefetch_products,
)
- # TODO: To remove in #5022
+ # Deprecated. To remove in #5022
url = graphene.String(description="The storefront's URL for the category.")
children = PrefetchingConnectionField(
lambda: Category, description="List of children of the category."
@@ -866,7 +866,7 @@ class Category(CountableDjangoObjectType, MetadataObjectType):
qs = root.children.all()
return gql_optimizer.query(qs, info)
- # TODO: To remove in #5022
+ # Deprecated. To remove in #5022
@staticmethod
def resolve_url(root: models.Category, _info):
return root.get_absolute_url()
diff --git a/saleor/menu/models.py b/saleor/menu/models.py
index 84e76e720b..9b1c9cc876 100644
--- a/saleor/menu/models.py
+++ b/saleor/menu/models.py
@@ -62,9 +62,9 @@ class MenuItem(MPTTModel, SortableModel):
def linked_object(self):
return self.category or self.collection or self.page
- # TODO: in #5022
def get_url(self):
linked_object = self.linked_object
+ # Deprecated. To remove in #5022
return linked_object.get_absolute_url() if linked_object else self.url
def is_public(self):
diff --git a/saleor/menu/utils.py b/saleor/menu/utils.py
index 25c6468a25..797c60e62b 100644
--- a/saleor/menu/utils.py
+++ b/saleor/menu/utils.py
@@ -5,8 +5,8 @@ from ..menu.models import Menu
def get_menu_item_as_dict(menu_item):
data = {}
- # TODO: in #5022
if menu_item.linked_object:
+ # Deprecated. To remove in #5022
data["url"] = menu_item.linked_object.get_absolute_url()
else:
data["url"] = menu_item.url or ""
diff --git a/saleor/order/models.py b/saleor/order/models.py
index e11f718d8a..e9f4f1abe3 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -223,7 +223,9 @@ class Order(ModelWithMetadata):
def __str__(self):
return "#%d" % (self.id,)
- def get_absolute_url(self):
+ # Deprecated. To remove in #5022
+ @staticmethod
+ def get_absolute_url():
return ""
def get_last_payment(self):
diff --git a/saleor/page/models.py b/saleor/page/models.py
index ecbce730bc..a61762c751 100644
--- a/saleor/page/models.py
+++ b/saleor/page/models.py
@@ -35,7 +35,9 @@ class Page(SeoModel, PublishableModel):
def __str__(self):
return self.title
- def get_absolute_url(self):
+ # Deprecated. To remove in #5022
+ @staticmethod
+ def get_absolute_url():
return ""
diff --git a/saleor/product/models.py b/saleor/product/models.py
index f0f1221329..aceb895923 100644
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -66,8 +66,9 @@ class Category(MPTTModel, ModelWithMetadata, SeoModel):
def __str__(self) -> str:
return self.name
- # TODO: in #5022
- def get_absolute_url(self) -> str:
+ # Deprecated. To remove in #5022
+ @staticmethod
+ def get_absolute_url() -> str:
return ""
@@ -335,8 +336,9 @@ class Product(SeoModel, ModelWithMetadata, PublishableModel):
def is_available(self) -> bool:
return self.is_visible and self.is_in_stock()
- # TODO: in #5022
- def get_absolute_url(self) -> str:
+ # Deprecated. To remove in #5022
+ @staticmethod
+ def get_absolute_url() -> str:
return ""
def get_slug(self) -> str:
@@ -501,8 +503,9 @@ class ProductVariant(ModelWithMetadata):
def get_weight(self):
return self.weight or self.product.weight or self.product.product_type.weight
- # TODO: in #5022
- def get_absolute_url(self) -> str:
+ # Deprecated. To remove in #5022
+ @staticmethod
+ def get_absolute_url() -> str:
return ""
def is_shipping_required(self) -> bool:
@@ -938,8 +941,9 @@ class Collection(SeoModel, ModelWithMetadata, PublishableModel):
def __str__(self) -> str:
return self.name
- # TODO: in #5022
- def get_absolute_url(self) -> str:
+ # Deprecated. To remove in #5022
+ @staticmethod
+ def get_absolute_url() -> str:
return ""
diff --git a/saleor/seo/schema/email.py b/saleor/seo/schema/email.py
index a6dd74110b..fb52461199 100644
--- a/saleor/seo/schema/email.py
+++ b/saleor/seo/schema/email.py
@@ -34,7 +34,7 @@ def get_product_data(line: "OrderLine", organization: dict) -> dict:
}
product = line.variant.product
- # TODO: in #5022
+ # Deprecated. To remove in #5022
product_url = build_absolute_uri(product.get_absolute_url())
product_data["itemOffered"]["url"] = product_url
@@ -48,7 +48,7 @@ def get_product_data(line: "OrderLine", organization: dict) -> dict:
def get_order_confirmation_markup(order: "Order") -> str:
"""Generate schema.org markup for order confirmation e-mail message."""
organization = get_organization()
- # TODO: in #5022
+ # Deprecated. To remove in #5022
order_url = build_absolute_uri(order.get_absolute_url())
data = {
"@context": "http://schema.org",
diff --git a/tests/test_menu.py b/tests/test_menu.py
index 0cd4f93ea5..f8a1b48d06 100644
--- a/tests/test_menu.py
+++ b/tests/test_menu.py
@@ -29,7 +29,7 @@ def test_get_menu_item_as_dict_with_translations(menu, collection):
result = get_menu_item_as_dict(item)
assert result == {
"name": "Name",
- # TODO: in #5022
+ # Deprecated. To remove in #5022
"url": collection.get_absolute_url(),
"translations": {"pl": {"name": "Polish Name"}},
}