Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Drop get_absolute_url methods
IKarbowiak2515752c4510
diff --git a/saleor/data_feeds/google_merchant.py b/saleor/data_feeds/google_merchant.pyindex 026d813da4..151c0142d2 100644--- a/saleor/data_feeds/google_merchant.py+++ b/saleor/data_feeds/google_merchant.py@@ -71,8 +71,10 @@ def item_guid(item: ProductVariant):return item.sku+# It should returns url to item, but right now+# there is no way to get product_variant urldef item_link(item: ProductVariant, current_site):- return add_domain(current_site.domain, item.get_absolute_url(), not settings.DEBUG)+ return add_domain(current_site.domain, "", not settings.DEBUG)def item_title(item: ProductVariant):diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.pyindex b9d784e843..0bed093304 100644--- a/saleor/graphql/product/types/products.py+++ b/saleor/graphql/product/types/products.py@@ -377,7 +377,9 @@ class ProductVariant(CountableDjangoObjectType):@key(fields="id")class Product(CountableDjangoObjectType):url = graphene.String(- description="The storefront URL for the product.", required=True+ description="The storefront URL for the product.",+ required=True,+ deprecation_reason="DEPRECATED: Will be removed in Saleor 2.11.",)thumbnail = graphene.Field(Image,@@ -469,7 +471,7 @@ class Product(CountableDjangoObjectType):@staticmethoddef resolve_url(root: models.Product, *_args):- return root.get_absolute_url()+ return ""@staticmethod@gql_optimizer.resolver_hints(@@ -754,8 +756,10 @@ class Category(CountableDjangoObjectType):products = PrefetchingConnectionField(Product, description="List of products in the category.")- # Deprecated. To remove in #5022- url = graphene.String(description="The storefront's URL for the category.")+ url = graphene.String(+ description="The storefront's URL for the category.",+ deprecation_reason="DEPRECATED: Will be removed in Saleor 2.11.",+ )children = PrefetchingConnectionField(lambda: Category, description="List of children of the category.")@@ -805,10 +809,9 @@ class Category(CountableDjangoObjectType):qs = root.children.all()return gql_optimizer.query(qs, info)- # Deprecated. To remove in #5022@staticmethoddef resolve_url(root: models.Category, _info):- return root.get_absolute_url()+ return ""@staticmethoddef resolve_products(root: models.Category, info, **_kwargs):diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 9cec657587..6e49ea5a40 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -515,7 +515,7 @@ type Category implements Node, ObjectWithMetadata {meta: [MetaStore]! @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.11. use the `metadata` field instead. ")ancestors(before: String, after: String, first: Int, last: Int): CategoryCountableConnectionproducts(before: String, after: String, first: Int, last: Int): ProductCountableConnection- url: String+ url: String @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.11.")children(before: String, after: String, first: Int, last: Int): CategoryCountableConnectionbackgroundImage(size: Int): Imagetranslation(languageCode: LanguageCodeEnum!): CategoryTranslation@@ -3141,7 +3141,7 @@ type Product implements Node, ObjectWithMetadata {metadata: [MetadataItem]!privateMeta: [MetaStore]! @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.11. use the `privetaMetadata` field instead. ")meta: [MetaStore]! @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.11. use the `metadata` field instead. ")- url: String!+ url: String! @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.11.")thumbnail(size: Int): Imagepricing: ProductPricingInfoisAvailable: Booleandiff --git a/saleor/menu/models.py b/saleor/menu/models.pyindex 6af8fc2320..4f92c17d95 100644--- a/saleor/menu/models.py+++ b/saleor/menu/models.py@@ -57,11 +57,6 @@ class MenuItem(MPTTModel, SortableModel):def linked_object(self):return self.category or self.collection or self.page- 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):return not self.linked_object or getattr(self.linked_object, "is_published", Truediff --git a/saleor/menu/utils.py b/saleor/menu/utils.pyindex 797c60e62b..7efe42217f 100644--- a/saleor/menu/utils.py+++ b/saleor/menu/utils.py@@ -5,11 +5,7 @@ from ..menu.models import Menudef get_menu_item_as_dict(menu_item):data = {}- 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 ""+ data["url"] = menu_item.url or ""data["name"] = menu_item.namedata["translations"] = {translated.language_code: {"name": translated.name}diff --git a/saleor/order/models.py b/saleor/order/models.pyindex d0b98f2cc7..08889797e0 100644--- a/saleor/order/models.py+++ b/saleor/order/models.py@@ -219,11 +219,6 @@ class Order(ModelWithMetadata):def __str__(self):return "#%d" % (self.id,)- # Deprecated. To remove in #5022- @staticmethod- def get_absolute_url():- return ""-def get_last_payment(self):return max(self.payments.all(), default=None, key=attrgetter("pk"))diff --git a/saleor/page/models.py b/saleor/page/models.pyindex 7c26da8e01..caf25ec6d1 100644--- a/saleor/page/models.py+++ b/saleor/page/models.py@@ -33,11 +33,6 @@ class Page(SeoModel, PublishableModel):def __str__(self):return self.title- # Deprecated. To remove in #5022- @staticmethod- def get_absolute_url():- return ""-class PageTranslation(SeoModelTranslation):language_code = models.CharField(max_length=10)diff --git a/saleor/product/models.py b/saleor/product/models.pyindex 6bcf038a45..115f3130c4 100644--- a/saleor/product/models.py+++ b/saleor/product/models.py@@ -65,11 +65,6 @@ class Category(MPTTModel, ModelWithMetadata, SeoModel):def __str__(self) -> str:return self.name- # Deprecated. To remove in #5022- @staticmethod- def get_absolute_url() -> str:- return ""-class CategoryTranslation(SeoModelTranslation):language_code = models.CharField(max_length=10)@@ -326,11 +321,6 @@ class Product(SeoModel, ModelWithMetadata, PublishableModel):return json_content_to_raw_text(self.description_json)return strip_tags(self.description)- # Deprecated. To remove in #5022- @staticmethod- def get_absolute_url() -> str:- return ""-def get_first_image(self):images = list(self.images.all())return images[0] if images else None@@ -466,11 +456,6 @@ class ProductVariant(ModelWithMetadata):def get_weight(self):return self.weight or self.product.weight or self.product.product_type.weight- # Deprecated. To remove in #5022- @staticmethod- def get_absolute_url() -> str:- return ""-def is_shipping_required(self) -> bool:return self.product.product_type.is_shipping_required@@ -896,11 +881,6 @@ class Collection(SeoModel, ModelWithMetadata, PublishableModel):def __str__(self) -> str:return self.name- # Deprecated. To remove in #5022- @staticmethod- def get_absolute_url() -> str:- return ""-class CollectionTranslation(SeoModelTranslation):language_code = models.CharField(max_length=10)diff --git a/saleor/seo/schema/email.py b/saleor/seo/schema/email.pyindex 3a8b50b171..efbc6ea644 100644--- a/saleor/seo/schema/email.py+++ b/saleor/seo/schema/email.py@@ -37,10 +37,6 @@ def get_product_data(line: "OrderLine", organization: dict) -> dict:return {}product = line.variant.product- # Deprecated. To remove in #5022- product_url = build_absolute_uri(product.get_absolute_url())- product_data["itemOffered"]["url"] = product_url-product_image = product.get_first_image()if product_image:image = product_image.image@@ -51,8 +47,6 @@ 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()- # Deprecated. To remove in #5022- order_url = build_absolute_uri(order.get_absolute_url())data = {"@context": "http://schema.org","@type": "Order",@@ -61,8 +55,6 @@ def get_order_confirmation_markup(order: "Order") -> str:"priceCurrency": order.total.gross.currency,"price": order.total.gross.amount,"acceptedOffer": [],- "url": order_url,- "potentialAction": {"@type": "ViewAction", "url": order_url},"orderStatus": "http://schema.org/OrderProcessing","orderDate": order.created,}diff --git a/tests/api/test_product.py b/tests/api/test_product.pyindex d999a315df..3356ef6bff 100644--- a/tests/api/test_product.py+++ b/tests/api/test_product.py@@ -212,7 +212,7 @@ def test_product_query(staff_api_client, product, permission_manage_products, stassert len(product_edges_data) == category.products.count()product_data = product_edges_data[0]["node"]assert product_data["name"] == product.name- assert product_data["url"] == product.get_absolute_url()+ assert product_data["url"] == ""assert product_data["slug"] == product.sluggross = product_data["pricing"]["priceRange"]["start"]["gross"]assert float(gross["amount"]) == float(product.price.amount)diff --git a/tests/test_menu.py b/tests/test_menu.pyindex f8a1b48d06..6a4524cdd0 100644--- a/tests/test_menu.py+++ b/tests/test_menu.py@@ -29,8 +29,7 @@ def test_get_menu_item_as_dict_with_translations(menu, collection):result = get_menu_item_as_dict(item)assert result == {"name": "Name",- # Deprecated. To remove in #5022- "url": collection.get_absolute_url(),+ "url": item.url or "","translations": {"pl": {"name": "Polish Name"}},}