Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Precise timestamps for publication dates (#9581)
Iga Karbowiakce6a8dc91a8c
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex fd989d896c..f08d5f542f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,24 @@ All notable, unreleased changes to this project will be documented in this file.- Fix filtering product attributes by date range - #9543 by @IKarbowiak- Fix for raising Permission Denied when anonymous user calls `checkout.customer` field - #9573 by @korycins+- Precise timestamps for publication dates - #9581 by @IKarbowiak+ - Change `publicationDate` fields to `publishedAt` date time fields.+ - Types and inputs where `publicationDate` is deprecated and `publishedAt` field should be used instead:+ - `Product`+ - `ProductChannelListing`+ - `CollectionChannelListing`+ - `Page`+ - `PublishableChannelListingInput`+ - `ProductChannelListingAddInput`+ - `PageCreateInput`+ - `PageInput`+ - Change `availableForPurchaseDate` fields to `availableForPurchaseAt` date time field.+ - Deprecate `Product.availableForPurchase` field, the `Product.availableForPurchaseAt` should be used instead.+ - Deprecate `ProductChannelListing.availableForPurchase` field, the `ProductChannelListing.availableForPurchaseAt` should be used instead.+ - Deprecate `publicationDate` on `CollectionInput` and `CollectionCreateInput`.+ - Deprecate `PUBLICATION_DATE` in `CollectionSortField`, the `PUBLISHED_AT` should be used instead.+ - Deprecate `PUBLICATION_DATE` in `PageSortField`, the `PUBLISHED_AT` should be used instead.+ - Add a new column `pubished at` to export products. The new field should be used instead of `publication_date`.# 3.2.0@@ -26,6 +44,7 @@ All notable, unreleased changes to this project will be documented in this file.instead.- Enable JWT expiration by default - #9483 by @maarcingebala+### Other changes#### Saleor Appsdiff --git a/saleor/core/models.py b/saleor/core/models.pyindex 73a0133633..3120aa6772 100644--- a/saleor/core/models.py+++ b/saleor/core/models.py@@ -1,6 +1,7 @@import datetimefrom typing import Any+import pytzfrom django.contrib.postgres.indexes import GinIndexfrom django.db import models, transactionfrom django.db.models import JSONField # type: ignore@@ -43,15 +44,15 @@ class SortableModel(models.Model):class PublishedQuerySet(models.QuerySet):def published(self):- today = datetime.date.today()+ today = datetime.datetime.now(pytz.UTC)return self.filter(- Q(publication_date__lte=today) | Q(publication_date__isnull=True),+ Q(published_at__lte=today) | Q(published_at__isnull=True),is_published=True,)class PublishableModel(models.Model):- publication_date = models.DateField(blank=True, null=True)+ published_at = models.DateTimeField(blank=True, null=True)is_published = models.BooleanField(default=False)objects = models.Manager.from_queryset(PublishedQuerySet)()@@ -62,8 +63,8 @@ class PublishableModel(models.Model):@propertydef is_visible(self):return self.is_published and (- self.publication_date is None- or self.publication_date <= datetime.date.today()+ self.published_at is None+ or self.published_at <= datetime.datetime.now(pytz.UTC))diff --git a/saleor/core/utils/date_time.py b/saleor/core/utils/date_time.pynew file mode 100644index 0000000000..ad45adb347--- /dev/null+++ b/saleor/core/utils/date_time.py@@ -0,0 +1,10 @@+from datetime import datetime++import pytz+++def convert_to_utc_date_time(date):+ """Convert date into utc date time."""+ if date is None:+ return+ return datetime.combine(date, datetime.min.time(), tzinfo=pytz.UTC)diff --git a/saleor/csv/tests/export/products_data/test_prepare_headers.py b/saleor/csv/tests/export/products_data/test_prepare_headers.pyindex 72f391e0ab..436d9f6977 100644--- a/saleor/csv/tests/export/products_data/test_prepare_headers.py+++ b/saleor/csv/tests/export/products_data/test_prepare_headers.py@@ -122,6 +122,7 @@ def test_get_channels_headers(channel_USD, channel_PLN):"product currency code","published","publication date",+ "published at","searchable","available for purchase","price amount",@@ -198,6 +199,7 @@ def test_get_product_export_fields_and_headers_info("product currency code","published","publication date",+ "published at","searchable","available for purchase","price amount",diff --git a/saleor/csv/tests/export/products_data/utils.py b/saleor/csv/tests/export/products_data/utils.pyindex dd678e810b..9f6c3c6a41 100644--- a/saleor/csv/tests/export/products_data/utils.py+++ b/saleor/csv/tests/export/products_data/utils.py@@ -81,9 +81,10 @@ def add_channel_to_expected_product_data(data, product, channel_ids, pk=None):for lookup, field in [("currency_code", "product currency code"),("is_published", "published"),- ("publication_date", "publication date"),+ ("published_at", "publication date"),+ ("published_at", "published at"),("visible_in_listings", "searchable"),- ("available_for_purchase", "available for purchase"),+ ("available_for_purchase_at", "available for purchase"),]:header = f"{channel_slug} (channel {field})"if lookup == "currency_code":diff --git a/saleor/csv/utils/__init__.py b/saleor/csv/utils/__init__.pyindex 54a7574522..b081b10b65 100644--- a/saleor/csv/utils/__init__.py+++ b/saleor/csv/utils/__init__.py@@ -46,9 +46,10 @@ class ProductExportFields:"slug": "channel_listings__channel__slug","product_currency_code": "channel_listings__currency","published": "channel_listings__is_published",- "publication_date": "channel_listings__publication_date",+ "publication_date": "channel_listings__published_at",+ "published_at": "channel_listings__published_at","searchable": "channel_listings__visible_in_listings",- "available for purchase": "channel_listings__available_for_purchase",+ "available for purchase": "channel_listings__available_for_purchase_at",}WAREHOUSE_FIELDS = {diff --git a/saleor/graphql/attribute/descriptions.py b/saleor/graphql/attribute/descriptions.pyindex ff5140d5fe..4d4b510dca 100644--- a/saleor/graphql/attribute/descriptions.py+++ b/saleor/graphql/attribute/descriptions.py@@ -34,9 +34,12 @@ class AttributeValueDescriptions:"(e.g. color values for swatch attributes).")VALUES_RANGE = "The range that the returned values should be in."- DATE_TIME_RANGE = "The date time range that the returned values should be in."- DATE_RANGE = "The date range that the returned values should be in."+ DATE_TIME_RANGE = "The date/time range that the returned values should be in."+ DATE_RANGE = (+ "The date range that the returned values should be in. "+ "In case of date/time attributes, the UTC midnight of the given date is used."+ )RICH_TEXT = "Represents the text (JSON) of the attribute value."BOOLEAN = "Represents the boolean value of the attribute value."DATE = "Represents the date value of the attribute value."- DATE_TIME = "Represents the date time value of the attribute value."+ DATE_TIME = "Represents the date/time value of the attribute value."diff --git a/saleor/graphql/channel/mutations.py b/saleor/graphql/channel/mutations.pyindex 49fdc5fdb3..e512f74712 100644--- a/saleor/graphql/channel/mutations.py+++ b/saleor/graphql/channel/mutations.py@@ -2,6 +2,7 @@ import datetimefrom typing import DefaultDict, Dict, Iterable, Listimport graphene+import pytzfrom django.core.exceptions import ValidationErrorfrom django.utils.text import slugify@@ -9,6 +10,7 @@ from ...channel import modelsfrom ...checkout.models import Checkoutfrom ...core.permissions import ChannelPermissionsfrom ...core.tracing import traced_atomic_transaction+from ...core.utils.date_time import convert_to_utc_date_timefrom ...order.models import Orderfrom ...shipping.tasks import drop_invalid_shipping_methods_relations_for_given_channelsfrom ..account.enums import CountryCodeEnum@@ -349,12 +351,38 @@ class BaseChannelListingMutation(BaseMutation):return cleaned_input@classmethod- def clean_publication_date(cls, cleaned_input, input_source="add_channels"):+ def clean_publication_date(+ cls, errors, error_code_enum, cleaned_input, input_source="add_channels"+ ):+ invalid_channels = []for add_channel in cleaned_input.get(input_source, []):- is_published = add_channel.get("is_published")+ # should update errors dict+ if "publication_date" in add_channel and "published_at" in add_channel:+ invalid_channels.append(add_channel["channel_id"])+ continuepublication_date = add_channel.get("publication_date")+ publication_date = (+ convert_to_utc_date_time(publication_date)+ if publication_date+ else add_channel.get("published_at")+ )+ is_published = add_channel.get("is_published")if is_published and not publication_date:- add_channel["publication_date"] = datetime.date.today()+ add_channel["published_at"] = datetime.datetime.now(pytz.UTC)+ elif "publication_date" in add_channel or "published_at" in add_channel:+ add_channel["published_at"] = publication_date+ if invalid_channels:+ error_msg = (+ "Only one of argument: publicationDate or publishedAt "+ "must be specified."+ )+ errors["publication_date"].append(+ ValidationError(+ error_msg,+ code=error_code_enum.INVALID.value,+ params={"channels": invalid_channels},+ )+ )class ChannelActivate(BaseMutation):diff --git a/saleor/graphql/checkout/mutations/utils.py b/saleor/graphql/checkout/mutations/utils.pyindex 831282ec47..fdcd5ec512 100644--- a/saleor/graphql/checkout/mutations/utils.py+++ b/saleor/graphql/checkout/mutations/utils.py@@ -6,6 +6,7 @@ from decimal import Decimalfrom typing import Any, Dict, Iterable, List, Optional, Union, castimport graphene+import pytzfrom django.core.exceptions import ObjectDoesNotExist, ValidationErrorfrom django.db.models import Q@@ -152,9 +153,9 @@ def check_lines_quantity(def validate_variants_available_for_purchase(variants_id: set, channel_id: int):- today = datetime.date.today()+ today = datetime.datetime.now(pytz.UTC)is_available_for_purchase = Q(- available_for_purchase__lte=today,+ available_for_purchase_at__lte=today,product__variants__id__in=variants_id,channel_id=channel_id,)diff --git a/saleor/graphql/checkout/tests/test_checkout.py b/saleor/graphql/checkout/tests/test_checkout.pyindex daf829b4df..83b4043661 100644--- a/saleor/graphql/checkout/tests/test_checkout.py+++ b/saleor/graphql/checkout/tests/test_checkout.py@@ -7,6 +7,7 @@ from unittest.mock import patchimport grapheneimport pytest+import pytzfrom django.core.exceptions import ValidationErrorfrom django.db.models import Sumfrom django.test import override_settings@@ -1605,7 +1606,7 @@ def test_checkout_create_unavailable_for_purchase_product(variant = stock.product_variantproduct = variant.product- product.channel_listings.update(available_for_purchase=None)+ product.channel_listings.update(available_for_purchase_at=None)variant_id = graphene.Node.to_global_id("ProductVariant", variant.id)test_email = "[email protected]"@@ -1642,7 +1643,8 @@ def test_checkout_create_available_for_purchase_from_tomorrow_product(product = variant.productproduct.channel_listings.update(- available_for_purchase=datetime.date.today() + datetime.timedelta(days=1)+ available_for_purchase_at=datetime.datetime.now(pytz.UTC)+ + datetime.timedelta(days=1))variant_id = graphene.Node.to_global_id("ProductVariant", variant.id)diff --git a/saleor/graphql/checkout/tests/test_checkout_complete.py b/saleor/graphql/checkout/tests/test_checkout_complete.pyindex f091034583..718bd06958 100644--- a/saleor/graphql/checkout/tests/test_checkout_complete.py+++ b/saleor/graphql/checkout/tests/test_checkout_complete.py@@ -1,10 +1,11 @@import uuid-from datetime import date, timedelta+from datetime import datetime, timedeltafrom decimal import Decimalfrom unittest.mock import ANY, patchimport grapheneimport pytest+import pytzfrom django.contrib.auth.models import AnonymousUserfrom django.db.models.aggregates import Sumfrom django.utils import timezone@@ -2284,7 +2285,7 @@ def test_checkout_complete_product_channel_listing_does_not_exist(@pytest.mark.parametrize(- "available_for_purchase", [None, date.today() + timedelta(days=1)]+ "available_for_purchase", [None, datetime.now(pytz.UTC) + timedelta(days=1)])def test_checkout_complete_product_channel_listing_not_available_for_purchase(user_api_client,@@ -2308,8 +2309,8 @@ def test_checkout_complete_product_channel_listing_not_available_for_purchase(product_channel_listings = checkout_line_variant.product.channel_listings.get(channel__id=checkout.channel_id)- product_channel_listings.available_for_purchase = available_for_purchase- product_channel_listings.save(update_fields=["available_for_purchase"])+ product_channel_listings.available_for_purchase_at = available_for_purchase+ product_channel_listings.save(update_fields=["available_for_purchase_at"])manager = get_plugins_manager()lines, _ = fetch_checkout_lines(checkout)diff --git a/saleor/graphql/checkout/tests/test_checkout_lines.py b/saleor/graphql/checkout/tests/test_checkout_lines.pyindex f5c50ab837..7b59b2aa22 100644--- a/saleor/graphql/checkout/tests/test_checkout_lines.py+++ b/saleor/graphql/checkout/tests/test_checkout_lines.py@@ -5,6 +5,7 @@ from unittest import mockimport grapheneimport pytest+import pytzfrom django.utils import timezonefrom ....checkout.error_codes import CheckoutErrorCode@@ -561,7 +562,7 @@ def test_checkout_lines_add_with_unavailable_for_purchase_product(# givenvariant = stock.product_variantproduct = stock.product_variant.product- product.channel_listings.update(available_for_purchase=None)+ product.channel_listings.update(available_for_purchase_at=None)variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)@@ -588,7 +589,8 @@ def test_checkout_lines_add_with_available_for_purchase_from_tomorrow_product(variant = stock.product_variantproduct = stock.product_variant.productproduct.channel_listings.update(- available_for_purchase=datetime.date.today() + datetime.timedelta(days=1)+ available_for_purchase_at=datetime.datetime.now(pytz.UTC)+ + datetime.timedelta(days=1))variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)diff --git a/saleor/graphql/checkout/tests/test_order_create_from_checkout.py b/saleor/graphql/checkout/tests/test_order_create_from_checkout.pyindex 25b0ee823e..8c2777d3b5 100644--- a/saleor/graphql/checkout/tests/test_order_create_from_checkout.py+++ b/saleor/graphql/checkout/tests/test_order_create_from_checkout.py@@ -1,9 +1,10 @@-from datetime import date, timedelta+from datetime import datetime, timedeltafrom decimal import Decimalfrom unittest.mock import ANY, patchimport grapheneimport pytest+import pytzfrom django.db.models.aggregates import Sumfrom django.utils import timezonefrom prices import Money@@ -1287,7 +1288,7 @@ def test_order_from_draft_create_product_channel_listing_does_not_exist(@pytest.mark.parametrize(- "available_for_purchase", [None, date.today() + timedelta(days=1)]+ "available_for_purchase", [None, datetime.now(pytz.UTC) + timedelta(days=1)])def test_order_from_draft_create_product_channel_listing_not_available_for_purchase(app_api_client,@@ -1311,8 +1312,8 @@ def test_order_from_draft_create_product_channel_listing_not_available_for_purchproduct_channel_listings = checkout_line_variant.product.channel_listings.get(channel__id=checkout.channel_id)- product_channel_listings.available_for_purchase = available_for_purchase- product_channel_listings.save(update_fields=["available_for_purchase"])+ product_channel_listings.available_for_purchase_at = available_for_purchase+ product_channel_listings.save(update_fields=["available_for_purchase_at"])orders_count = Order.objects.count()variables = {"id": graphene.Node.to_global_id("Checkout", checkout.pk)}diff --git a/saleor/graphql/order/tests/test_order.py b/saleor/graphql/order/tests/test_order.pyindex a952136ea1..eb7b2e676a 100644--- a/saleor/graphql/order/tests/test_order.py+++ b/saleor/graphql/order/tests/test_order.py@@ -1,11 +1,12 @@from copy import deepcopy-from datetime import date, timedelta+from datetime import date, datetime, timedeltafrom decimal import Decimalfrom unittest import mockfrom unittest.mock import ANY, MagicMock, Mock, call, patchimport grapheneimport pytest+import pytzfrom django.contrib.auth.models import AnonymousUserfrom django.core.exceptions import ValidationErrorfrom django.db.models import Sum@@ -2418,12 +2419,12 @@ def test_draft_order_create_with_channel_with_unpublished_product_by_date(# Ensure no events were created yetassert not OrderEvent.objects.exists()- next_day = date.today() + timedelta(days=1)+ next_day = datetime.now(pytz.UTC) + timedelta(days=1)user_id = graphene.Node.to_global_id("User", customer_user.id)variant_0_id = graphene.Node.to_global_id("ProductVariant", variant_0.id)variant_1 = product_without_shipping.variants.first()channel_listing = variant_1.product.channel_listings.get()- channel_listing.publication_date = next_day+ channel_listing.published_at = next_daychannel_listing.save()variant_1.quantity = 2@@ -3096,7 +3097,7 @@ def test_can_finalize_order_product_unavailable_for_purchase(line = order.lines.first()product = line.variant.product- product.channel_listings.update(available_for_purchase=None)+ product.channel_listings.update(available_for_purchase_at=None)order_id = graphene.Node.to_global_id("Order", order.id)variables = {"id": order_id}@@ -3127,7 +3128,7 @@ def test_can_finalize_order_product_available_for_purchase_from_tomorrow(line = order.lines.first()product = line.variant.productproduct.channel_listings.update(- available_for_purchase=date.today() + timedelta(days=1)+ available_for_purchase_at=datetime.now(pytz.UTC) + timedelta(days=1))order_id = graphene.Node.to_global_id("Order", order.id)@@ -3215,7 +3216,7 @@ def test_validate_draft_order_with_unavailable_for_purchase_product(draft_order)order = draft_orderline = order.lines.first()variant = line.variant- variant.product.channel_listings.update(available_for_purchase=None)+ variant.product.channel_listings.update(available_for_purchase_at=None)line.refresh_from_db()with pytest.raises(ValidationError) as e:@@ -3234,7 +3235,7 @@ def test_validate_draft_order_with_product_available_for_purchase_in_future(line = order.lines.first()variant = line.variantvariant.product.channel_listings.update(- available_for_purchase=date.today() + timedelta(days=2)+ available_for_purchase_at=datetime.now(pytz.UTC) + timedelta(days=2))line.refresh_from_db()@@ -3856,7 +3857,7 @@ def test_draft_order_complete_unavailable_for_purchase(product = order.lines.first().variant.productproduct.channel_listings.update(- available_for_purchase=date.today() + timedelta(days=5)+ available_for_purchase_at=datetime.now(pytz.UTC) + timedelta(days=5))order_id = graphene.Node.to_global_id("Order", order.id)@@ -4126,6 +4127,52 @@ def test_order_lines_create(assert variant.sku.lower() in order.search_document[email protected]("status", (OrderStatus.DRAFT, OrderStatus.UNCONFIRMED))+@patch("saleor.plugins.manager.PluginsManager.draft_order_updated")+@patch("saleor.plugins.manager.PluginsManager.order_updated")+@patch("saleor.plugins.manager.PluginsManager.product_variant_out_of_stock")+def test_order_lines_create_for_just_published_product(+ product_variant_out_of_stock_webhook_mock,+ order_updated_webhook_mock,+ draft_order_updated_webhook_mock,+ status,+ order_with_lines,+ permission_manage_orders,+ staff_api_client,+ variant_with_many_stocks,+):+ # given+ query = ORDER_LINES_CREATE_MUTATION+ order = order_with_lines+ order.status = status+ order.save(update_fields=["status"])+ variant = variant_with_many_stocks+ product_listing = variant.product.channel_listings.get(channel=order.channel)+ product_listing.published_at = datetime.now(pytz.utc)+ product_listing.save(update_fields=["published_at"])++ quantity = 1+ order_id = graphene.Node.to_global_id("Order", order.id)+ variant_id = graphene.Node.to_global_id("ProductVariant", variant.id)+ staff_api_client.user.user_permissions.add(permission_manage_orders)+ variables = {"orderId": order_id, "variantId": variant_id, "quantity": quantity}++ # when+ response = staff_api_client.post_graphql(query, variables)++ # then+ assert_proper_webhook_called_once(+ order, status, draft_order_updated_webhook_mock, order_updated_webhook_mock+ )+ assert OrderEvent.objects.count() == 1+ assert OrderEvent.objects.last().type == order_events.OrderEvents.ADDED_PRODUCTS+ content = get_graphql_content(response)+ data = content["data"]["orderLinesCreate"]+ assert data["orderLines"][0]["productSku"] == variant.sku+ assert data["orderLines"][0]["productVariantId"] == variant.get_global_id()+ assert data["orderLines"][0]["quantity"] == quantity++@patch("saleor.plugins.manager.PluginsManager.draft_order_updated")@patch("saleor.plugins.manager.PluginsManager.order_updated")def test_order_lines_create_with_unavailable_variant(diff --git a/saleor/graphql/page/mutations/pages.py b/saleor/graphql/page/mutations/pages.pyindex 5ecb277fcb..d72a793351 100644--- a/saleor/graphql/page/mutations/pages.py+++ b/saleor/graphql/page/mutations/pages.py@@ -1,8 +1,9 @@from collections import defaultdict-from datetime import date+from datetime import datetimefrom typing import TYPE_CHECKING, Dict, Listimport graphene+import pytzfrom django.core.exceptions import ValidationErrorfrom django.db import transaction@@ -14,6 +15,7 @@ from ....page import modelsfrom ....page.error_codes import PageErrorCodefrom ...attribute.types import AttributeValueInputfrom ...attribute.utils import AttributeAssignmentMixin+from ...core.descriptions import ADDED_IN_33, DEPRECATED_IN_3X_INPUTfrom ...core.fields import JSONStringfrom ...core.mutations import ModelDeleteMutation, ModelMutationfrom ...core.types import NonNullList, PageError, SeoInput@@ -34,7 +36,13 @@ class PageInput(graphene.InputObjectType):description="Determines if page is visible in the storefront.")publication_date = graphene.String(- description="Publication date. ISO 8601 standard."+ description=(+ f"Publication date. ISO 8601 standard. {DEPRECATED_IN_3X_INPUT} "+ "Use `publishedAt` field instead."+ )+ )+ published_at = graphene.DateTime(+ description=f"{ADDED_IN_33} Publication date time. ISO 8601 standard.")seo = SeoInput(description="Search engine optimization fields.")@@ -78,10 +86,25 @@ class PageCreate(ModelMutation):error.code = PageErrorCode.REQUIREDraise ValidationError({"slug": error})+ if "publication_date" in cleaned_input and "published_at" in cleaned_input:+ raise ValidationError(+ {+ "publication_date": ValidationError(+ "Only one of argument: publicationDate or publishedAt "+ "must be specified.",+ code=PageErrorCode.INVALID.value,+ )+ }+ )+is_published = cleaned_input.get("is_published")- publication_date = cleaned_input.get("publication_date")+ publication_date = cleaned_input.get("published_at") or cleaned_input.get(+ "publication_date"+ )if is_published and not publication_date:- cleaned_input["publication_date"] = date.today()+ cleaned_input["published_at"] = datetime.now(pytz.UTC)+ elif "publication_date" in cleaned_input or "published_at" in cleaned_input:+ cleaned_input["published_at"] = publication_dateattributes = cleaned_input.get("attributes")page_type = (diff --git a/saleor/graphql/page/sorters.py b/saleor/graphql/page/sorters.pyindex 67895c0d39..7c1e757493 100644--- a/saleor/graphql/page/sorters.py+++ b/saleor/graphql/page/sorters.py@@ -1,5 +1,6 @@import graphene+from ..core.descriptions import DEPRECATED_IN_3X_INPUTfrom ..core.types import SortInputObjectType@@ -8,13 +9,17 @@ class PageSortField(graphene.Enum):SLUG = ["slug"]VISIBILITY = ["is_published", "title", "slug"]CREATION_DATE = ["created_at", "title", "slug"]- PUBLICATION_DATE = ["publication_date", "title", "slug"]+ PUBLICATION_DATE = ["published_at", "title", "slug"]+ PUBLISHED_AT = ["published_at", "title", "slug"]@propertydef description(self):if self.name in PageSortField.__enum__._member_names_:sort_name = self.name.lower().replace("_", " ")- return f"Sort pages by {sort_name}."+ description = f"Sort pages by {sort_name}."+ if self.name == "PUBLICATION_DATE":+ description += DEPRECATED_IN_3X_INPUT+ return descriptionraise ValueError("Unsupported enum value: %s" % self.value)diff --git a/saleor/graphql/page/tests/deprecated/__init__.py b/saleor/graphql/page/tests/deprecated/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/saleor/graphql/page/tests/deprecated/test_page_create.py b/saleor/graphql/page/tests/deprecated/test_page_create.pynew file mode 100644index 0000000000..29e9b9b165--- /dev/null+++ b/saleor/graphql/page/tests/deprecated/test_page_create.py@@ -0,0 +1,144 @@+from datetime import datetime, timedelta++import graphene+import pytz+from django.utils.text import slugify++from .....page.error_codes import PageErrorCode+from .....tests.utils import dummy_editorjs+from ....tests.utils import get_graphql_content++CREATE_PAGE_MUTATION = """+ mutation CreatePage(+ $input: PageCreateInput!+ ) {+ pageCreate(input: $input) {+ page {+ id+ title+ content+ slug+ isPublished+ publicationDate+ pageType {+ id+ }+ attributes {+ attribute {+ slug+ }+ values {+ slug+ name+ reference+ date+ dateTime+ file {+ url+ contentType+ }+ }+ }+ }+ errors {+ field+ code+ message+ attributes+ }+ }+ }+"""+++def test_page_create_mutation_with_publication_date(+ staff_api_client, permission_manage_pages, page_type+):+ page_slug = "test-slug"+ page_content = dummy_editorjs("test content", True)+ page_title = "test title"+ page_is_published = True+ publication_date = datetime.now(pytz.utc) + timedelta(days=5)+ page_type_id = graphene.Node.to_global_id("PageType", page_type.pk)++ # Default attributes defined in product_type fixture+ tag_attr = page_type.page_attributes.get(name="tag")+ tag_value_slug = tag_attr.values.first().slug+ tag_attr_id = graphene.Node.to_global_id("Attribute", tag_attr.id)++ # Add second attribute+ size_attr = page_type.page_attributes.get(name="Page size")+ size_attr_id = graphene.Node.to_global_id("Attribute", size_attr.id)+ non_existent_attr_value = "New value"++ # test creating root page+ variables = {+ "input": {+ "title": page_title,+ "content": page_content,+ "isPublished": page_is_published,+ "publicationDate": publication_date,+ "slug": page_slug,+ "pageType": page_type_id,+ "attributes": [+ {"id": tag_attr_id, "values": [tag_value_slug]},+ {"id": size_attr_id, "values": [non_existent_attr_value]},+ ],+ }+ }++ response = staff_api_client.post_graphql(+ CREATE_PAGE_MUTATION, variables, permissions=[permission_manage_pages]+ )+ content = get_graphql_content(response)+ data = content["data"]["pageCreate"]+ assert data["errors"] == []+ assert data["page"]["title"] == page_title+ assert data["page"]["content"] == page_content+ assert data["page"]["slug"] == page_slug+ assert data["page"]["isPublished"] == page_is_published+ assert data["page"]["publicationDate"] == publication_date.date().isoformat()+ assert data["page"]["pageType"]["id"] == page_type_id+ values = (+ data["page"]["attributes"][0]["values"][0]["slug"],+ data["page"]["attributes"][1]["values"][0]["slug"],+ )+ assert slugify(non_existent_attr_value) in values+ assert tag_value_slug in values+++def test_page_create_mutation_publication_date_and_published_at_provided(+ staff_api_client, permission_manage_pages, page_type+):+ """Ensure an error is raised when publishedAt and publicationDate are both+ provided."""+ page_slug = "test-slug"+ page_content = dummy_editorjs("test content", True)+ page_title = "test title"+ page_is_published = True+ publication_date = datetime.now(pytz.utc) + timedelta(days=5)+ published_at = datetime.now(pytz.utc) + timedelta(days=5)+ page_type_id = graphene.Node.to_global_id("PageType", page_type.pk)++ # test creating root page+ variables = {+ "input": {+ "title": page_title,+ "content": page_content,+ "isPublished": page_is_published,+ "publishedAt": published_at,+ "publicationDate": publication_date,+ "slug": page_slug,+ "pageType": page_type_id,+ }+ }++ response = staff_api_client.post_graphql(+ CREATE_PAGE_MUTATION, variables, permissions=[permission_manage_pages]+ )+ content = get_graphql_content(response)+ data = content["data"]["pageCreate"]+ assert not data["page"]+ assert len(data["errors"]) == 1+ assert data["errors"][0]["field"] == "publicationDate"+ assert data["errors"][0]["code"] == PageErrorCode.INVALID.namediff --git a/saleor/graphql/page/tests/deprecated/test_page_sorting.py b/saleor/graphql/page/tests/deprecated/test_page_sorting.pynew file mode 100644index 0000000000..ee5cbfe02e--- /dev/null+++ b/saleor/graphql/page/tests/deprecated/test_page_sorting.py@@ -0,0 +1,79 @@+import pytest+from django.utils import timezone+from freezegun import freeze_time++from .....page.models import Page+from .....tests.utils import dummy_editorjs+from ....tests.utils import get_graphql_content++QUERY_PAGE_WITH_SORT = """+ query ($sort_by: PageSortingInput!) {+ pages(first:5, sortBy: $sort_by) {+ edges{+ node{+ title+ }+ }+ }+ }+"""+++ "page_sort, result_order",+ [+ ({"field": "TITLE", "direction": "ASC"}, ["About", "Page1", "Page2"]),+ ({"field": "TITLE", "direction": "DESC"}, ["Page2", "Page1", "About"]),+ ({"field": "SLUG", "direction": "ASC"}, ["About", "Page2", "Page1"]),+ ({"field": "SLUG", "direction": "DESC"}, ["Page1", "Page2", "About"]),+ ({"field": "VISIBILITY", "direction": "ASC"}, ["Page2", "About", "Page1"]),+ ({"field": "VISIBILITY", "direction": "DESC"}, ["Page1", "About", "Page2"]),+ ({"field": "CREATION_DATE", "direction": "ASC"}, ["Page1", "About", "Page2"]),+ ({"field": "CREATION_DATE", "direction": "DESC"}, ["Page2", "About", "Page1"]),+ (+ {"field": "PUBLICATION_DATE", "direction": "ASC"},+ ["Page1", "Page2", "About"],+ ),+ (+ {"field": "PUBLICATION_DATE", "direction": "DESC"},+ ["About", "Page2", "Page1"],+ ),+ ],+)+def test_query_pages_with_sort(+ page_sort, result_order, staff_api_client, permission_manage_pages, page_type+):+ with freeze_time("2017-05-31 12:00:01"):+ Page.objects.create(+ title="Page1",+ slug="slug_page_1",+ content=dummy_editorjs("p1."),+ is_published=True,+ published_at=timezone.now().replace(year=2018, month=12, day=5),+ page_type=page_type,+ )+ with freeze_time("2019-05-31 12:00:01"):+ Page.objects.create(+ title="Page2",+ slug="page_2",+ content=dummy_editorjs("p2."),+ is_published=False,+ published_at=timezone.now().replace(year=2019, month=12, day=5),+ page_type=page_type,+ )+ with freeze_time("2018-05-31 12:00:01"):+ Page.objects.create(+ title="About",+ slug="about",+ content=dummy_editorjs("Ab."),+ is_published=True,+ page_type=page_type,+ )+ variables = {"sort_by": page_sort}+ staff_api_client.user.user_permissions.add(permission_manage_pages)+ response = staff_api_client.post_graphql(QUERY_PAGE_WITH_SORT, variables)+ content = get_graphql_content(response)+ pages = content["data"]["pages"]["edges"]++ for order, page_name in enumerate(result_order):+ assert pages[order]["node"]["title"] == page_namediff --git a/saleor/graphql/page/tests/deprecated/test_page_update.py b/saleor/graphql/page/tests/deprecated/test_page_update.pynew file mode 100644index 0000000000..3d4e1a624a--- /dev/null+++ b/saleor/graphql/page/tests/deprecated/test_page_update.py@@ -0,0 +1,110 @@+from datetime import datetime, timedelta++import graphene+import pytz++from .....page.error_codes import PageErrorCode+from .....page.models import Page+from ....tests.utils import get_graphql_content++UPDATE_PAGE_MUTATION = """+ mutation updatePage(+ $id: ID!, $input: PageInput!+ ) {+ pageUpdate(+ id: $id, input: $input+ ) {+ page {+ id+ title+ slug+ isPublished+ publicationDate+ attributes {+ attribute {+ slug+ }+ values {+ slug+ name+ reference+ file {+ url+ contentType+ }+ }+ }+ }+ errors {+ field+ code+ message+ }+ }+ }+"""+++def test_update_page_publication_date(+ staff_api_client, permission_manage_pages, page_type+):+ data = {+ "slug": "test-url",+ "title": "Test page",+ "page_type": page_type,+ }+ page = Page.objects.create(**data)+ publication_date = datetime.now(pytz.utc) + timedelta(days=5)+ page_id = graphene.Node.to_global_id("Page", page.id)+ variables = {+ "id": page_id,+ "input": {+ "isPublished": True,+ "slug": page.slug,+ "publicationDate": publication_date,+ },+ }+ response = staff_api_client.post_graphql(+ UPDATE_PAGE_MUTATION, variables, permissions=[permission_manage_pages]+ )+ content = get_graphql_content(response)+ data = content["data"]["pageUpdate"]++ assert not data["errors"]+ assert data["page"]["isPublished"] is True+ assert data["page"]["publicationDate"] == publication_date.date().isoformat()+++def test_page_update_mutation_publication_date_and_published_at_provided(+ staff_api_client, permission_manage_pages, page_type+):+ """Ensure an error is raised when publishedAt and publicationDate are both+ provided."""+ data = {+ "slug": "test-url",+ "title": "Test page",+ "page_type": page_type,+ }+ page = Page.objects.create(**data)+ published_at = datetime.now(pytz.utc) + timedelta(days=5)+ publication_date = datetime.now(pytz.utc) + timedelta(days=5)+ page_id = graphene.Node.to_global_id("Page", page.id)++ # test creating root page+ variables = {+ "id": page_id,+ "input": {+ "publishedAt": published_at,+ "publicationDate": publication_date,+ },+ }++ response = staff_api_client.post_graphql(+ UPDATE_PAGE_MUTATION, variables, permissions=[permission_manage_pages]+ )+ content = get_graphql_content(response)+ data = content["data"]["pageUpdate"]+ assert not data["page"]+ assert len(data["errors"]) == 1+ assert data["errors"][0]["field"] == "publicationDate"+ assert data["errors"][0]["code"] == PageErrorCode.INVALID.namediff --git a/saleor/graphql/page/tests/mutations/test_page_create.py b/saleor/graphql/page/tests/mutations/test_page_create.pyindex 16d62f23c5..9efce11fc9 100644--- a/saleor/graphql/page/tests/mutations/test_page_create.py+++ b/saleor/graphql/page/tests/mutations/test_page_create.py@@ -1,4 +1,4 @@-from datetime import datetime+from datetime import datetime, timedeltafrom unittest import mockimport graphene@@ -16,21 +16,16 @@ from ....tests.utils import get_graphql_contentCREATE_PAGE_MUTATION = """mutation CreatePage(- $slug: String, $title: String, $content: JSONString, $pageType: ID!- $isPublished: Boolean,- $attributes: [AttributeValueInput!]) {- pageCreate(- input: {- slug: $slug, title: $title, pageType: $pageType- content: $content- isPublished: $isPublished, attributes: $attributes}) {+ $input: PageCreateInput!+ ) {+ pageCreate(input: $input) {page {idtitlecontentslugisPublished- publicationDate+ publishedAtpageType {id}@@ -82,15 +77,74 @@ def test_page_create_mutation(staff_api_client, permission_manage_pages, page_ty# test creating root pagevariables = {- "title": page_title,- "content": page_content,- "isPublished": page_is_published,- "slug": page_slug,- "pageType": page_type_id,- "attributes": [- {"id": tag_attr_id, "values": [tag_value_slug]},- {"id": size_attr_id, "values": [non_existent_attr_value]},- ],+ "input": {+ "title": page_title,+ "content": page_content,+ "isPublished": page_is_published,+ "slug": page_slug,+ "pageType": page_type_id,+ "attributes": [+ {"id": tag_attr_id, "values": [tag_value_slug]},+ {"id": size_attr_id, "values": [non_existent_attr_value]},+ ],+ }+ }++ response = staff_api_client.post_graphql(+ CREATE_PAGE_MUTATION, variables, permissions=[permission_manage_pages]+ )+ content = get_graphql_content(response)+ data = content["data"]["pageCreate"]+ assert data["errors"] == []+ assert data["page"]["title"] == page_title+ assert data["page"]["content"] == page_content+ assert data["page"]["slug"] == page_slug+ assert data["page"]["isPublished"] == page_is_published+ assert data["page"]["publishedAt"] == datetime.now(pytz.utc).isoformat()+ assert data["page"]["pageType"]["id"] == page_type_id+ values = (+ data["page"]["attributes"][0]["values"][0]["slug"],+ data["page"]["attributes"][1]["values"][0]["slug"],+ )+ assert slugify(non_existent_attr_value) in values+ assert tag_value_slug in values+++@freeze_time("2020-03-18 12:00:00")+def test_page_create_mutation_with_published_at_date(+ staff_api_client, permission_manage_pages, page_type+):+ page_slug = "test-slug"+ page_content = dummy_editorjs("test content", True)+ page_title = "test title"+ page_is_published = True+ published_at = datetime.now(pytz.utc).replace(microsecond=0) + timedelta(days=5)+ page_type_id = graphene.Node.to_global_id("PageType", page_type.pk)++ # Default attributes defined in product_type fixture+ tag_attr = page_type.page_attributes.get(name="tag")+ tag_value_slug = tag_attr.values.first().slug+ tag_attr_id = graphene.Node.to_global_id("Attribute", tag_attr.id)++ # Add second attribute+ size_attr = page_type.page_attributes.get(name="Page size")+ size_attr_id = graphene.Node.to_global_id("Attribute", size_attr.id)+ non_existent_attr_value = "New value"++ # test creating root page+ variables = {+ "input": {+ "title": page_title,+ "content": page_content,+ "isPublished": page_is_published,+ "publishedAt": published_at,+ "slug": page_slug,+ "pageType": page_type_id,+ "attributes": [+ {"id": tag_attr_id, "values": [tag_value_slug]},+ {"id": size_attr_id, "values": [non_existent_attr_value]},+ ],+ }}response = staff_api_client.post_graphql(@@ -103,7 +157,7 @@ def test_page_create_mutation(staff_api_client, permission_manage_pages, page_tyassert data["page"]["content"] == page_contentassert data["page"]["slug"] == page_slugassert data["page"]["isPublished"] == page_is_published- assert data["page"]["publicationDate"] == "2020-03-18"+ assert data["page"]["publishedAt"] == published_at.isoformat()assert data["page"]["pageType"]["id"] == page_type_idvalues = (data["page"]["attributes"][0]["values"][0]["slug"],@@ -135,11 +189,13 @@ def test_page_create_trigger_page_webhook(page_type_id = graphene.Node.to_global_id("PageType", page_type.pk)# test creating root pagevariables = {- "title": page_title,- "content": page_content,- "isPublished": page_is_published,- "slug": page_slug,- "pageType": page_type_id,+ "input": {+ "title": page_title,+ "content": page_content,+ "isPublished": page_is_published,+ "slug": page_slug,+ "pageType": page_type_id,+ }}response = staff_api_client.post_graphql(@@ -168,24 +224,28 @@ def test_page_create_trigger_page_webhook(def test_page_create_required_fields(staff_api_client, permission_manage_pages, page_type):- variables = {"pageType": graphene.Node.to_global_id("PageType", page_type.pk)}+ variables = {+ "input": {"pageType": graphene.Node.to_global_id("PageType", page_type.pk)}+ }response = staff_api_client.post_graphql(CREATE_PAGE_MUTATION, variables, permissions=[permission_manage_pages])content = get_graphql_content(response)errors = content["data"]["pageCreate"]["errors"]- assert len(errors) == 1- assert errors[0]["field"] == "title"- assert errors[0]["code"] == PageErrorCode.REQUIRED.name+ assert len(errors) == 2+ assert {error["field"] for error in errors} == {"title", "slug"}+ assert {error["code"] for error in errors} == {PageErrorCode.REQUIRED.name}def test_create_default_slug(staff_api_client, permission_manage_pages, page_type):# test creating root pagetitle = "Spanish inquisition"variables = {- "title": title,- "pageType": graphene.Node.to_global_id("PageType", page_type.pk),+ "input": {+ "title": title,+ "pageType": graphene.Node.to_global_id("PageType", page_type.pk),+ }}response = staff_api_client.post_graphql(CREATE_PAGE_MUTATION, variables, permissions=[permission_manage_pages]@@ -219,12 +279,14 @@ def test_page_create_mutation_missing_required_attributes(# test creating root pagevariables = {- "title": page_title,- "content": page_content,- "isPublished": page_is_published,- "slug": page_slug,- "pageType": page_type_id,- "attributes": [{"id": tag_attr_id, "values": [tag_value_slug]}],+ "input": {+ "title": page_title,+ "content": page_content,+ "isPublished": page_is_published,+ "slug": page_slug,+ "pageType": page_type_id,+ "attributes": [{"id": tag_attr_id, "values": [tag_value_slug]}],+ }}# when@@ -262,12 +324,14 @@ def test_page_create_mutation_empty_attribute_value(# test creating root pagevariables = {- "title": page_title,- "content": page_content,- "isPublished": page_is_published,- "slug": page_slug,- "pageType": page_type_id,- "attributes": [{"id": tag_attr_id, "values": [" "]}],+ "input": {+ "title": page_title,+ "content": page_content,+ "isPublished": page_is_published,+ "slug": page_slug,+ "pageType": page_type_id,+ "attributes": [{"id": tag_attr_id, "values": [" "]}],+ }}# when@@ -310,12 +374,14 @@ def test_create_page_with_file_attribute(# test creating root pagevariables = {- "title": page_title,- "content": page_content,- "isPublished": page_is_published,- "slug": page_slug,- "pageType": page_type_id,- "attributes": [{"id": file_attribute_id, "file": attr_value.file_url}],+ "input": {+ "title": page_title,+ "content": page_content,+ "isPublished": page_is_published,+ "slug": page_slug,+ "pageType": page_type_id,+ "attributes": [{"id": file_attribute_id, "file": attr_value.file_url}],+ }}# when@@ -379,18 +445,20 @@ def test_create_page_with_file_attribute_new_attribute_value(# test creating root pagevariables = {- "title": page_title,- "content": page_content,- "isPublished": page_is_published,- "slug": page_slug,- "pageType": page_type_id,- "attributes": [- {- "id": file_attribute_id,- "file": new_value,- "contentType": new_value_content_type,- }- ],+ "input": {+ "title": page_title,+ "content": page_content,+ "isPublished": page_is_published,+ "slug": page_slug,+ "pageType": page_type_id,+ "attributes": [+ {+ "id": file_attribute_id,+ "file": new_value,+ "contentType": new_value_content_type,+ }+ ],+ }}# when@@ -453,12 +521,14 @@ def test_create_page_with_file_attribute_not_required_no_file_url_given(# test creating root pagevariables = {- "title": page_title,- "content": page_content,- "isPublished": page_is_published,- "slug": page_slug,- "pageType": page_type_id,- "attributes": [{"id": file_attribute_id, "file": ""}],+ "input": {+ "title": page_title,+ "content": page_content,+ "isPublished": page_is_published,+ "slug": page_slug,+ "pageType": page_type_id,+ "attributes": [{"id": file_attribute_id, "file": ""}],+ }}# when@@ -499,12 +569,14 @@ def test_create_page_with_file_attribute_required_no_file_url_given(# test creating root pagevariables = {- "title": page_title,- "content": page_content,- "isPublished": page_is_published,- "slug": page_slug,- "pageType": page_type_id,- "attributes": [{"id": file_attribute_id, "file": ""}],+ "input": {+ "title": page_title,+ "content": page_content,+ "isPublished": page_is_published,+ "slug": page_slug,+ "pageType": page_type_id,+ "attributes": [{"id": file_attribute_id, "file": ""}],+ }}# when@@ -549,12 +621,14 @@ def test_create_page_with_page_reference_attribute(# test creating root pagevariables = {- "title": page_title,- "content": page_content,- "isPublished": page_is_published,- "slug": page_slug,- "pageType": page_type_id,- "attributes": [{"id": ref_attribute_id, "references": [reference]}],+ "input": {+ "title": page_title,+ "content": page_content,+ "isPublished": page_is_published,+ "slug": page_slug,+ "pageType": page_type_id,+ "attributes": [{"id": ref_attribute_id, "references": [reference]}],+ }}# when@@ -613,11 +687,13 @@ def test_create_page_with_date_attribute(date_value = date_time_value.date()variables = {- "title": page_title,- "pageType": page_type_id,- "attributes": [- {"id": date_attribute_id, "date": date_value},- ],+ "input": {+ "title": page_title,+ "pageType": page_type_id,+ "attributes": [+ {"id": date_attribute_id, "date": date_value},+ ],+ }}# when@@ -670,11 +746,13 @@ def test_create_page_with_date_time_attribute()date_time_value = datetime.now(tz=pytz.utc)variables = {- "title": page_title,- "pageType": page_type_id,- "attributes": [- {"id": date_time_attribute_id, "dateTime": date_time_value},- ],+ "input": {+ "title": page_title,+ "pageType": page_type_id,+ "attributes": [+ {"id": date_time_attribute_id, "dateTime": date_time_value},+ ],+ }}# when@@ -735,12 +813,14 @@ def test_create_page_with_page_reference_attribute_not_required_no_references_gi# test creating root pagevariables = {- "title": page_title,- "content": page_content,- "isPublished": page_is_published,- "slug": page_slug,- "pageType": page_type_id,- "attributes": [{"id": file_attribute_id, "file": ""}],+ "input": {+ "title": page_title,+ "content": page_content,+ "isPublished": page_is_published,+ "slug": page_slug,+ "pageType": page_type_id,+ "attributes": [{"id": file_attribute_id, "file": ""}],+ }}# when@@ -786,12 +866,14 @@ def test_create_page_with_page_reference_attribute_required_no_references_given(# test creating root pagevariables = {- "title": page_title,- "content": page_content,- "isPublished": page_is_published,- "slug": page_slug,- "pageType": page_type_id,- "attributes": [{"id": file_attribute_id, "file": ""}],+ "input": {+ "title": page_title,+ "content": page_content,+ "isPublished": page_is_published,+ "slug": page_slug,+ "pageType": page_type_id,+ "attributes": [{"id": file_attribute_id, "file": ""}],+ }}# when@@ -836,12 +918,14 @@ def test_create_page_with_product_reference_attribute(# test creating root pagevariables = {- "title": page_title,- "content": page_content,- "isPublished": page_is_published,- "slug": page_slug,- "pageType": page_type_id,- "attributes": [{"id": ref_attribute_id, "references": [reference]}],+ "input": {+ "title": page_title,+ "content": page_content,+ "isPublished": page_is_published,+ "slug": page_slug,+ "pageType": page_type_id,+ "attributes": [{"id": ref_attribute_id, "references": [reference]}],+ }}# when@@ -908,12 +992,14 @@ def test_create_page_with_product_reference_attribute_not_required_no_references# test creating root pagevariables = {- "title": page_title,- "content": page_content,- "isPublished": page_is_published,- "slug": page_slug,- "pageType": page_type_id,- "attributes": [{"id": file_attribute_id, "file": ""}],+ "input": {+ "title": page_title,+ "content": page_content,+ "isPublished": page_is_published,+ "slug": page_slug,+ "pageType": page_type_id,+ "attributes": [{"id": file_attribute_id, "file": ""}],+ }}# when@@ -959,12 +1045,14 @@ def test_create_page_with_product_reference_attribute_required_no_references_giv# test creating root pagevariables = {- "title": page_title,- "content": page_content,- "isPublished": page_is_published,- "slug": page_slug,- "pageType": page_type_id,- "attributes": [{"id": file_attribute_id, "file": ""}],+ "input": {+ "title": page_title,+ "content": page_content,+ "isPublished": page_is_published,+ "slug": page_slug,+ "pageType": page_type_id,+ "attributes": [{"id": file_attribute_id, "file": ""}],+ }}# whendiff --git a/saleor/graphql/page/tests/mutations/test_page_update.py b/saleor/graphql/page/tests/mutations/test_page_update.pyindex 406f3916d0..43ae64d1be 100644--- a/saleor/graphql/page/tests/mutations/test_page_update.py+++ b/saleor/graphql/page/tests/mutations/test_page_update.py@@ -1,8 +1,10 @@-from datetime import date+from datetime import datetime, timedeltafrom unittest import mockimport grapheneimport pytest+import pytz+from django.utils import timezonefrom django.utils.functional import SimpleLazyObjectfrom django.utils.text import slugifyfrom freezegun import freeze_time@@ -28,7 +30,7 @@ UPDATE_PAGE_MUTATION = """titleslugisPublished- publicationDate+ publishedAtattributes {attribute {slug@@ -165,7 +167,7 @@ def test_update_page_trigger_webhook(assert not data["errors"]assert data["page"]["title"] == page_titleassert data["page"]["slug"] == new_slug- page.publication_date = date(2020, 3, 18)+ page.published_at = timezone.now()expected_data = generate_page_payload(page, staff_api_client.user)mocked_webhook_trigger.assert_called_once_with(expected_data,@@ -626,7 +628,33 @@ def test_public_page_sets_publication_date(assert not data["errors"]assert data["page"]["isPublished"] is True- assert data["page"]["publicationDate"] == "2020-03-18"+ assert data["page"]["publishedAt"] == datetime.now(pytz.utc).isoformat()+++def test_update_page_publication_date(+ staff_api_client, permission_manage_pages, page_type+):+ data = {+ "slug": "test-url",+ "title": "Test page",+ "page_type": page_type,+ }+ page = Page.objects.create(**data)+ published_at = datetime.now(pytz.utc).replace(microsecond=0) + timedelta(days=5)+ page_id = graphene.Node.to_global_id("Page", page.id)+ variables = {+ "id": page_id,+ "input": {"isPublished": True, "slug": page.slug, "publishedAt": published_at},+ }+ response = staff_api_client.post_graphql(+ UPDATE_PAGE_MUTATION, variables, permissions=[permission_manage_pages]+ )+ content = get_graphql_content(response)+ data = content["data"]["pageUpdate"]++ assert not data["errors"]+ assert data["page"]["isPublished"] is True+ assert data["page"]["publishedAt"] == published_at.isoformat()@pytest.mark.parametrize("slug_value", [None, ""])diff --git a/saleor/graphql/page/tests/queries/test_pages.py b/saleor/graphql/page/tests/queries/test_pages.pyindex 9bc08bb79e..ebb93329e8 100644--- a/saleor/graphql/page/tests/queries/test_pages.py+++ b/saleor/graphql/page/tests/queries/test_pages.py@@ -117,11 +117,11 @@ QUERY_PAGE_WITH_SORT = """({"field": "CREATION_DATE", "direction": "ASC"}, ["Page1", "About", "Page2"]),({"field": "CREATION_DATE", "direction": "DESC"}, ["Page2", "About", "Page1"]),(- {"field": "PUBLICATION_DATE", "direction": "ASC"},+ {"field": "PUBLISHED_AT", "direction": "ASC"},["Page1", "Page2", "About"],),(- {"field": "PUBLICATION_DATE", "direction": "DESC"},+ {"field": "PUBLISHED_AT", "direction": "DESC"},["About", "Page2", "Page1"],),],@@ -135,7 +135,7 @@ def test_query_pages_with_sort(slug="slug_page_1",content=dummy_editorjs("p1."),is_published=True,- publication_date=timezone.now().replace(year=2018, month=12, day=5),+ published_at=timezone.now().replace(year=2018, month=12, day=5),page_type=page_type,)with freeze_time("2019-05-31 12:00:01"):@@ -144,7 +144,7 @@ def test_query_pages_with_sort(slug="page_2",content=dummy_editorjs("p2."),is_published=False,- publication_date=timezone.now().replace(year=2019, month=12, day=5),+ published_at=timezone.now().replace(year=2019, month=12, day=5),page_type=page_type,)with freeze_time("2018-05-31 12:00:01"):diff --git a/saleor/graphql/page/types.py b/saleor/graphql/page/types.pyindex 310eb5a8ea..1ce3bbdf67 100644--- a/saleor/graphql/page/types.py+++ b/saleor/graphql/page/types.py@@ -12,7 +12,7 @@ from ..core.connection import (create_connection_slice,filter_connection_queryset,)-from ..core.descriptions import DEPRECATED_IN_3X_FIELD+from ..core.descriptions import ADDED_IN_33, DEPRECATED_IN_3X_FIELDfrom ..core.federation import federated_entity, resolve_federation_referencesfrom ..core.fields import FilterConnectionField, JSONString, PermissionsFieldfrom ..core.types import ModelObjectType, NonNullList@@ -99,7 +99,15 @@ class Page(ModelObjectType):seo_description = graphene.String()title = graphene.String(required=True)content = JSONString(description="Content of the page (JSON).")- publication_date = graphene.Date()+ publication_date = graphene.Date(+ deprecation_reason=(+ f"{DEPRECATED_IN_3X_FIELD} "+ "Use the `publishedAt` field to fetch the publication date."+ ),+ )+ published_at = graphene.DateTime(+ description=f"{ADDED_IN_33} The page publication date."+ )is_published = graphene.Boolean(required=True)slug = graphene.String(required=True)page_type = graphene.Field(PageType, required=True)@@ -124,6 +132,10 @@ class Page(ModelObjectType):interfaces = [graphene.relay.Node, ObjectWithMetadata]model = models.Page+ @staticmethod+ def resolve_publication_date(root: models.Page, info, **_kwargs):+ return root.published_at+@staticmethoddef resolve_created(root: models.Page, _info):return root.created_atdiff --git a/saleor/graphql/product/mutations/channels.py b/saleor/graphql/product/mutations/channels.pyindex 35b486ddbf..32dbb8ab65 100644--- a/saleor/graphql/product/mutations/channels.py+++ b/saleor/graphql/product/mutations/channels.py@@ -1,8 +1,9 @@-import datetimefrom collections import defaultdict+from datetime import datetimefrom typing import TYPE_CHECKING, DefaultDict, Dict, Listimport graphene+import pytzfrom django.core.exceptions import ValidationErrorfrom django.db import transactionfrom django.db.utils import IntegrityError@@ -10,6 +11,7 @@ from django.db.utils import IntegrityErrorfrom ....checkout.models import CheckoutLinefrom ....core.permissions import ProductPermissionsfrom ....core.tracing import traced_atomic_transaction+from ....core.utils.date_time import convert_to_utc_date_timefrom ....product.error_codes import CollectionErrorCode, ProductErrorCodefrom ....product.models import CollectionChannelListingfrom ....product.models import Product as ProductModel@@ -20,7 +22,12 @@ from ....product.tasks import update_product_discounted_price_taskfrom ...channel import ChannelContextfrom ...channel.mutations import BaseChannelListingMutationfrom ...channel.types import Channel-from ...core.descriptions import ADDED_IN_31, PREVIEW_FEATURE+from ...core.descriptions import (+ ADDED_IN_31,+ ADDED_IN_33,+ DEPRECATED_IN_3X_INPUT,+ PREVIEW_FEATURE,+)from ...core.mutations import BaseMutationfrom ...core.scalars import PositiveDecimalfrom ...core.types import (@@ -46,7 +53,13 @@ class PublishableChannelListingInput(graphene.InputObjectType):description="Determines if object is visible to customers.")publication_date = graphene.types.datetime.Date(- description="Publication date. ISO 8601 standard."+ description=(+ f"Publication date. ISO 8601 standard. {DEPRECATED_IN_3X_INPUT} "+ "Use `publishedAt` field instead."+ )+ )+ published_at = graphene.types.datetime.DateTime(+ description=f"{ADDED_IN_33} Publication date time. ISO 8601 standard.")@@ -64,6 +77,14 @@ class ProductChannelListingAddInput(PublishableChannelListingInput):description=("A start date from which a product will be available for purchase. ""When not set and isAvailable is set to True, "+ f"the current day is assumed. {DEPRECATED_IN_3X_INPUT} "+ "Use `availableForPurchaseAt` field instead."+ )+ )+ available_for_purchase_at = graphene.DateTime(+ description=(+ f"{ADDED_IN_33} A start date time from which a product will be available "+ "for purchase. When not set and `isAvailable` is set to True, ""the current day is assumed."))@@ -112,16 +133,21 @@ class ProductChannelListingUpdate(BaseChannelListingMutation):@classmethoddef clean_available_for_purchase(cls, cleaned_input, errors: ErrorType):- channels_with_invalid_available_for_purchase = []- for update_variant in cleaned_input.get("update_channels", []):- is_available_for_purchase = update_variant.get("is_available_for_purchase")- available_for_purchase_date = update_variant.get(+ channels_with_invalid_available_for_purchase: List[str] = []+ channels_with_invalid_date: List[str] = []+ for update_channel in cleaned_input.get("update_channels", []):+ is_available_for_purchase = update_channel.get("is_available_for_purchase")+ available_for_purchase_date = update_channel.get("available_for_purchase_date"- )+ ) or update_channel.get("available_for_purchase_at")if not is_available_for_purchase and available_for_purchase_date:channels_with_invalid_available_for_purchase.append(- update_variant["channel_id"]+ update_channel["channel_id"])+ channels_with_invalid_date = cls.clean_available_fo_purchase_date(+ update_channel, channels_with_invalid_date+ )+if channels_with_invalid_available_for_purchase:error_msg = ("Cannot set available for purchase date when"@@ -134,6 +160,33 @@ class ProductChannelListingUpdate(BaseChannelListingMutation):params={"channels": channels_with_invalid_available_for_purchase},))+ if channels_with_invalid_date:+ error_msg = (+ "Only one of argument: availableForPurchaseDate or "+ "availableForPurchaseAt must be specified."+ )+ errors["available_for_purchase_date"].append(+ ValidationError(+ error_msg,+ code=ProductErrorCode.INVALID.value,+ params={"channels": channels_with_invalid_date},+ )+ )++ @staticmethod+ def clean_available_fo_purchase_date(+ update_channel_input, channels_with_invalid_date+ ):+ # DEPRECATED+ available_for_purchase_date = update_channel_input.get(+ "available_for_purchase_date"+ )+ available_for_purchase_at = update_channel_input.get(+ "available_for_purchase_at"+ )+ if available_for_purchase_date and available_for_purchase_at:+ channels_with_invalid_date.append(update_channel_input["channel_id"])+ return channels_with_invalid_date@classmethoddef validate_product_without_category(cls, cleaned_input, errors: ErrorType):@@ -165,23 +218,16 @@ class ProductChannelListingUpdate(BaseChannelListingMutation):add_variants = update_channel.get("add_variants", None)remove_variants = update_channel.get("remove_variants", None)defaults = {"currency": channel.currency_code}- for field in ["is_published", "publication_date", "visible_in_listings"]:+ for field in ["is_published", "published_at", "visible_in_listings"]:if field in update_channel.keys():- defaults[field] = update_channel.get(field, None)+ defaults[field] = update_channel[field]is_available_for_purchase = update_channel.get("is_available_for_purchase")- available_for_purchase_date = update_channel.get(- "available_for_purchase_date"- )if is_available_for_purchase is not None:- if is_available_for_purchase is False:- defaults["available_for_purchase"] = None- elif (- is_available_for_purchase is True- and not available_for_purchase_date- ):- defaults["available_for_purchase"] = datetime.date.today()- else:- defaults["available_for_purchase"] = available_for_purchase_date+ defaults[+ "available_for_purchase_at"+ ] = cls.get_available_for_purchase_date(+ is_available_for_purchase, update_channel+ )product_channel_listing, _ = ProductChannelListing.objects.update_or_create(product=product, channel=channel, defaults=defaults)@@ -190,6 +236,20 @@ class ProductChannelListingUpdate(BaseChannelListingMutation):product_channel_listing, product, channel, remove_variants)+ @staticmethod+ def get_available_for_purchase_date(is_available_for_purchase, update_channel):+ available_for_purchase_date = update_channel.get("available_for_purchase_date")+ available_for_purchase_date = (+ convert_to_utc_date_time(available_for_purchase_date)+ if available_for_purchase_date+ else update_channel.get("available_for_purchase_at")+ )+ if is_available_for_purchase is False:+ return None+ elif is_available_for_purchase is True and not available_for_purchase_date:+ return datetime.now(pytz.UTC)+ return available_for_purchase_date+@classmethoddef validate_variants(cls, input, errors):for update_channel in input.get("update_channels", []):@@ -287,7 +347,9 @@ class ProductChannelListingUpdate(BaseChannelListingMutation):ProductErrorCode.DUPLICATED_INPUT_ITEM.value,input_source="update_channels",)- cls.clean_publication_date(cleaned_input, input_source="update_channels")+ cls.clean_publication_date(+ errors, ProductErrorCode, cleaned_input, input_source="update_channels"+ )cls.clean_available_for_purchase(cleaned_input, errors)cls.validate_variants(cleaned_input, errors)if not product.category:@@ -507,9 +569,9 @@ class CollectionChannelListingUpdate(BaseChannelListingMutation):def add_channels(cls, collection: "CollectionModel", add_channels: List[Dict]):for add_channel in add_channels:defaults = {}- for field in ["is_published", "publication_date"]:+ for field in ["is_published", "published_at"]:if field in add_channel.keys():- defaults[field] = add_channel.get(field, None)+ defaults[field] = add_channel[field]CollectionChannelListing.objects.update_or_create(collection=collection, channel=add_channel["channel"], defaults=defaults)@@ -537,7 +599,7 @@ class CollectionChannelListingUpdate(BaseChannelListingMutation):errors,CollectionErrorCode.DUPLICATED_INPUT_ITEM.value,)- cls.clean_publication_date(cleaned_input)+ cls.clean_publication_date(errors, CollectionErrorCode, cleaned_input)if errors:raise ValidationError(errors)diff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.pyindex 2d775c3ae3..0bcc0520e1 100644--- a/saleor/graphql/product/mutations/products.py+++ b/saleor/graphql/product/mutations/products.py@@ -3,6 +3,7 @@ from collections import defaultdictfrom typing import List, Tupleimport graphene+import pytzimport requestsfrom django.core.exceptions import ObjectDoesNotExist, ValidationErrorfrom django.core.files import File@@ -16,6 +17,7 @@ from ....core.exceptions import PreorderAllocationErrorfrom ....core.permissions import ProductPermissions, ProductTypePermissionsfrom ....core.tasks import delete_product_media_taskfrom ....core.tracing import traced_atomic_transaction+from ....core.utils.date_time import convert_to_utc_date_timefrom ....core.utils.editorjs import clean_editor_jsfrom ....core.utils.validators import get_oembed_datafrom ....order import OrderStatus@@ -44,7 +46,7 @@ from ....warehouse.management import deactivate_preorder_for_variantfrom ...attribute.types import AttributeValueInputfrom ...attribute.utils import AttributeAssignmentMixin, AttrValuesInputfrom ...channel import ChannelContext-from ...core.descriptions import ADDED_IN_31, PREVIEW_FEATURE+from ...core.descriptions import ADDED_IN_31, DEPRECATED_IN_3X_INPUT, PREVIEW_FEATUREfrom ...core.fields import JSONStringfrom ...core.inputs import ReorderInputfrom ...core.mutations import BaseMutation, ModelDeleteMutation, ModelMutation@@ -210,7 +212,9 @@ class CollectionInput(graphene.InputObjectType):background_image = Upload(description="Background image file.")background_image_alt = graphene.String(description="Alt text for an image.")seo = SeoInput(description="Search engine optimization fields.")- publication_date = graphene.Date(description="Publication date. ISO 8601 standard.")+ publication_date = graphene.Date(+ description=(f"Publication date. ISO 8601 standard. {DEPRECATED_IN_3X_INPUT}")+ )class CollectionCreateInput(CollectionInput):@@ -252,7 +256,9 @@ class CollectionCreate(ModelMutation):is_published = cleaned_input.get("is_published")publication_date = cleaned_input.get("publication_date")if is_published and not publication_date:- cleaned_input["publication_date"] = datetime.date.today()+ cleaned_input["published_at"] = datetime.datetime.now(pytz.UTC)+ elif publication_date:+ cleaned_input["published_at"] = convert_to_utc_date_time(publication_date)clean_seo_fields(cleaned_input)return cleaned_inputdiff --git a/saleor/graphql/product/sorters.py b/saleor/graphql/product/sorters.pyindex 2631e2d6a0..a0d58094cc 100644--- a/saleor/graphql/product/sorters.py+++ b/saleor/graphql/product/sorters.py@@ -73,19 +73,17 @@ class CollectionSortField(graphene.Enum):NAME = ["name", "slug"]AVAILABILITY = ["is_published", "slug"]PRODUCT_COUNT = ["product_count", "slug"]- PUBLICATION_DATE = ["publication_date", "slug"]+ PUBLICATION_DATE = ["published_at", "slug"]+ PUBLISHED_AT = ["published_at", "slug"]@propertydef description(self):- # pylint: disable=no-member- if self in [- CollectionSortField.NAME,- CollectionSortField.AVAILABILITY,- CollectionSortField.PRODUCT_COUNT,- CollectionSortField.PUBLICATION_DATE,- ]:+ if self.name in CollectionSortField.__enum__._member_names_:sort_name = self.name.lower().replace("_", " ")- return f"Sort collections by {sort_name}."+ description = f"Sort collections by {sort_name}."+ if self.name == "PUBLICATION_DATE":+ description += DEPRECATED_IN_3X_INPUT+ return descriptionraise ValueError("Unsupported enum value: %s" % self.value)@staticmethod@@ -105,13 +103,17 @@ class CollectionSortField(graphene.Enum):@staticmethoddef qs_with_publication_date(queryset: QuerySet, channel_slug: str) -> QuerySet:+ return CollectionSortField.qs_with_published_at(queryset, channel_slug)++ @staticmethod+ def qs_with_published_at(queryset: QuerySet, channel_slug: str) -> QuerySet:subquery = Subquery(CollectionChannelListing.objects.filter(collection_id=OuterRef("pk"), channel__slug=str(channel_slug)- ).values_list("publication_date")[:1]+ ).values_list("published_at")[:1])return queryset.annotate(- publication_date=ExpressionWrapper(subquery, output_field=DateField())+ published_at=ExpressionWrapper(subquery, output_field=DateField()))@@ -130,8 +132,8 @@ class ProductOrderField(graphene.Enum):DATE = ["updated_at", "name", "slug"]TYPE = ["product_type__name", "name", "slug"]PUBLISHED = ["is_published", "name", "slug"]- PUBLICATION_DATE = ["publication_date", "name", "slug"]- PUBLISHED_AT = ["publication_date", "name", "slug"]+ PUBLICATION_DATE = ["published_at", "name", "slug"]+ PUBLISHED_AT = ["published_at", "name", "slug"]LAST_MODIFIED_AT = ["updated_at", "name", "slug"]COLLECTION = ["collectionproduct__sort_order", "pk"]RATING = ["rating", "name", "slug"]@@ -208,10 +210,10 @@ class ProductOrderField(graphene.Enum):subquery = Subquery(ProductChannelListing.objects.filter(product_id=OuterRef("pk"), channel__slug=str(channel_slug)- ).values_list("publication_date")[:1]+ ).values_list("published_at")[:1])return queryset.annotate(- publication_date=ExpressionWrapper(subquery, output_field=DateField())+ published_at=ExpressionWrapper(subquery, output_field=DateField()))@staticmethoddiff --git a/saleor/graphql/product/tests/benchmark/test_product.py b/saleor/graphql/product/tests/benchmark/test_product.pyindex 708f24fffb..e39fb8b465 100644--- a/saleor/graphql/product/tests/benchmark/test_product.py+++ b/saleor/graphql/product/tests/benchmark/test_product.py@@ -257,7 +257,7 @@ def test_retrieve_channel_listings(node {idchannelListings {- publicationDate+ publishedAtisPublishedchannel{slug@@ -283,7 +283,7 @@ def test_retrieve_channel_listings(stop}isAvailableForPurchase- availableForPurchase+ availableForPurchaseAtpricing {priceRangeUndiscounted {start {diff --git a/saleor/graphql/product/tests/deprecated/test_collection_channel_listing_update.py b/saleor/graphql/product/tests/deprecated/test_collection_channel_listing_update.pynew file mode 100644index 0000000000..70f64c2da7--- /dev/null+++ b/saleor/graphql/product/tests/deprecated/test_collection_channel_listing_update.py@@ -0,0 +1,275 @@+import datetime++import graphene+import pytz++from .....product.error_codes import CollectionErrorCode+from ....tests.utils import get_graphql_content++COLLECTION_CHANNEL_LISTING_UPDATE_MUTATION = """+mutation UpdateCollectionChannelListing(+ $id: ID!+ $input: CollectionChannelListingUpdateInput!+) {+ collectionChannelListingUpdate(id: $id, input: $input) {+ errors {+ field+ message+ code+ channels+ }+ collection {+ slug+ channelListings {+ isPublished+ publicationDate+ channel {+ slug+ }+ }+ }+ }+}+"""+++def test_collection_channel_listing_update_as_staff_user(+ staff_api_client,+ published_collection,+ permission_manage_products,+ channel_USD,+ channel_PLN,+):+ # given+ publication_date = datetime.date.today()+ collection_id = graphene.Node.to_global_id("Collection", published_collection.pk)+ channel_id = graphene.Node.to_global_id("Channel", channel_PLN.id)+ variables = {+ "id": collection_id,+ "input": {+ "addChannels": [+ {+ "channelId": channel_id,+ "isPublished": False,+ "publicationDate": publication_date,+ }+ ]+ },+ }++ # when+ response = staff_api_client.post_graphql(+ COLLECTION_CHANNEL_LISTING_UPDATE_MUTATION,+ variables=variables,+ permissions=(permission_manage_products,),+ )+ content = get_graphql_content(response)++ # then+ data = content["data"]["collectionChannelListingUpdate"]+ collection_data = data["collection"]+ collection_channel_listing = published_collection.channel_listings.get(+ channel=channel_USD+ )+ publication_date_usd = collection_channel_listing.published_at+ assert not data["errors"]+ assert collection_data["slug"] == published_collection.slug+ assert collection_data["channelListings"][0]["isPublished"] is True+ assert (+ collection_data["channelListings"][0]["publicationDate"]+ == publication_date_usd.date().isoformat()+ )+ assert collection_data["channelListings"][0]["channel"]["slug"] == channel_USD.slug++ assert collection_data["channelListings"][1]["isPublished"] is False+ assert (+ collection_data["channelListings"][1]["publicationDate"]+ == publication_date.isoformat()+ )+ assert collection_data["channelListings"][1]["channel"]["slug"] == channel_PLN.slug+++def test_collection_channel_listing_update_as_app(+ app_api_client,+ published_collection,+ permission_manage_products,+ channel_USD,+ channel_PLN,+):+ # given+ publication_date = datetime.date.today()+ collection_id = graphene.Node.to_global_id("Collection", published_collection.pk)+ channel_id = graphene.Node.to_global_id("Channel", channel_PLN.id)+ variables = {+ "id": collection_id,+ "input": {+ "addChannels": [+ {+ "channelId": channel_id,+ "isPublished": False,+ "publicationDate": publication_date,+ }+ ]+ },+ }++ # when+ response = app_api_client.post_graphql(+ COLLECTION_CHANNEL_LISTING_UPDATE_MUTATION,+ variables=variables,+ permissions=(permission_manage_products,),+ )+ content = get_graphql_content(response)++ # then+ collection_channel_listing = published_collection.channel_listings.get(+ channel=channel_USD+ )+ publication_date_usd = collection_channel_listing.published_at+ data = content["data"]["collectionChannelListingUpdate"]+ collection_data = data["collection"]+ assert not data["errors"]+ assert collection_data["slug"] == published_collection.slug+ assert collection_data["channelListings"][0]["isPublished"] is True+ assert (+ collection_data["channelListings"][0]["publicationDate"]+ == publication_date_usd.date().isoformat()+ )+ assert collection_data["channelListings"][0]["channel"]["slug"] == channel_USD.slug+ assert collection_data["channelListings"][1]["isPublished"] is False+ assert (+ collection_data["channelListings"][1]["publicationDate"]+ == publication_date.isoformat()+ )+ assert collection_data["channelListings"][1]["channel"]["slug"] == channel_PLN.slug+++def test_collection_channel_listing_update_add_channel(+ staff_api_client,+ published_collection,+ permission_manage_products,+ channel_USD,+ channel_PLN,+):+ # given+ publication_date = datetime.date.today()+ collection_id = graphene.Node.to_global_id("Collection", published_collection.pk)+ channel_id = graphene.Node.to_global_id("Channel", channel_PLN.id)+ variables = {+ "id": collection_id,+ "input": {+ "addChannels": [+ {+ "channelId": channel_id,+ "isPublished": False,+ "publicationDate": publication_date,+ }+ ]+ },+ }++ # when+ response = staff_api_client.post_graphql(+ COLLECTION_CHANNEL_LISTING_UPDATE_MUTATION,+ variables=variables,+ permissions=(permission_manage_products,),+ )+ content = get_graphql_content(response)++ # then+ collection_channel_listing = published_collection.channel_listings.get(+ channel=channel_USD+ )+ publication_date_usd = collection_channel_listing.published_at+ data = content["data"]["collectionChannelListingUpdate"]+ collection_data = data["collection"]+ assert not data["errors"]+ assert collection_data["slug"] == published_collection.slug+ assert collection_data["channelListings"][0]["isPublished"] is True+ assert (+ collection_data["channelListings"][0]["publicationDate"]+ == publication_date_usd.date().isoformat()+ )+ assert collection_data["channelListings"][0]["channel"]["slug"] == channel_USD.slug+ assert collection_data["channelListings"][1]["isPublished"] is False+ assert (+ collection_data["channelListings"][1]["publicationDate"]+ == publication_date.isoformat()+ )+ assert collection_data["channelListings"][1]["channel"]["slug"] == channel_PLN.slug+++def test_collection_channel_listing_update_update_publication_date(+ staff_api_client, collection, permission_manage_products, channel_USD+):+ # given+ publication_date = datetime.date.today()+ collection_id = graphene.Node.to_global_id("Collection", collection.pk)+ channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)+ variables = {+ "id": collection_id,+ "input": {+ "addChannels": [+ {"channelId": channel_id, "publicationDate": publication_date}+ ]+ },+ }++ # when+ response = staff_api_client.post_graphql(+ COLLECTION_CHANNEL_LISTING_UPDATE_MUTATION,+ variables=variables,+ permissions=(permission_manage_products,),+ )+ content = get_graphql_content(response)++ # then+ data = content["data"]["collectionChannelListingUpdate"]+ collection_data = data["collection"]+ assert not data["errors"]+ assert collection_data["slug"] == collection.slug+ assert (+ collection_data["channelListings"][0]["publicationDate"]+ == publication_date.isoformat()+ )+ assert collection_data["channelListings"][0]["channel"]["slug"] == channel_USD.slug+++def test_collection_channel_listing_update_update_publication_date_and_published_at(+ staff_api_client, collection, permission_manage_products, channel_USD+):+ """Ensure an error is raised when both publicationDate and publishedAt date+ is given."""+ # given+ publication_date = datetime.date.today()+ published_at = datetime.datetime.now(pytz.utc)+ collection_id = graphene.Node.to_global_id("Collection", collection.pk)+ channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)+ variables = {+ "id": collection_id,+ "input": {+ "addChannels": [+ {+ "channelId": channel_id,+ "publicationDate": publication_date,+ "publishedAt": published_at,+ }+ ]+ },+ }++ # when+ response = staff_api_client.post_graphql(+ COLLECTION_CHANNEL_LISTING_UPDATE_MUTATION,+ variables=variables,+ permissions=(permission_manage_products,),+ )+ content = get_graphql_content(response)++ # then+ data = content["data"]["collectionChannelListingUpdate"]+ errors = data["errors"]+ assert len(errors) == 1+ assert errors[0]["field"] == "publicationDate"+ assert errors[0]["code"] == CollectionErrorCode.INVALID.name+ assert errors[0]["channels"] == [channel_id]diff --git a/saleor/graphql/product/tests/deprecated/test_collection_sorting.py b/saleor/graphql/product/tests/deprecated/test_collection_sorting.pynew file mode 100644index 0000000000..16b76df78f--- /dev/null+++ b/saleor/graphql/product/tests/deprecated/test_collection_sorting.py@@ -0,0 +1,258 @@+import datetime++import pytest+import pytz++from .....product.models import Collection, CollectionChannelListing+from ....tests.utils import assert_graphql_error_with_message, get_graphql_content+++def collections_for_sorting_with_channels(channel_USD, channel_PLN):+ collections = Collection.objects.bulk_create(+ [+ Collection(name="Collection1", slug="collection1"),+ Collection(name="Collection2", slug="collection2"),+ Collection(name="Collection3", slug="collection3"),+ Collection(name="Collection4", slug="collection4"),+ Collection(name="Collection5", slug="collection5"),+ ]+ )+ CollectionChannelListing.objects.bulk_create(+ [+ CollectionChannelListing(+ collection=collections[0],+ published_at=None,+ is_published=True,+ channel=channel_USD,+ ),+ CollectionChannelListing(+ collection=collections[1],+ published_at=None,+ is_published=False,+ channel=channel_USD,+ ),+ CollectionChannelListing(+ collection=collections[2],+ published_at=datetime.datetime(2004, 1, 1, tzinfo=pytz.UTC),+ is_published=False,+ channel=channel_USD,+ ),+ CollectionChannelListing(+ collection=collections[3],+ published_at=datetime.datetime(2003, 1, 1, tzinfo=pytz.UTC),+ is_published=False,+ channel=channel_USD,+ ),+ # second channel+ CollectionChannelListing(+ collection=collections[0],+ published_at=None,+ is_published=False,+ channel=channel_PLN,+ ),+ CollectionChannelListing(+ collection=collections[1],+ published_at=None,+ is_published=True,+ channel=channel_PLN,+ ),+ CollectionChannelListing(+ collection=collections[2],+ published_at=datetime.datetime(2002, 1, 1, tzinfo=pytz.UTC),+ is_published=False,+ channel=channel_PLN,+ ),+ CollectionChannelListing(+ collection=collections[4],+ published_at=datetime.datetime(2001, 1, 1, tzinfo=pytz.UTC),+ is_published=False,+ channel=channel_PLN,+ ),+ ]+ )+++QUERY_COLLECTIONS_WITH_SORTING_AND_FILTERING = """+ query (+ $sortBy: CollectionSortingInput,+ $filter: CollectionFilterInput, $channel: String+ ){+ collections (+ first: 10, sortBy: $sortBy, filter: $filter, channel: $channel+ ) {+ edges {+ node {+ name+ slug+ }+ }+ }+ }+"""+++ "sort_by",+ [+ {"field": "AVAILABILITY", "direction": "ASC"},+ {"field": "PUBLICATION_DATE", "direction": "DESC"},+ ],+)+def test_collections_with_sorting_and_without_channel(+ sort_by,+ staff_api_client,+ permission_manage_products,+):+ # given+ variables = {"sortBy": sort_by}++ # when+ response = staff_api_client.post_graphql(+ QUERY_COLLECTIONS_WITH_SORTING_AND_FILTERING,+ variables,+ permissions=[permission_manage_products],+ check_no_permissions=False,+ )++ # then+ assert_graphql_error_with_message(response, "A default channel does not exist.")+++ "sort_by, collections_order",+ [+ (+ {"field": "PUBLICATION_DATE", "direction": "ASC"},+ ["Collection4", "Collection3", "Collection1", "Collection2"],+ ),+ (+ {"field": "PUBLICATION_DATE", "direction": "DESC"},+ ["Collection2", "Collection1", "Collection3", "Collection4"],+ ),+ ],+)+def test_collections_with_sorting_and_channel_USD(+ sort_by,+ collections_order,+ staff_api_client,+ permission_manage_products,+ collections_for_sorting_with_channels,+ channel_USD,+):+ # given+ variables = {"sortBy": sort_by, "channel": channel_USD.slug}++ # when+ response = staff_api_client.post_graphql(+ QUERY_COLLECTIONS_WITH_SORTING_AND_FILTERING,+ variables,+ permissions=[permission_manage_products],+ check_no_permissions=False,+ )++ # then+ content = get_graphql_content(response)+ collections_nodes = content["data"]["collections"]["edges"]+ for index, collection_name in enumerate(collections_order):+ assert collection_name == collections_nodes[index]["node"]["name"]+++ "sort_by, collections_order",+ [+ (+ {"field": "PUBLICATION_DATE", "direction": "ASC"},+ ["Collection5", "Collection3", "Collection1", "Collection2"],+ ),+ (+ {"field": "PUBLICATION_DATE", "direction": "DESC"},+ ["Collection2", "Collection1", "Collection3", "Collection5"],+ ),+ ],+)+def test_collections_with_sorting_and_channel_PLN(+ sort_by,+ collections_order,+ staff_api_client,+ permission_manage_products,+ collections_for_sorting_with_channels,+ channel_PLN,+):+ # given+ variables = {"sortBy": sort_by, "channel": channel_PLN.slug}++ # when+ response = staff_api_client.post_graphql(+ QUERY_COLLECTIONS_WITH_SORTING_AND_FILTERING,+ variables,+ permissions=[permission_manage_products],+ check_no_permissions=False,+ )++ # then+ content = get_graphql_content(response)+ collections_nodes = content["data"]["collections"]["edges"]++ for index, collection_name in enumerate(collections_order):+ assert collection_name == collections_nodes[index]["node"]["name"]+++ "sort_by",+ [+ {"field": "AVAILABILITY", "direction": "ASC"},+ {"field": "PUBLICATION_DATE", "direction": "ASC"},+ ],+)+def test_collections_with_sorting_and_not_existing_channel_asc(+ sort_by,+ staff_api_client,+ permission_manage_products,+ collections_for_sorting_with_channels,+ channel_USD,+):+ # given+ variables = {"sortBy": sort_by, "channel": "Not-existing"}++ # when+ response = staff_api_client.post_graphql(+ QUERY_COLLECTIONS_WITH_SORTING_AND_FILTERING,+ variables,+ permissions=[permission_manage_products],+ check_no_permissions=False,+ )++ # then+ content = get_graphql_content(response)+ assert not content["data"]["collections"]["edges"]+++ "sort_by",+ [+ {"field": "AVAILABILITY", "direction": "DESC"},+ {"field": "PUBLICATION_DATE", "direction": "DESC"},+ ],+)+def test_collections_with_sorting_and_not_existing_channel_desc(+ sort_by,+ staff_api_client,+ permission_manage_products,+ collections_for_sorting_with_channels,+ channel_USD,+):+ # given+ variables = {"sortBy": sort_by, "channel": "Not-existing"}++ # when+ response = staff_api_client.post_graphql(+ QUERY_COLLECTIONS_WITH_SORTING_AND_FILTERING,+ variables,+ permissions=[permission_manage_products],+ check_no_permissions=False,+ )++ # then+ content = get_graphql_content(response)+ assert not content["data"]["collections"]["edges"]diff --git a/saleor/graphql/product/tests/deprecated/test_product.py b/saleor/graphql/product/tests/deprecated/test_product.pyindex 8223a09469..1fbf7bb283 100644--- a/saleor/graphql/product/tests/deprecated/test_product.py+++ b/saleor/graphql/product/tests/deprecated/test_product.py@@ -111,7 +111,7 @@ def test_fetch_all_products(user_api_client, product):assert product_data["isAvailable"] is Trueassert product_data["isAvailableForPurchase"] is Trueassert product_data["availableForPurchase"] == str(- product_channel_listing.available_for_purchase+ product_channel_listing.available_for_purchase_at.date())assert len(content["data"]["products"]["edges"]) == num_productsassert any(diff --git a/saleor/graphql/product/tests/deprecated/test_product_channel_listing_update.py b/saleor/graphql/product/tests/deprecated/test_product_channel_listing_update.pynew file mode 100644index 0000000000..8d1b181572--- /dev/null+++ b/saleor/graphql/product/tests/deprecated/test_product_channel_listing_update.py@@ -0,0 +1,481 @@+import datetime+from unittest.mock import patch++import graphene+import pytz++from .....product.error_codes import ProductErrorCode+from .....product.utils.costs import get_product_costs_data+from ....tests.utils import get_graphql_content++PRODUCT_CHANNEL_LISTING_UPDATE_MUTATION = """+mutation UpdateProductChannelListing(+ $id: ID!+ $input: ProductChannelListingUpdateInput!+) {+ productChannelListingUpdate(id: $id, input: $input) {+ errors {+ field+ message+ code+ channels+ variants+ }+ product {+ slug+ channelListings {+ isPublished+ publicationDate+ visibleInListings+ channel {+ slug+ }+ purchaseCost {+ start {+ amount+ }+ stop {+ amount+ }+ }+ margin {+ start+ stop+ }+ isAvailableForPurchase+ availableForPurchase+ }+ variants {+ channelListings {+ channel {+ slug+ }+ }+ }+ }+ }+}+"""+++def test_product_channel_listing_update_as_staff_user(+ staff_api_client, product, permission_manage_products, channel_USD, channel_PLN+):+ # given+ publication_date = datetime.date.today()+ product_id = graphene.Node.to_global_id("Product", product.pk)+ channel_id = graphene.Node.to_global_id("Channel", channel_PLN.id)+ available_for_purchase_date = datetime.date(2007, 1, 1)+ variables = {+ "id": product_id,+ "input": {+ "updateChannels": [+ {+ "channelId": channel_id,+ "isPublished": False,+ "publicationDate": publication_date,+ "visibleInListings": True,+ "isAvailableForPurchase": True,+ "availableForPurchaseDate": available_for_purchase_date,+ }+ ]+ },+ }++ # when+ response = staff_api_client.post_graphql(+ PRODUCT_CHANNEL_LISTING_UPDATE_MUTATION,+ variables=variables,+ permissions=(permission_manage_products,),+ )+ content = get_graphql_content(response)++ # then+ data = content["data"]["productChannelListingUpdate"]+ product_data = data["product"]++ variant = product.variants.first()+ variant_channel_listing = variant.channel_listings.filter(channel_id=channel_USD.id)+ purchase_cost, margin = get_product_costs_data(+ variant_channel_listing, True, channel_USD.currency_code+ )+ assert not data["errors"]+ assert product_data["slug"] == product.slug+ assert product_data["channelListings"][0]["isPublished"] is True+ assert product_data["channelListings"][0]["publicationDate"] is None+ assert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slug+ assert product_data["channelListings"][0]["visibleInListings"] is True+ assert product_data["channelListings"][0]["isAvailableForPurchase"] is True+ assert (+ product_data["channelListings"][0]["availableForPurchase"]+ == datetime.date(1999, 1, 1).isoformat()+ )+ cost_start = product_data["channelListings"][0]["purchaseCost"]["start"]["amount"]+ cost_stop = product_data["channelListings"][0]["purchaseCost"]["stop"]["amount"]++ assert purchase_cost.start.amount == cost_start+ assert purchase_cost.stop.amount == cost_stop+ assert margin[0] == product_data["channelListings"][0]["margin"]["start"]+ assert margin[1] == product_data["channelListings"][0]["margin"]["stop"]+ assert product_data["channelListings"][1]["isPublished"] is False+ assert (+ product_data["channelListings"][1]["publicationDate"]+ == publication_date.isoformat()+ )+ assert product_data["channelListings"][1]["visibleInListings"] is True+ assert product_data["channelListings"][1]["channel"]["slug"] == channel_PLN.slug+ assert product_data["channelListings"][1]["isAvailableForPurchase"] is True+ assert (+ product_data["channelListings"][1]["availableForPurchase"]+ == available_for_purchase_date.isoformat()+ )+++@patch("saleor.plugins.manager.PluginsManager.product_updated")+def test_product_channel_listing_update_trigger_webhook_product_updated(+ mock_product_updated,+ staff_api_client,+ product,+ permission_manage_products,+ channel_USD,+ channel_PLN,+):+ # given+ publication_date = datetime.date.today()+ product_id = graphene.Node.to_global_id("Product", product.pk)+ channel_id = graphene.Node.to_global_id("Channel", channel_PLN.id)+ available_for_purchase_date = datetime.date(2007, 1, 1)+ variables = {+ "id": product_id,+ "input": {+ "updateChannels": [+ {+ "channelId": channel_id,+ "isPublished": False,+ "publicationDate": publication_date,+ "visibleInListings": True,+ "isAvailableForPurchase": True,+ "availableForPurchaseDate": available_for_purchase_date,+ }+ ]+ },+ }++ # when+ response = staff_api_client.post_graphql(+ PRODUCT_CHANNEL_LISTING_UPDATE_MUTATION,+ variables=variables,+ permissions=(permission_manage_products,),+ )+ get_graphql_content(response)++ # then+ mock_product_updated.assert_called_once_with(product)+++def test_product_channel_listing_update_add_channel(+ staff_api_client, product, permission_manage_products, channel_USD, channel_PLN+):+ # given+ publication_date = datetime.date.today()+ product_id = graphene.Node.to_global_id("Product", product.pk)+ channel_id = graphene.Node.to_global_id("Channel", channel_PLN.id)+ available_for_purchase_date = datetime.date(2007, 1, 1)+ variables = {+ "id": product_id,+ "input": {+ "updateChannels": [+ {+ "channelId": channel_id,+ "isPublished": False,+ "publicationDate": publication_date,+ "visibleInListings": True,+ "isAvailableForPurchase": True,+ "availableForPurchaseDate": available_for_purchase_date,+ }+ ]+ },+ }++ # when+ response = staff_api_client.post_graphql(+ PRODUCT_CHANNEL_LISTING_UPDATE_MUTATION,+ variables=variables,+ permissions=(permission_manage_products,),+ )+ content = get_graphql_content(response)++ # then+ data = content["data"]["productChannelListingUpdate"]+ product_data = data["product"]+ assert not data["errors"]+ assert product_data["slug"] == product.slug+ assert product_data["channelListings"][0]["isPublished"] is True+ assert product_data["channelListings"][0]["publicationDate"] is None+ assert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slug+ assert product_data["channelListings"][1]["isPublished"] is False+ assert (+ product_data["channelListings"][1]["publicationDate"]+ == publication_date.isoformat()+ )+ assert product_data["channelListings"][1]["channel"]["slug"] == channel_PLN.slug+ assert product_data["channelListings"][1]["visibleInListings"] is True+ assert product_data["channelListings"][1]["isAvailableForPurchase"] is True+ assert (+ product_data["channelListings"][1]["availableForPurchase"]+ == available_for_purchase_date.isoformat()+ )+++def test_product_channel_listing_update_update_publication_data(+ staff_api_client, product, permission_manage_products, channel_USD+):+ # given+ publication_date = datetime.date.today()+ product_id = graphene.Node.to_global_id("Product", product.pk)+ channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)+ variables = {+ "id": product_id,+ "input": {+ "updateChannels": [+ {+ "channelId": channel_id,+ "isPublished": False,+ "publicationDate": publication_date,+ }+ ]+ },+ }++ # when+ response = staff_api_client.post_graphql(+ PRODUCT_CHANNEL_LISTING_UPDATE_MUTATION,+ variables=variables,+ permissions=(permission_manage_products,),+ )+ content = get_graphql_content(response)++ # then+ data = content["data"]["productChannelListingUpdate"]+ product_data = data["product"]+ assert not data["errors"]+ assert product_data["slug"] == product.slug+ assert product_data["channelListings"][0]["isPublished"] is False+ assert (+ product_data["channelListings"][0]["publicationDate"]+ == publication_date.isoformat()+ )+ assert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slug+ assert product_data["channelListings"][0]["visibleInListings"] is True+ assert product_data["channelListings"][0]["isAvailableForPurchase"] is True+ assert (+ product_data["channelListings"][0]["availableForPurchase"]+ == datetime.date(1999, 1, 1).isoformat()+ )+++def test_product_channel_listing_update_update_publication_date_and_published_at(+ staff_api_client, product, permission_manage_products, channel_USD+):+ """Ensure an error is raised when both publicationDate and publishedAt date+ is given."""+ # given+ publication_date = datetime.date.today()+ published_at = datetime.datetime.now(pytz.utc)+ product_id = graphene.Node.to_global_id("Product", product.pk)+ channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)+ variables = {+ "id": product_id,+ "input": {+ "updateChannels": [+ {+ "channelId": channel_id,+ "isPublished": False,+ "publicationDate": publication_date,+ "publishedAt": published_at,+ }+ ]+ },+ }++ # when+ response = staff_api_client.post_graphql(+ PRODUCT_CHANNEL_LISTING_UPDATE_MUTATION,+ variables=variables,+ permissions=(permission_manage_products,),+ )++ # then+ content = get_graphql_content(response)+ data = content["data"]["productChannelListingUpdate"]+ errors = data["errors"]+ assert len(errors) == 1+ assert errors[0]["field"] == "publicationDate"+ assert errors[0]["code"] == ProductErrorCode.INVALID.name+ assert errors[0]["channels"] == [channel_id]+++def test_product_channel_listing_update_update_is_available_for_purchase_past_date(+ staff_api_client, product, permission_manage_products, channel_USD+):+ # given+ product_id = graphene.Node.to_global_id("Product", product.pk)+ channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)+ available_for_purchase_date = datetime.date(2007, 1, 1)+ variables = {+ "id": product_id,+ "input": {+ "updateChannels": [+ {+ "channelId": channel_id,+ "isAvailableForPurchase": True,+ "availableForPurchaseDate": available_for_purchase_date,+ }+ ]+ },+ }++ # when+ response = staff_api_client.post_graphql(+ PRODUCT_CHANNEL_LISTING_UPDATE_MUTATION,+ variables=variables,+ permissions=(permission_manage_products,),+ )+ content = get_graphql_content(response)++ # then+ data = content["data"]["productChannelListingUpdate"]+ product_data = data["product"]+ assert not data["errors"]+ assert product_data["slug"] == product.slug+ assert product_data["channelListings"][0]["isPublished"] is True+ assert not product_data["channelListings"][0]["publicationDate"]+ assert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slug+ assert product_data["channelListings"][0]["visibleInListings"] is True+ assert product_data["channelListings"][0]["isAvailableForPurchase"] is True+ assert (+ product_data["channelListings"][0]["availableForPurchase"]+ == available_for_purchase_date.isoformat()+ )+++def test_product_channel_listing_update_update_is_available_for_purchase_future_date(+ staff_api_client, product, permission_manage_products, channel_USD+):+ # given+ product_id = graphene.Node.to_global_id("Product", product.pk)+ channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)+ available_for_purchase_date = datetime.date.today() + datetime.timedelta(days=1)+ variables = {+ "id": product_id,+ "input": {+ "updateChannels": [+ {+ "channelId": channel_id,+ "isAvailableForPurchase": True,+ "availableForPurchaseDate": available_for_purchase_date,+ }+ ]+ },+ }++ # when+ response = staff_api_client.post_graphql(+ PRODUCT_CHANNEL_LISTING_UPDATE_MUTATION,+ variables=variables,+ permissions=(permission_manage_products,),+ )+ content = get_graphql_content(response)++ # then+ data = content["data"]["productChannelListingUpdate"]+ product_data = data["product"]+ assert not data["errors"]+ assert product_data["slug"] == product.slug+ assert product_data["channelListings"][0]["isPublished"] is True+ assert not product_data["channelListings"][0]["publicationDate"]+ assert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slug+ assert product_data["channelListings"][0]["visibleInListings"] is True+ assert product_data["channelListings"][0]["isAvailableForPurchase"] is False+ assert (+ product_data["channelListings"][0]["availableForPurchase"]+ == available_for_purchase_date.isoformat()+ )+++def test_product_channel_listing_update_update_is_available_for_purchase_false_and_date(+ staff_api_client, product, permission_manage_products, channel_USD+):+ # given+ product_id = graphene.Node.to_global_id("Product", product.pk)+ channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)+ available_for_purchase_date = datetime.date.today() + datetime.timedelta(days=1)+ variables = {+ "id": product_id,+ "input": {+ "updateChannels": [+ {+ "channelId": channel_id,+ "isAvailableForPurchase": False,+ "availableForPurchaseDate": available_for_purchase_date,+ }+ ]+ },+ }++ # when+ response = staff_api_client.post_graphql(+ PRODUCT_CHANNEL_LISTING_UPDATE_MUTATION,+ variables=variables,+ permissions=(permission_manage_products,),+ )+ content = get_graphql_content(response)++ # then+ data = content["data"]["productChannelListingUpdate"]+ errors = data["errors"]+ assert errors[0]["field"] == "availableForPurchaseDate"+ assert errors[0]["code"] == ProductErrorCode.INVALID.name+ assert errors[0]["channels"] == [channel_id]+ assert len(errors) == 1+++def test_product_channel_listing_update_available_for_purchase_both_date_value_given(+ staff_api_client, product, permission_manage_products, channel_USD+):+ """Ensure an error is raised when both availableForPurchaseDate and+ availableForPurchaseAt date is given."""+ # given+ available_for_purchase_date = datetime.date.today()+ available_for_purchase_at = datetime.datetime.now(pytz.utc)+ product_id = graphene.Node.to_global_id("Product", product.pk)+ channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)+ variables = {+ "id": product_id,+ "input": {+ "updateChannels": [+ {+ "channelId": channel_id,+ "isAvailableForPurchase": True,+ "availableForPurchaseDate": available_for_purchase_date,+ "availableForPurchaseAt": available_for_purchase_at,+ }+ ]+ },+ }++ # when+ response = staff_api_client.post_graphql(+ PRODUCT_CHANNEL_LISTING_UPDATE_MUTATION,+ variables=variables,+ permissions=(permission_manage_products,),+ )++ # then+ content = get_graphql_content(response)+ data = content["data"]["productChannelListingUpdate"]+ errors = data["errors"]+ assert len(errors) == 1+ assert errors[0]["field"] == "availableForPurchaseDate"+ assert errors[0]["code"] == ProductErrorCode.INVALID.name+ assert errors[0]["channels"] == [channel_id]diff --git a/saleor/graphql/product/tests/deprecated/test_product_sorting.py b/saleor/graphql/product/tests/deprecated/test_product_sorting.pynew file mode 100644index 0000000000..eb2051dad9--- /dev/null+++ b/saleor/graphql/product/tests/deprecated/test_product_sorting.py@@ -0,0 +1,98 @@+from datetime import timedelta++import graphene+import pytest+from django.utils import timezone+from freezegun import freeze_time++from .....product.models import ProductChannelListing+from ....tests.utils import assert_graphql_error_with_message, get_graphql_content++GET_SORTED_PRODUCTS_QUERY = """+query Products($sortBy: ProductOrder, $channel: String) {+ products(first: 10, sortBy: $sortBy, channel: $channel) {+ edges {+ node {+ id+ }+ }+ }+}+"""+++@freeze_time("2020-03-18 12:00:00")+ "direction, order_direction",+ (("ASC", "publication_date"), ("DESC", "-publication_date")),+)+def test_sort_products_by_publication_date(+ direction, order_direction, api_client, product_list, channel_USD+):+ product_channel_listings = []+ for iter_value, product in enumerate(product_list):+ product_channel_listing = product.channel_listings.get(channel=channel_USD)+ product_channel_listing.published_at = timezone.now() - timedelta(+ days=iter_value+ )+ product_channel_listings.append(product_channel_listing)+ ProductChannelListing.objects.bulk_update(+ product_channel_listings, ["published_at"]+ )++ variables = {+ "sortBy": {+ "direction": direction,+ "field": "PUBLICATION_DATE",+ },+ "channel": channel_USD.slug,+ }++ # when+ response = api_client.post_graphql(GET_SORTED_PRODUCTS_QUERY, variables)++ # then+ content = get_graphql_content(response)+ data = content["data"]["products"]["edges"]++ if direction == "ASC":+ product_list.reverse()++ assert [node["node"]["id"] for node in data] == [+ graphene.Node.to_global_id("Product", product.pk) for product in product_list+ ]+++QUERY_PRODUCTS_WITH_SORTING_AND_FILTERING = """+ query ($sortBy: ProductOrder, $filter: ProductFilterInput, $channel: String){+ products (+ first: 10, sortBy: $sortBy, filter: $filter, channel: $channel+ ) {+ edges {+ node {+ name+ slug+ }+ }+ }+ }+"""+++def test_products_with_sorting_and_without_channel(+ staff_api_client,+ permission_manage_products,+):+ # given+ variables = {"sortBy": {"field": "PUBLICATION_DATE", "direction": "DESC"}}++ # when+ response = staff_api_client.post_graphql(+ QUERY_PRODUCTS_WITH_SORTING_AND_FILTERING,+ variables,+ permissions=[permission_manage_products],+ check_no_permissions=False,+ )++ # then+ assert_graphql_error_with_message(response, "A default channel does not exist.")diff --git a/saleor/graphql/product/tests/test_bulk_delete.py b/saleor/graphql/product/tests/test_bulk_delete.pyindex d1e7054bd6..723ed8fdaa 100644--- a/saleor/graphql/product/tests/test_bulk_delete.py+++ b/saleor/graphql/product/tests/test_bulk_delete.py@@ -221,7 +221,7 @@ def test_delete_categories_with_subcategories_and_products(product=parent_product,channel=channel_PLN,is_published=True,- publication_date=timezone.now(),+ published_at=timezone.now(),),])@@ -263,7 +263,7 @@ def test_delete_categories_with_subcategories_and_products()for product_channel_listing in product_channel_listings:assert product_channel_listing.is_published is False- assert not product_channel_listing.publication_date+ assert not product_channel_listing.published_atassert product_channel_listings.count() == 3diff --git a/saleor/graphql/product/tests/test_category.py b/saleor/graphql/product/tests/test_category.pyindex 67e94313cb..8467c718c0 100644--- a/saleor/graphql/product/tests/test_category.py+++ b/saleor/graphql/product/tests/test_category.py@@ -1081,7 +1081,7 @@ def test_category_delete_mutation_for_categories_tree()for product_channel_listing in product_channel_listings:assert product_channel_listing.is_published is False- assert not product_channel_listing.publication_date+ assert not product_channel_listing.published_atassert product_channel_listings.count() == 4@@ -1118,7 +1118,7 @@ def test_category_delete_mutation_for_children_from_categories_tree()for product_channel_listing in product_channel_listings:assert product_channel_listing.is_published is True- assert product_channel_listing.publication_date+ assert product_channel_listing.published_atchild_product.refresh_from_db()assert not child_product.category@@ -1127,7 +1127,7 @@ def test_category_delete_mutation_for_children_from_categories_tree()for product_channel_listing in product_channel_listings:assert product_channel_listing.is_published is False- assert not product_channel_listing.publication_date+ assert not product_channel_listing.published_atLEVELED_CATEGORIES_QUERY = """diff --git a/saleor/graphql/product/tests/test_collection_channel_listing_update.py b/saleor/graphql/product/tests/test_collection_channel_listing_update.pyindex 00e7927e99..980b02da2d 100644--- a/saleor/graphql/product/tests/test_collection_channel_listing_update.py+++ b/saleor/graphql/product/tests/test_collection_channel_listing_update.py@@ -1,6 +1,7 @@import datetimeimport graphene+import pytzfrom freezegun import freeze_timefrom ....product.error_codes import CollectionErrorCode@@ -22,7 +23,7 @@ mutation UpdateCollectionChannelListing(slugchannelListings {isPublished- publicationDate+ publishedAtchannel {slug}@@ -176,7 +177,7 @@ def test_collection_channel_listing_update_as_staff_user(channel_PLN,):# given- publication_date = datetime.date.today()+ publication_date = datetime.datetime.now(pytz.utc).replace(microsecond=0)collection_id = graphene.Node.to_global_id("Collection", published_collection.pk)channel_id = graphene.Node.to_global_id("Channel", channel_PLN.id)variables = {@@ -186,7 +187,7 @@ def test_collection_channel_listing_update_as_staff_user({"channelId": channel_id,"isPublished": False,- "publicationDate": publication_date,+ "publishedAt": publication_date,}]},@@ -206,18 +207,19 @@ def test_collection_channel_listing_update_as_staff_user(collection_channel_listing = published_collection.channel_listings.get(channel=channel_USD)- publication_date_usd = collection_channel_listing.publication_date.isoformat()+ publication_date_usd = collection_channel_listing.published_atassert not data["errors"]assert collection_data["slug"] == published_collection.slugassert collection_data["channelListings"][0]["isPublished"] is Trueassert (- collection_data["channelListings"][0]["publicationDate"] == publication_date_usd+ collection_data["channelListings"][0]["publishedAt"]+ == publication_date_usd.isoformat())assert collection_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugassert collection_data["channelListings"][1]["isPublished"] is Falseassert (- collection_data["channelListings"][1]["publicationDate"]+ collection_data["channelListings"][1]["publishedAt"]== publication_date.isoformat())assert collection_data["channelListings"][1]["channel"]["slug"] == channel_PLN.slug@@ -231,7 +233,7 @@ def test_collection_channel_listing_update_as_app(channel_PLN,):# given- publication_date = datetime.date.today()+ publication_date = datetime.datetime.now(pytz.utc).replace(microsecond=0)collection_id = graphene.Node.to_global_id("Collection", published_collection.pk)channel_id = graphene.Node.to_global_id("Channel", channel_PLN.id)variables = {@@ -241,7 +243,7 @@ def test_collection_channel_listing_update_as_app({"channelId": channel_id,"isPublished": False,- "publicationDate": publication_date,+ "publishedAt": publication_date,}]},@@ -259,19 +261,20 @@ def test_collection_channel_listing_update_as_app(collection_channel_listing = published_collection.channel_listings.get(channel=channel_USD)- publication_date_usd = collection_channel_listing.publication_date.isoformat()+ publication_date_usd = collection_channel_listing.published_atdata = content["data"]["collectionChannelListingUpdate"]collection_data = data["collection"]assert not data["errors"]assert collection_data["slug"] == published_collection.slugassert collection_data["channelListings"][0]["isPublished"] is Trueassert (- collection_data["channelListings"][0]["publicationDate"] == publication_date_usd+ collection_data["channelListings"][0]["publishedAt"]+ == publication_date_usd.isoformat())assert collection_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugassert collection_data["channelListings"][1]["isPublished"] is Falseassert (- collection_data["channelListings"][1]["publicationDate"]+ collection_data["channelListings"][1]["publishedAt"]== publication_date.isoformat())assert collection_data["channelListings"][1]["channel"]["slug"] == channel_PLN.slug@@ -325,7 +328,7 @@ def test_collection_channel_listing_update_add_channel(channel_PLN,):# given- publication_date = datetime.date.today()+ publication_date = datetime.datetime.now(pytz.utc).replace(microsecond=0)collection_id = graphene.Node.to_global_id("Collection", published_collection.pk)channel_id = graphene.Node.to_global_id("Channel", channel_PLN.id)variables = {@@ -335,7 +338,7 @@ def test_collection_channel_listing_update_add_channel({"channelId": channel_id,"isPublished": False,- "publicationDate": publication_date,+ "publishedAt": publication_date,}]},@@ -353,19 +356,20 @@ def test_collection_channel_listing_update_add_channel(collection_channel_listing = published_collection.channel_listings.get(channel=channel_USD)- publication_date_usd = collection_channel_listing.publication_date.isoformat()+ publication_date_usd = collection_channel_listing.published_atdata = content["data"]["collectionChannelListingUpdate"]collection_data = data["collection"]assert not data["errors"]assert collection_data["slug"] == published_collection.slugassert collection_data["channelListings"][0]["isPublished"] is Trueassert (- collection_data["channelListings"][0]["publicationDate"] == publication_date_usd+ collection_data["channelListings"][0]["publishedAt"]+ == publication_date_usd.isoformat())assert collection_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugassert collection_data["channelListings"][1]["isPublished"] is Falseassert (- collection_data["channelListings"][1]["publicationDate"]+ collection_data["channelListings"][1]["publishedAt"]== publication_date.isoformat())assert collection_data["channelListings"][1]["channel"]["slug"] == channel_PLN.slug@@ -390,7 +394,7 @@ def test_collection_channel_listing_update_unpublished()content = get_graphql_content(response)collection_channel_listing = published_collection.channel_listings.get()- publication_date_usd = collection_channel_listing.publication_date.isoformat()+ publication_date_usd = collection_channel_listing.published_at# thendata = content["data"]["collectionChannelListingUpdate"]@@ -399,7 +403,8 @@ def test_collection_channel_listing_update_unpublished(assert collection_data["slug"] == published_collection.slugassert collection_data["channelListings"][0]["isPublished"] is Falseassert (- collection_data["channelListings"][0]["publicationDate"] == publication_date_usd+ collection_data["channelListings"][0]["publishedAt"]+ == publication_date_usd.isoformat())assert collection_data["channelListings"][0]["channel"]["slug"] == channel_USD.slug@@ -408,15 +413,13 @@ def test_collection_channel_listing_update_update_publication_date(staff_api_client, collection, permission_manage_products, channel_USD):# given- publication_date = datetime.date.today()+ publication_date = datetime.datetime.now(pytz.utc).replace(microsecond=0)collection_id = graphene.Node.to_global_id("Collection", collection.pk)channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)variables = {"id": collection_id,"input": {- "addChannels": [- {"channelId": channel_id, "publicationDate": publication_date}- ]+ "addChannels": [{"channelId": channel_id, "publishedAt": publication_date}]},}@@ -434,7 +437,7 @@ def test_collection_channel_listing_update_update_publication_date(assert not data["errors"]assert collection_data["slug"] == collection.slugassert (- collection_data["channelListings"][0]["publicationDate"]+ collection_data["channelListings"][0]["publishedAt"]== publication_date.isoformat())assert collection_data["channelListings"][0]["channel"]["slug"] == channel_USD.slug@@ -467,13 +470,16 @@ def test_collection_channel_listing_update_remove_not_assigned_channel(collection_channel_listing = published_collection.channel_listings.get(channel=channel_USD)- publication_date = collection_channel_listing.publication_date.isoformat()+ publication_date = collection_channel_listing.published_atdata = content["data"]["collectionChannelListingUpdate"]collection_data = data["collection"]assert not data["errors"]assert collection_data["slug"] == published_collection.slugassert collection_data["channelListings"][0]["isPublished"] is True- assert collection_data["channelListings"][0]["publicationDate"] == publication_date+ assert (+ collection_data["channelListings"][0]["publishedAt"]+ == publication_date.isoformat()+ )assert collection_data["channelListings"][0]["channel"]["slug"] == channel_USD.slug@@ -510,8 +516,8 @@ def test_collection_channel_listing_update_add_channel_without_publication_date(assert collection_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugassert collection_data["channelListings"][1]["isPublished"] is Trueassert (- collection_data["channelListings"][1]["publicationDate"]- == datetime.date(2020, 3, 18).isoformat()+ collection_data["channelListings"][1]["publishedAt"]+ == datetime.datetime.now(pytz.utc).isoformat())assert collection_data["channelListings"][1]["channel"]["slug"] == channel_PLN.slug@@ -544,7 +550,7 @@ def test_collection_channel_listing_update_publish_without_publication_date(assert collection_data["slug"] == published_collection.slugassert collection_data["channelListings"][0]["isPublished"] is Trueassert (- collection_data["channelListings"][0]["publicationDate"]- == datetime.date(2020, 3, 18).isoformat()+ collection_data["channelListings"][0]["publishedAt"]+ == datetime.datetime.now(pytz.utc).isoformat())assert collection_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugdiff --git a/saleor/graphql/product/tests/test_collection_filtering_and_sorting_with_channels.py b/saleor/graphql/product/tests/test_collection_filtering_and_sorting_with_channels.pyindex f593dc5224..be39dc8d8a 100644--- a/saleor/graphql/product/tests/test_collection_filtering_and_sorting_with_channels.py+++ b/saleor/graphql/product/tests/test_collection_filtering_and_sorting_with_channels.py@@ -1,6 +1,7 @@import datetimeimport pytest+import pytzfrom ....product.models import Collection, CollectionChannelListingfrom ...tests.utils import assert_graphql_error_with_message, get_graphql_content@@ -21,50 +22,50 @@ def collections_for_sorting_with_channels(channel_USD, channel_PLN):[CollectionChannelListing(collection=collections[0],- publication_date=None,+ published_at=None,is_published=True,channel=channel_USD,),CollectionChannelListing(collection=collections[1],- publication_date=None,+ published_at=None,is_published=False,channel=channel_USD,),CollectionChannelListing(collection=collections[2],- publication_date=datetime.date(2004, 1, 1),+ published_at=datetime.datetime(2004, 1, 1, tzinfo=pytz.UTC),is_published=False,channel=channel_USD,),CollectionChannelListing(collection=collections[3],- publication_date=datetime.date(2003, 1, 1),+ published_at=datetime.datetime(2003, 1, 1, tzinfo=pytz.UTC),is_published=False,channel=channel_USD,),# second channelCollectionChannelListing(collection=collections[0],- publication_date=None,+ published_at=None,is_published=False,channel=channel_PLN,),CollectionChannelListing(collection=collections[1],- publication_date=None,+ published_at=None,is_published=True,channel=channel_PLN,),CollectionChannelListing(collection=collections[2],- publication_date=datetime.date(2002, 1, 1),+ published_at=datetime.datetime(2002, 1, 1, tzinfo=pytz.UTC),is_published=False,channel=channel_PLN,),CollectionChannelListing(collection=collections[4],- publication_date=datetime.date(2001, 1, 1),+ published_at=datetime.datetime(2001, 1, 1, tzinfo=pytz.UTC),is_published=False,channel=channel_PLN,),@@ -95,7 +96,7 @@ QUERY_COLLECTIONS_WITH_SORTING_AND_FILTERING = """"sort_by",[{"field": "AVAILABILITY", "direction": "ASC"},- {"field": "PUBLICATION_DATE", "direction": "DESC"},+ {"field": "PUBLISHED_AT", "direction": "DESC"},],)def test_collections_with_sorting_and_without_channel(@@ -130,11 +131,11 @@ def test_collections_with_sorting_and_without_channel(["Collection1", "Collection4", "Collection3", "Collection2"],),(- {"field": "PUBLICATION_DATE", "direction": "ASC"},+ {"field": "PUBLISHED_AT", "direction": "ASC"},["Collection4", "Collection3", "Collection1", "Collection2"],),(- {"field": "PUBLICATION_DATE", "direction": "DESC"},+ {"field": "PUBLISHED_AT", "direction": "DESC"},["Collection2", "Collection1", "Collection3", "Collection4"],),],@@ -177,11 +178,11 @@ def test_collections_with_sorting_and_channel_USD(["Collection2", "Collection5", "Collection3", "Collection1"],),(- {"field": "PUBLICATION_DATE", "direction": "ASC"},+ {"field": "PUBLISHED_AT", "direction": "ASC"},["Collection5", "Collection3", "Collection1", "Collection2"],),(- {"field": "PUBLICATION_DATE", "direction": "DESC"},+ {"field": "PUBLISHED_AT", "direction": "DESC"},["Collection2", "Collection1", "Collection3", "Collection5"],),],@@ -217,7 +218,7 @@ def test_collections_with_sorting_and_channel_PLN("sort_by",[{"field": "AVAILABILITY", "direction": "ASC"},- {"field": "PUBLICATION_DATE", "direction": "ASC"},+ {"field": "PUBLISHED_AT", "direction": "ASC"},],)def test_collections_with_sorting_and_not_existing_channel_asc(@@ -247,7 +248,7 @@ def test_collections_with_sorting_and_not_existing_channel_asc("sort_by",[{"field": "AVAILABILITY", "direction": "DESC"},- {"field": "PUBLICATION_DATE", "direction": "DESC"},+ {"field": "PUBLISHED_AT", "direction": "DESC"},],)def test_collections_with_sorting_and_not_existing_channel_desc(diff --git a/saleor/graphql/product/tests/test_product.py b/saleor/graphql/product/tests/test_product.pyindex d25eac2b02..691de55cba 100644--- a/saleor/graphql/product/tests/test_product.py+++ b/saleor/graphql/product/tests/test_product.py@@ -170,6 +170,7 @@ QUERY_PRODUCT = """value}availableForPurchase+ availableForPurchaseAtisAvailableForPurchaseisAvailable}@@ -1122,8 +1123,8 @@ def test_product_query_is_available_for_purchase_true(user_api_client, product, channel_USD):# given- available_for_purchase = datetime.today() - timedelta(days=1)- product.channel_listings.update(available_for_purchase=available_for_purchase)+ available_for_purchase = timezone.now() - timedelta(days=1)+ product.channel_listings.update(available_for_purchase_at=available_for_purchase)variables = {"id": graphene.Node.to_global_id("Product", product.pk),@@ -1140,6 +1141,7 @@ def test_product_query_is_available_for_purchase_true(assert product_data["availableForPurchase"] == available_for_purchase.strftime("%Y-%m-%d")+ assert product_data["availableForPurchaseAt"] == available_for_purchase.isoformat()assert product_data["isAvailableForPurchase"] is True@@ -1147,8 +1149,8 @@ def test_product_query_is_available_for_purchase_false(user_api_client, product, channel_USD):# given- available_for_purchase = datetime.today() + timedelta(days=1)- product.channel_listings.update(available_for_purchase=available_for_purchase)+ available_for_purchase = timezone.now() + timedelta(days=1)+ product.channel_listings.update(available_for_purchase_at=available_for_purchase)variables = {"id": graphene.Node.to_global_id("Product", product.pk),@@ -1165,6 +1167,7 @@ def test_product_query_is_available_for_purchase_false(assert product_data["availableForPurchase"] == available_for_purchase.strftime("%Y-%m-%d")+ assert product_data["availableForPurchaseAt"] == available_for_purchase.isoformat()assert product_data["isAvailableForPurchase"] is Falseassert product_data["isAvailable"] is False@@ -1173,7 +1176,7 @@ def test_product_query_is_available_for_purchase_false_no_available_for_purchaseuser_api_client, product, channel_USD):# given- product.channel_listings.update(available_for_purchase=None)+ product.channel_listings.update(available_for_purchase_at=None)variables = {"id": graphene.Node.to_global_id("Product", product.pk),@@ -1188,6 +1191,7 @@ def test_product_query_is_available_for_purchase_false_no_available_for_purchaseproduct_data = content["data"]["product"]assert not product_data["availableForPurchase"]+ assert not product_data["availableForPurchaseAt"]assert product_data["isAvailableForPurchase"] is Falseassert product_data["isAvailable"] is Falsediff --git a/saleor/graphql/product/tests/test_product_channel_listing_update.py b/saleor/graphql/product/tests/test_product_channel_listing_update.pyindex 7bc1e66ab5..37eb5a0926 100644--- a/saleor/graphql/product/tests/test_product_channel_listing_update.py+++ b/saleor/graphql/product/tests/test_product_channel_listing_update.py@@ -2,6 +2,8 @@ import datetimefrom unittest.mock import patchimport graphene+import pytz+from django.utils import timezonefrom freezegun import freeze_timefrom ....checkout.fetch import fetch_checkout_info@@ -29,7 +31,7 @@ mutation UpdateProductChannelListing(slugchannelListings {isPublished- publicationDate+ publishedAtvisibleInListingschannel {slug@@ -47,7 +49,7 @@ mutation UpdateProductChannelListing(stop}isAvailableForPurchase- availableForPurchase+ availableForPurchaseAt}variants {channelListings {@@ -201,10 +203,10 @@ def test_product_channel_listing_update_as_staff_user(staff_api_client, product, permission_manage_products, channel_USD, channel_PLN):# given- publication_date = datetime.date.today()+ publication_date = datetime.datetime.now(pytz.utc).replace(microsecond=0)product_id = graphene.Node.to_global_id("Product", product.pk)channel_id = graphene.Node.to_global_id("Channel", channel_PLN.id)- available_for_purchase_date = datetime.date(2007, 1, 1)+ available_for_purchase_date = datetime.datetime(2007, 1, 1, tzinfo=pytz.utc)variables = {"id": product_id,"input": {@@ -212,10 +214,10 @@ def test_product_channel_listing_update_as_staff_user({"channelId": channel_id,"isPublished": False,- "publicationDate": publication_date,+ "publishedAt": publication_date,"visibleInListings": True,"isAvailableForPurchase": True,- "availableForPurchaseDate": available_for_purchase_date,+ "availableForPurchaseAt": available_for_purchase_date,}]},@@ -241,13 +243,13 @@ def test_product_channel_listing_update_as_staff_user(assert not data["errors"]assert product_data["slug"] == product.slugassert product_data["channelListings"][0]["isPublished"] is True- assert product_data["channelListings"][0]["publicationDate"] is None+ assert product_data["channelListings"][0]["publishedAt"] is Noneassert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugassert product_data["channelListings"][0]["visibleInListings"] is Trueassert product_data["channelListings"][0]["isAvailableForPurchase"] is Trueassert (- product_data["channelListings"][0]["availableForPurchase"]- == datetime.date(1999, 1, 1).isoformat()+ datetime.date(1999, 1, 1).isoformat()+ in product_data["channelListings"][0]["availableForPurchaseAt"])cost_start = product_data["channelListings"][0]["purchaseCost"]["start"]["amount"]cost_stop = product_data["channelListings"][0]["purchaseCost"]["stop"]["amount"]@@ -258,14 +260,14 @@ def test_product_channel_listing_update_as_staff_user(assert margin[1] == product_data["channelListings"][0]["margin"]["stop"]assert product_data["channelListings"][1]["isPublished"] is Falseassert (- product_data["channelListings"][1]["publicationDate"]+ product_data["channelListings"][1]["publishedAt"]== publication_date.isoformat())assert product_data["channelListings"][1]["visibleInListings"] is Trueassert product_data["channelListings"][1]["channel"]["slug"] == channel_PLN.slugassert product_data["channelListings"][1]["isAvailableForPurchase"] is Trueassert (- product_data["channelListings"][1]["availableForPurchase"]+ product_data["channelListings"][1]["availableForPurchaseAt"]== available_for_purchase_date.isoformat())@@ -280,10 +282,10 @@ def test_product_channel_listing_update_trigger_webhook_product_updated(channel_PLN,):# given- publication_date = datetime.date.today()+ publication_date = datetime.datetime.now(pytz.utc)product_id = graphene.Node.to_global_id("Product", product.pk)channel_id = graphene.Node.to_global_id("Channel", channel_PLN.id)- available_for_purchase_date = datetime.date(2007, 1, 1)+ available_for_purchase_date = datetime.datetime(2007, 1, 1, tzinfo=pytz.utc)variables = {"id": product_id,"input": {@@ -291,10 +293,10 @@ def test_product_channel_listing_update_trigger_webhook_product_updated({"channelId": channel_id,"isPublished": False,- "publicationDate": publication_date,+ "publishedAt": publication_date,"visibleInListings": True,"isAvailableForPurchase": True,- "availableForPurchaseDate": available_for_purchase_date,+ "availableForPurchaseAt": available_for_purchase_date,}]},@@ -316,10 +318,10 @@ def test_product_channel_listing_update_as_app(app_api_client, product, permission_manage_products, channel_USD, channel_PLN):# given- publication_date = datetime.date.today()+ publication_date = datetime.datetime.now(pytz.utc).replace(microsecond=0)product_id = graphene.Node.to_global_id("Product", product.pk)channel_id = graphene.Node.to_global_id("Channel", channel_PLN.id)- available_for_purchase_date = datetime.date(2007, 1, 1)+ available_for_purchase_date = datetime.datetime(2007, 1, 1, tzinfo=pytz.utc)variables = {"id": product_id,"input": {@@ -327,10 +329,10 @@ def test_product_channel_listing_update_as_app({"channelId": channel_id,"isPublished": False,- "publicationDate": publication_date,+ "publishedAt": publication_date,"visibleInListings": True,"isAvailableForPurchase": True,- "availableForPurchaseDate": available_for_purchase_date,+ "availableForPurchaseAt": available_for_purchase_date,}]},@@ -350,24 +352,24 @@ def test_product_channel_listing_update_as_app(assert not data["errors"]assert product_data["slug"] == product.slugassert product_data["channelListings"][0]["isPublished"] is True- assert product_data["channelListings"][0]["publicationDate"] is None+ assert product_data["channelListings"][0]["publishedAt"] is Noneassert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugassert product_data["channelListings"][0]["visibleInListings"] is Trueassert product_data["channelListings"][0]["isAvailableForPurchase"] is Trueassert (- product_data["channelListings"][0]["availableForPurchase"]- == datetime.date(1999, 1, 1).isoformat()+ datetime.date(1999, 1, 1).isoformat()+ in product_data["channelListings"][0]["availableForPurchaseAt"])assert product_data["channelListings"][1]["isPublished"] is Falseassert (- product_data["channelListings"][1]["publicationDate"]+ product_data["channelListings"][1]["publishedAt"]== publication_date.isoformat())assert product_data["channelListings"][1]["visibleInListings"] is Trueassert product_data["channelListings"][1]["channel"]["slug"] == channel_PLN.slugassert product_data["channelListings"][1]["isAvailableForPurchase"] is Trueassert (- product_data["channelListings"][1]["availableForPurchase"]+ product_data["channelListings"][1]["availableForPurchaseAt"]== available_for_purchase_date.isoformat())@@ -414,10 +416,10 @@ def test_product_channel_listing_update_add_channel(staff_api_client, product, permission_manage_products, channel_USD, channel_PLN):# given- publication_date = datetime.date.today()+ publication_date = datetime.datetime.now(pytz.utc).replace(microsecond=0)product_id = graphene.Node.to_global_id("Product", product.pk)channel_id = graphene.Node.to_global_id("Channel", channel_PLN.id)- available_for_purchase_date = datetime.date(2007, 1, 1)+ available_for_purchase_date = datetime.datetime(2007, 1, 1, tzinfo=pytz.utc)variables = {"id": product_id,"input": {@@ -425,10 +427,10 @@ def test_product_channel_listing_update_add_channel({"channelId": channel_id,"isPublished": False,- "publicationDate": publication_date,+ "publishedAt": publication_date,"visibleInListings": True,"isAvailableForPurchase": True,- "availableForPurchaseDate": available_for_purchase_date,+ "availableForPurchaseAt": available_for_purchase_date,}]},@@ -448,18 +450,18 @@ def test_product_channel_listing_update_add_channel(assert not data["errors"]assert product_data["slug"] == product.slugassert product_data["channelListings"][0]["isPublished"] is True- assert product_data["channelListings"][0]["publicationDate"] is None+ assert product_data["channelListings"][0]["publishedAt"] is Noneassert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugassert product_data["channelListings"][1]["isPublished"] is Falseassert (- product_data["channelListings"][1]["publicationDate"]+ product_data["channelListings"][1]["publishedAt"]== publication_date.isoformat())assert product_data["channelListings"][1]["channel"]["slug"] == channel_PLN.slugassert product_data["channelListings"][1]["visibleInListings"] is Trueassert product_data["channelListings"][1]["isAvailableForPurchase"] is Trueassert (- product_data["channelListings"][1]["availableForPurchase"]+ product_data["channelListings"][1]["availableForPurchaseAt"]== available_for_purchase_date.isoformat())@@ -490,12 +492,12 @@ def test_product_channel_listing_update_add_channel_without_publication_date(assert not data["errors"]assert product_data["slug"] == product.slugassert product_data["channelListings"][0]["isPublished"] is True- assert product_data["channelListings"][0]["publicationDate"] is None+ assert product_data["channelListings"][0]["publishedAt"] is Noneassert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugassert product_data["channelListings"][1]["isPublished"] is Trueassert (- product_data["channelListings"][1]["publicationDate"]- == datetime.date(2020, 3, 18).isoformat()+ datetime.date(2020, 3, 18).isoformat()+ in product_data["channelListings"][1]["publishedAt"])assert product_data["channelListings"][1]["channel"]["slug"] == channel_PLN.slug@@ -504,7 +506,7 @@ def test_product_channel_listing_update_unpublished(staff_api_client, product, permission_manage_products, channel_USD):# given- product.channel_listings.update(publication_date=datetime.date.today())+ product.channel_listings.update(published_at=timezone.now())product_id = graphene.Node.to_global_id("Product", product.pk)channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)variables = {@@ -527,15 +529,15 @@ def test_product_channel_listing_update_unpublished(assert product_data["slug"] == product.slugassert product_data["channelListings"][0]["isPublished"] is Falseassert (- product_data["channelListings"][0]["publicationDate"]- == datetime.date.today().isoformat()+ datetime.date.today().isoformat()+ in product_data["channelListings"][0]["publishedAt"])assert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugassert product_data["channelListings"][0]["visibleInListings"] is Trueassert product_data["channelListings"][0]["isAvailableForPurchase"] is Trueassert (- product_data["channelListings"][0]["availableForPurchase"]- == datetime.date(1999, 1, 1).isoformat()+ datetime.date(1999, 1, 1).isoformat()+ in product_data["channelListings"][0]["availableForPurchaseAt"])@@ -567,8 +569,8 @@ def test_product_channel_listing_update_publish_without_publication_date(assert product_data["slug"] == product.slugassert product_data["channelListings"][0]["isPublished"] is Trueassert (- product_data["channelListings"][0]["publicationDate"]- == datetime.date(2020, 3, 18).isoformat()+ datetime.date(2020, 3, 18).isoformat()+ in product_data["channelListings"][0]["publishedAt"])assert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slug@@ -577,14 +579,12 @@ def test_product_channel_listing_update_remove_publication_date(staff_api_client, product, permission_manage_products, channel_USD):# given- product.channel_listings.update(publication_date=datetime.date.today())+ product.channel_listings.update(published_at=timezone.now())product_id = graphene.Node.to_global_id("Product", product.pk)channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)variables = {"id": product_id,- "input": {- "updateChannels": [{"channelId": channel_id, "publicationDate": None}]- },+ "input": {"updateChannels": [{"channelId": channel_id, "publishedAt": None}]},}# when@@ -601,13 +601,13 @@ def test_product_channel_listing_update_remove_publication_date(assert not data["errors"]assert product_data["slug"] == product.slugassert product_data["channelListings"][0]["isPublished"] is True- assert product_data["channelListings"][0]["publicationDate"] is None+ assert product_data["channelListings"][0]["publishedAt"] is Noneassert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugassert product_data["channelListings"][0]["visibleInListings"] is Trueassert product_data["channelListings"][0]["isAvailableForPurchase"] is Trueassert (- product_data["channelListings"][0]["availableForPurchase"]- == datetime.date(1999, 1, 1).isoformat()+ datetime.date(1999, 1, 1).isoformat()+ in product_data["channelListings"][0]["availableForPurchaseAt"])@@ -638,13 +638,13 @@ def test_product_channel_listing_update_visible_in_listings(assert not data["errors"]assert product_data["slug"] == product.slugassert product_data["channelListings"][0]["isPublished"] is True- assert product_data["channelListings"][0]["publicationDate"] is None+ assert product_data["channelListings"][0]["publishedAt"] is Noneassert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugassert product_data["channelListings"][0]["visibleInListings"] is Falseassert product_data["channelListings"][0]["isAvailableForPurchase"] is Trueassert (- product_data["channelListings"][0]["availableForPurchase"]- == datetime.date(1999, 1, 1).isoformat()+ datetime.date(1999, 1, 1).isoformat()+ in product_data["channelListings"][0]["availableForPurchaseAt"])@@ -652,7 +652,7 @@ def test_product_channel_listing_update_update_publication_data(staff_api_client, product, permission_manage_products, channel_USD):# given- publication_date = datetime.date.today()+ publication_date = datetime.datetime.now(pytz.utc).replace(microsecond=0)product_id = graphene.Node.to_global_id("Product", product.pk)channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)variables = {@@ -662,7 +662,7 @@ def test_product_channel_listing_update_update_publication_data({"channelId": channel_id,"isPublished": False,- "publicationDate": publication_date,+ "publishedAt": publication_date,}]},@@ -683,15 +683,15 @@ def test_product_channel_listing_update_update_publication_data(assert product_data["slug"] == product.slugassert product_data["channelListings"][0]["isPublished"] is Falseassert (- product_data["channelListings"][0]["publicationDate"]+ product_data["channelListings"][0]["publishedAt"]== publication_date.isoformat())assert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugassert product_data["channelListings"][0]["visibleInListings"] is Trueassert product_data["channelListings"][0]["isAvailableForPurchase"] is Trueassert (- product_data["channelListings"][0]["availableForPurchase"]- == datetime.date(1999, 1, 1).isoformat()+ datetime.date(1999, 1, 1).isoformat()+ in product_data["channelListings"][0]["availableForPurchaseAt"])@@ -724,11 +724,11 @@ def test_product_channel_listing_update_update_is_available_for_purchase_false(assert not data["errors"]assert product_data["slug"] == product.slugassert product_data["channelListings"][0]["isPublished"] is True- assert not product_data["channelListings"][0]["publicationDate"]+ assert not product_data["channelListings"][0]["publishedAt"]assert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugassert product_data["channelListings"][0]["visibleInListings"] is Trueassert product_data["channelListings"][0]["isAvailableForPurchase"] is False- assert not product_data["channelListings"][0]["availableForPurchase"]+ assert not product_data["channelListings"][0]["availableForPurchaseAt"]def test_product_channel_listing_update_update_is_available_for_purchase_without_date(@@ -760,13 +760,13 @@ def test_product_channel_listing_update_update_is_available_for_purchase_withoutassert not data["errors"]assert product_data["slug"] == product.slugassert product_data["channelListings"][0]["isPublished"] is True- assert not product_data["channelListings"][0]["publicationDate"]+ assert not product_data["channelListings"][0]["publishedAt"]assert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugassert product_data["channelListings"][0]["visibleInListings"] is Trueassert product_data["channelListings"][0]["isAvailableForPurchase"] is Trueassert (- product_data["channelListings"][0]["availableForPurchase"]- == datetime.date.today().isoformat()+ datetime.date.today().isoformat()+ in product_data["channelListings"][0]["availableForPurchaseAt"])@@ -776,7 +776,7 @@ def test_product_channel_listing_update_update_is_available_for_purchase_past_da# givenproduct_id = graphene.Node.to_global_id("Product", product.pk)channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)- available_for_purchase_date = datetime.date(2007, 1, 1)+ available_for_purchase_date = datetime.datetime(2007, 1, 1, tzinfo=pytz.utc)variables = {"id": product_id,"input": {@@ -784,7 +784,7 @@ def test_product_channel_listing_update_update_is_available_for_purchase_past_da{"channelId": channel_id,"isAvailableForPurchase": True,- "availableForPurchaseDate": available_for_purchase_date,+ "availableForPurchaseAt": available_for_purchase_date,}]},@@ -804,12 +804,12 @@ def test_product_channel_listing_update_update_is_available_for_purchase_past_daassert not data["errors"]assert product_data["slug"] == product.slugassert product_data["channelListings"][0]["isPublished"] is True- assert not product_data["channelListings"][0]["publicationDate"]+ assert not product_data["channelListings"][0]["publishedAt"]assert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugassert product_data["channelListings"][0]["visibleInListings"] is Trueassert product_data["channelListings"][0]["isAvailableForPurchase"] is Trueassert (- product_data["channelListings"][0]["availableForPurchase"]+ product_data["channelListings"][0]["availableForPurchaseAt"]== available_for_purchase_date.isoformat())@@ -820,7 +820,9 @@ def test_product_channel_listing_update_update_is_available_for_purchase_future_# givenproduct_id = graphene.Node.to_global_id("Product", product.pk)channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)- available_for_purchase_date = datetime.date.today() + datetime.timedelta(days=1)+ available_for_purchase_date = datetime.datetime.now(pytz.utc).replace(+ microsecond=0+ ) + datetime.timedelta(days=1)variables = {"id": product_id,"input": {@@ -828,7 +830,7 @@ def test_product_channel_listing_update_update_is_available_for_purchase_future_{"channelId": channel_id,"isAvailableForPurchase": True,- "availableForPurchaseDate": available_for_purchase_date,+ "availableForPurchaseAt": available_for_purchase_date,}]},@@ -848,12 +850,12 @@ def test_product_channel_listing_update_update_is_available_for_purchase_future_assert not data["errors"]assert product_data["slug"] == product.slugassert product_data["channelListings"][0]["isPublished"] is True- assert not product_data["channelListings"][0]["publicationDate"]+ assert not product_data["channelListings"][0]["publishedAt"]assert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugassert product_data["channelListings"][0]["visibleInListings"] is Trueassert product_data["channelListings"][0]["isAvailableForPurchase"] is Falseassert (- product_data["channelListings"][0]["availableForPurchase"]+ product_data["channelListings"][0]["availableForPurchaseAt"]== available_for_purchase_date.isoformat())@@ -864,7 +866,9 @@ def test_product_channel_listing_update_update_is_available_for_purchase_false_a# givenproduct_id = graphene.Node.to_global_id("Product", product.pk)channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)- available_for_purchase_date = datetime.date.today() + datetime.timedelta(days=1)+ available_for_purchase_date = datetime.datetime.now(pytz.utc) + datetime.timedelta(+ days=1+ )variables = {"id": product_id,"input": {@@ -872,7 +876,7 @@ def test_product_channel_listing_update_update_is_available_for_purchase_false_a{"channelId": channel_id,"isAvailableForPurchase": False,- "availableForPurchaseDate": available_for_purchase_date,+ "availableForPurchaseAt": available_for_purchase_date,}]},@@ -993,7 +997,7 @@ def test_product_channel_listing_update_remove_not_assigned_channel(assert not data["errors"]assert product_data["slug"] == product.slugassert product_data["channelListings"][0]["isPublished"] is True- assert product_data["channelListings"][0]["publicationDate"] is None+ assert product_data["channelListings"][0]["publishedAt"] is Noneassert product_data["channelListings"][0]["channel"]["slug"] == channel_USD.slugdiff --git a/saleor/graphql/product/tests/test_product_filtering_and_sorting_with_channels.py b/saleor/graphql/product/tests/test_product_filtering_and_sorting_with_channels.pyindex 57abe86688..f92eb73c80 100644--- a/saleor/graphql/product/tests/test_product_filtering_and_sorting_with_channels.py+++ b/saleor/graphql/product/tests/test_product_filtering_and_sorting_with_channels.py@@ -3,6 +3,7 @@ import uuidfrom decimal import Decimalimport pytest+import pytzfrom freezegun import freeze_timefrom ....product import ProductTypeKind@@ -64,28 +65,28 @@ def products_for_sorting_with_channels(category, channel_USD, channel_PLN):channel=channel_USD,is_published=True,discounted_price_amount=Decimal(5),- publication_date=datetime.date(2002, 1, 1),+ published_at=datetime.datetime(2002, 1, 1, tzinfo=pytz.UTC),),ProductChannelListing(product=products[1],channel=channel_USD,is_published=True,discounted_price_amount=Decimal(15),- publication_date=datetime.date(2000, 1, 1),+ published_at=datetime.datetime(2000, 1, 1, tzinfo=pytz.UTC),),ProductChannelListing(product=products[2],channel=channel_USD,is_published=False,discounted_price_amount=Decimal(4),- publication_date=datetime.date(1999, 1, 1),+ published_at=datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC),),ProductChannelListing(product=products[3],channel=channel_USD,is_published=True,discounted_price_amount=Decimal(7),- publication_date=datetime.date(2001, 1, 1),+ published_at=datetime.datetime(2001, 1, 1, tzinfo=pytz.UTC),),# Second channelProductChannelListing(@@ -93,28 +94,28 @@ def products_for_sorting_with_channels(category, channel_USD, channel_PLN):channel=channel_PLN,is_published=False,discounted_price_amount=Decimal(15),- publication_date=datetime.date(2003, 1, 1),+ published_at=datetime.datetime(2003, 1, 1, tzinfo=pytz.UTC),),ProductChannelListing(product=products[1],channel=channel_PLN,is_published=True,discounted_price_amount=Decimal(4),- publication_date=datetime.date(1999, 1, 1),+ published_at=datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC),),ProductChannelListing(product=products[2],channel=channel_PLN,is_published=True,discounted_price_amount=Decimal(5),- publication_date=datetime.date(2000, 1, 1),+ published_at=datetime.datetime(2000, 1, 1, tzinfo=pytz.UTC),),ProductChannelListing(product=products[4],channel=channel_PLN,is_published=True,discounted_price_amount=Decimal(7),- publication_date=datetime.date(1998, 1, 1),+ published_at=datetime.datetime(1998, 1, 1, tzinfo=pytz.UTC),),])@@ -243,7 +244,7 @@ QUERY_PRODUCTS_WITH_SORTING_AND_FILTERING = """{"field": "PUBLISHED", "direction": "ASC"},{"field": "PRICE", "direction": "DESC"},{"field": "MINIMAL_PRICE", "direction": "DESC"},- {"field": "PUBLICATION_DATE", "direction": "DESC"},+ {"field": "PUBLISHED_AT", "direction": "DESC"},],)def test_products_with_sorting_and_without_channel(diff --git a/saleor/graphql/product/tests/test_product_sorting.py b/saleor/graphql/product/tests/test_product_sorting.pyindex b772584659..f37fa36db4 100644--- a/saleor/graphql/product/tests/test_product_sorting.py+++ b/saleor/graphql/product/tests/test_product_sorting.py@@ -1,8 +1,9 @@import random-from datetime import date, timedelta+from datetime import timedeltaimport grapheneimport pytest+from django.utils import timezonefrom freezegun import freeze_timefrom ....product.models import CollectionProduct, Product, ProductChannelListing@@ -160,26 +161,26 @@ query Products($sortBy: ProductOrder, $channel: String) {@freeze_time("2020-03-18 12:00:00")@pytest.mark.parametrize("direction, order_direction",- (("ASC", "publication_date"), ("DESC", "-publication_date")),+ (("ASC", "published_at"), ("DESC", "-published_at")),)-def test_sort_products_by_publication_date(+def test_sort_products_by_published_at(direction, order_direction, api_client, product_list, channel_USD):product_channel_listings = []for iter_value, product in enumerate(product_list):product_channel_listing = product.channel_listings.get(channel=channel_USD)- product_channel_listing.publication_date = date.today() - timedelta(+ product_channel_listing.published_at = timezone.now() - timedelta(days=iter_value)product_channel_listings.append(product_channel_listing)ProductChannelListing.objects.bulk_update(- product_channel_listings, ["publication_date"]+ product_channel_listings, ["published_at"])variables = {"sortBy": {"direction": direction,- "field": "PUBLICATION_DATE",+ "field": "PUBLISHED_AT",},"channel": channel_USD.slug,}diff --git a/saleor/graphql/product/types/channels.py b/saleor/graphql/product/types/channels.pyindex 8b1084cfe3..010a354bf1 100644--- a/saleor/graphql/product/types/channels.py+++ b/saleor/graphql/product/types/channels.py@@ -16,7 +16,12 @@ from ....product.utils.costs import (from ...account import types as account_typesfrom ...channel.dataloaders import ChannelByIdLoaderfrom ...channel.types import Channel-from ...core.descriptions import ADDED_IN_31, PREVIEW_FEATURE+from ...core.descriptions import (+ ADDED_IN_31,+ ADDED_IN_33,+ DEPRECATED_IN_3X_FIELD,+ PREVIEW_FEATURE,+)from ...core.fields import PermissionsFieldfrom ...core.types import ModelObjectTypefrom ...discount.dataloaders import DiscountsByDateTimeLoader@@ -36,11 +41,28 @@ class Margin(graphene.ObjectType):class ProductChannelListing(ModelObjectType):id = graphene.GlobalID(required=True)- publication_date = graphene.Date()+ publication_date = graphene.Date(+ deprecation_reason=(+ f"{DEPRECATED_IN_3X_FIELD} "+ "Use the `publishedAt` field to fetch the publication date."+ ),+ )+ published_at = graphene.DateTime(+ description=f"{ADDED_IN_33} The product publication date time."+ )is_published = graphene.Boolean(required=True)channel = graphene.Field(Channel, required=True)visible_in_listings = graphene.Boolean(required=True)- available_for_purchase = graphene.Date()+ available_for_purchase = graphene.Date(+ deprecation_reason=(+ f"{DEPRECATED_IN_3X_FIELD} "+ "Use the `availableForPurchaseAt` field to fetch "+ "the available for purchase date."+ ),+ )+ available_for_purchase_at = graphene.DateTime(+ description=f"{ADDED_IN_33} The product available for purchase date time."+ )discounted_price = graphene.Field(Money, description="The price of the cheapest variant (including discounts).")@@ -79,6 +101,16 @@ class ProductChannelListing(ModelObjectType):model = models.ProductChannelListinginterfaces = [graphene.relay.Node]+ @staticmethod+ def resolve_publication_date(root: models.ProductChannelListing, info, **_kwargs):+ return root.published_at++ @staticmethod+ def resolve_available_for_purchase(+ root: models.ProductChannelListing, info, **_kwargs+ ):+ return root.available_for_purchase_at+@staticmethoddef resolve_channel(root: models.ProductChannelListing, info, **_kwargs):return ChannelByIdLoader(info.context).load(root.channel_id)@@ -296,7 +328,15 @@ class ProductVariantChannelListing(ModelObjectType):class CollectionChannelListing(ModelObjectType):id = graphene.GlobalID(required=True)- publication_date = graphene.Date()+ publication_date = graphene.Date(+ deprecation_reason=(+ f"{DEPRECATED_IN_3X_FIELD} "+ "Use the `publishedAt` field to fetch the publication date."+ ),+ )+ published_at = graphene.DateTime(+ description=f"{ADDED_IN_33} The collection publication date."+ )is_published = graphene.Boolean(required=True)channel = graphene.Field(Channel, required=True)@@ -305,6 +345,10 @@ class CollectionChannelListing(ModelObjectType):model = models.CollectionChannelListinginterfaces = [graphene.relay.Node]+ @staticmethod+ def resolve_publication_date(root: models.ProductChannelListing, info, **_kwargs):+ return root.published_at+@staticmethoddef resolve_channel(root: models.ProductChannelListing, info, **_kwargs):return ChannelByIdLoader(info.context).load(root.channel_id)diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.pyindex 7a371d8b73..4edfc9a78b 100644--- a/saleor/graphql/product/types/products.py+++ b/saleor/graphql/product/types/products.py@@ -841,6 +841,14 @@ class Product(ChannelContextTypeWithMetadata, ModelObjectType):resolver=ChannelContextType.resolve_translation,)available_for_purchase = graphene.Date(+ description="Date when product is available for purchase.",+ deprecation_reason=(+ f"{DEPRECATED_IN_3X_FIELD} "+ "Use the `availableForPurchaseAt` field to fetch "+ "the available for purchase date."+ ),+ )+ available_for_purchase_at = graphene.DateTime(description="Date when product is available for purchase.")is_available_for_purchase = graphene.Boolean(@@ -1188,7 +1196,25 @@ class Product(ChannelContextTypeWithMetadata, ModelObjectType):def calculate_available_for_purchase(product_channel_listing):if not product_channel_listing:return None- return product_channel_listing.available_for_purchase+ return product_channel_listing.available_for_purchase_at++ return (+ ProductChannelListingByProductIdAndChannelSlugLoader(info.context)+ .load((root.node.id, channel_slug))+ .then(calculate_available_for_purchase)+ )++ @staticmethod+ @traced_resolver+ def resolve_available_for_purchase_at(root: ChannelContext[models.Product], info):+ if not root.channel_slug:+ return None+ channel_slug = str(root.channel_slug)++ def calculate_available_for_purchase(product_channel_listing):+ if not product_channel_listing:+ return None+ return product_channel_listing.available_for_purchase_atreturn (ProductChannelListingByProductIdAndChannelSlugLoader(info.context)diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 7f39c09b43..164b8701df 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -3183,7 +3183,10 @@ type Product implements Node & ObjectWithMetadata {): ProductTranslation"""Date when product is available for purchase."""- availableForPurchase: Date+ availableForPurchase: Date @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `availableForPurchaseAt` field to fetch the available for purchase date.")++ """Date when product is available for purchase."""+ availableForPurchaseAt: DateTime"""Whether the product is available for purchase."""isAvailableForPurchase: Boolean@@ -3538,7 +3541,7 @@ type AttributeValue implements Node {"""Represents the date value of the attribute value."""date: Date- """Represents the date time value of the attribute value."""+ """Represents the date/time value of the attribute value."""dateTime: DateTime}@@ -4449,11 +4452,17 @@ type TaxedMoneyRange {"""Represents product channel listing."""type ProductChannelListing implements Node {id: ID!- publicationDate: Date+ publicationDate: Date @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `publishedAt` field to fetch the publication date.")++ """New in Saleor 3.3. The product publication date time."""+ publishedAt: DateTimeisPublished: Boolean!channel: Channel!visibleInListings: Boolean!- availableForPurchase: Date+ availableForPurchase: Date @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `availableForPurchaseAt` field to fetch the available for purchase date.")++ """New in Saleor 3.3. The product available for purchase date time."""+ availableForPurchaseAt: DateTime"""The price of the cheapest variant (including discounts)."""discountedPrice: Money@@ -4585,10 +4594,12 @@ input AttributeInput {"""The range that the returned values should be in."""valuesRange: IntRangeInput- """The date time range that the returned values should be in."""+ """The date/time range that the returned values should be in."""dateTime: DateTimeRangeInput- """The date range that the returned values should be in."""+ """+ The date range that the returned values should be in. In case of date/time attributes, the UTC midnight of the given date is used.+ """date: DateRangeInput"""The boolean value of the attribute."""@@ -4720,7 +4731,10 @@ type CollectionTranslation implements Node {"""Represents collection channel listing."""type CollectionChannelListing implements Node {id: ID!- publicationDate: Date+ publicationDate: Date @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `publishedAt` field to fetch the publication date.")++ """New in Saleor 3.3. The collection publication date."""+ publishedAt: DateTimeisPublished: Boolean!channel: Channel!}@@ -4962,7 +4976,10 @@ type Page implements Node & ObjectWithMetadata {"""Content of the page (JSON)."""content: JSONString- publicationDate: Date+ publicationDate: Date @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `publishedAt` field to fetch the publication date.")++ """New in Saleor 3.3. The page publication date."""+ publishedAt: DateTimeisPublished: Boolean!slug: String!pageType: PageType!@@ -7210,8 +7227,19 @@ enum CollectionSortField {"""Sort collections by product count."""PRODUCT_COUNT- """Sort collections by publication date."""+ """+ Sort collections by publication date.++ DEPRECATED: this field will be removed in Saleor 4.0.+ """PUBLICATION_DATE++ """+ Sort collections by publication date.++ DEPRECATED: this field will be removed in Saleor 4.0.+ """+ PUBLISHED_AT}input ProductTypeFilterInput {@@ -7332,8 +7360,19 @@ enum PageSortField {"""Sort pages by creation date."""CREATION_DATE- """Sort pages by publication date."""+ """+ Sort pages by publication date.++ DEPRECATED: this field will be removed in Saleor 4.0.+ """PUBLICATION_DATE++ """+ Sort pages by publication date.++ DEPRECATED: this field will be removed in Saleor 4.0.+ """+ PUBLISHED_AT}input PageFilterInput {@@ -12099,7 +12138,11 @@ input CollectionCreateInput {"""Search engine optimization fields."""seo: SeoInput- """Publication date. ISO 8601 standard."""+ """+ Publication date. ISO 8601 standard.++ DEPRECATED: this field will be removed in Saleor 4.0.+ """publicationDate: Date"""List of products to be added to the collection."""@@ -12186,7 +12229,11 @@ input CollectionInput {"""Search engine optimization fields."""seo: SeoInput- """Publication date. ISO 8601 standard."""+ """+ Publication date. ISO 8601 standard.++ DEPRECATED: this field will be removed in Saleor 4.0.+ """publicationDate: Date}@@ -12246,8 +12293,15 @@ input PublishableChannelListingInput {"""Determines if object is visible to customers."""isPublished: Boolean- """Publication date. ISO 8601 standard."""+ """+ Publication date. ISO 8601 standard.++ DEPRECATED: this field will be removed in Saleor 4.0. Use `publishedAt` field instead.+ """publicationDate: Date++ """New in Saleor 3.3. Publication date time. ISO 8601 standard."""+ publishedAt: DateTime}"""@@ -12324,7 +12378,7 @@ input AttributeValueInput {"""Represents the date value of the attribute value."""date: Date- """Represents the date time value of the attribute value."""+ """Represents the date/time value of the attribute value."""dateTime: DateTime}@@ -12450,9 +12504,16 @@ input ProductChannelListingAddInput {"""Determines if object is visible to customers."""isPublished: Boolean- """Publication date. ISO 8601 standard."""+ """+ Publication date. ISO 8601 standard.++ DEPRECATED: this field will be removed in Saleor 4.0. Use `publishedAt` field instead.+ """publicationDate: Date+ """New in Saleor 3.3. Publication date time. ISO 8601 standard."""+ publishedAt: DateTime+"""Determines if product is visible in product listings (doesn't apply to product collections)."""@@ -12462,10 +12523,17 @@ input ProductChannelListingAddInput {isAvailableForPurchase: Boolean"""- A start date from which a product will be available for purchase. When not set and isAvailable is set to True, the current day is assumed.+ A start date from which a product will be available for purchase. When not set and isAvailable is set to True, the current day is assumed.++ DEPRECATED: this field will be removed in Saleor 4.0. Use `availableForPurchaseAt` field instead."""availableForPurchaseDate: Date+ """+ New in Saleor 3.3. A start date time from which a product will be available for purchase. When not set and `isAvailable` is set to True, the current day is assumed.+ """+ availableForPurchaseAt: DateTime+"""List of variants to which the channel should be assigned."""addVariants: [ID!]@@ -13283,9 +13351,16 @@ input PageCreateInput {"""Determines if page is visible in the storefront."""isPublished: Boolean- """Publication date. ISO 8601 standard."""+ """+ Publication date. ISO 8601 standard.++ DEPRECATED: this field will be removed in Saleor 4.0. Use `publishedAt` field instead.+ """publicationDate: String+ """New in Saleor 3.3. Publication date time. ISO 8601 standard."""+ publishedAt: DateTime+"""Search engine optimization fields."""seo: SeoInput@@ -13347,9 +13422,16 @@ input PageInput {"""Determines if page is visible in the storefront."""isPublished: Boolean- """Publication date. ISO 8601 standard."""+ """+ Publication date. ISO 8601 standard.++ DEPRECATED: this field will be removed in Saleor 4.0. Use `publishedAt` field instead.+ """publicationDate: String+ """New in Saleor 3.3. Publication date time. ISO 8601 standard."""+ publishedAt: DateTime+"""Search engine optimization fields."""seo: SeoInput}diff --git a/saleor/page/migrations/0026_alter_page_publication_date.py b/saleor/page/migrations/0026_alter_page_publication_date.pynew file mode 100644index 0000000000..ee31cb34df--- /dev/null+++ b/saleor/page/migrations/0026_alter_page_publication_date.py@@ -0,0 +1,23 @@+# Generated by Django 3.2.12 on 2022-04-19 09:10++from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ("page", "0025_rename_created_page_created_at"),+ ]++ operations = [+ migrations.AlterField(+ model_name="page",+ name="publication_date",+ field=models.DateTimeField(blank=True, null=True),+ ),+ migrations.RenameField(+ model_name="page",+ old_name="publication_date",+ new_name="published_at",+ ),+ ]diff --git a/saleor/product/migrations/0166_update_publication_date_and_available_for_purchase.py b/saleor/product/migrations/0166_update_publication_date_and_available_for_purchase.pynew file mode 100644index 0000000000..272b3cc6c9--- /dev/null+++ b/saleor/product/migrations/0166_update_publication_date_and_available_for_purchase.py@@ -0,0 +1,53 @@+# Generated by Django 3.2.12 on 2022-04-19 09:10++from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ("product", "0165_update_product_search_document"),+ ]++ operations = [+ migrations.AlterField(+ model_name="collectionchannellisting",+ name="publication_date",+ field=models.DateTimeField(blank=True, null=True),+ ),+ migrations.AlterField(+ model_name="productchannellisting",+ name="available_for_purchase",+ field=models.DateTimeField(blank=True, null=True),+ ),+ migrations.AlterField(+ model_name="productchannellisting",+ name="publication_date",+ field=models.DateTimeField(blank=True, null=True),+ ),+ migrations.RemoveIndex(+ model_name="productchannellisting",+ name="product_pro_publica_67290c_idx",+ ),+ migrations.RenameField(+ model_name="collectionchannellisting",+ old_name="publication_date",+ new_name="published_at",+ ),+ migrations.RenameField(+ model_name="productchannellisting",+ old_name="available_for_purchase",+ new_name="available_for_purchase_at",+ ),+ migrations.RenameField(+ model_name="productchannellisting",+ old_name="publication_date",+ new_name="published_at",+ ),+ migrations.AddIndex(+ model_name="productchannellisting",+ index=models.Index(+ fields=["published_at"], name="product_pro_publish_a3c049_idx"+ ),+ ),+ ]diff --git a/saleor/product/models.py b/saleor/product/models.pyindex 4a6297734b..a9f1efbedb 100644--- a/saleor/product/models.py+++ b/saleor/product/models.py@@ -3,6 +3,7 @@ from typing import TYPE_CHECKING, Iterable, Optional, Unionfrom uuid import uuid4import graphene+import pytzfrom django.conf import settingsfrom django.contrib.postgres.aggregates import StringAggfrom django.contrib.postgres.indexes import BTreeIndex, GinIndex@@ -14,7 +15,7 @@ from django.db.models import (BooleanField,Case,Count,- DateField,+ DateTimeField,Exists,ExpressionWrapper,F,@@ -193,21 +194,21 @@ class ProductType(ModelWithMetadata):class ProductsQueryset(models.QuerySet):def published(self, channel_slug: str):- today = datetime.date.today()+ today = datetime.datetime.now(pytz.UTC)channels = Channel.objects.filter(slug=str(channel_slug), is_active=True).values("id")channel_listings = ProductChannelListing.objects.filter(- Q(publication_date__lte=today) | Q(publication_date__isnull=True),+ Q(published_at__lte=today) | Q(published_at__isnull=True),Exists(channels.filter(pk=OuterRef("channel_id"))),is_published=True,).values("id")return self.filter(Exists(channel_listings.filter(product_id=OuterRef("pk"))))def not_published(self, channel_slug: str):- today = datetime.date.today()+ today = datetime.datetime.now(pytz.UTC)return self.annotate_publication_info(channel_slug).filter(- Q(publication_date__gt=today) & Q(is_published=True)+ Q(published_at__gt=today) & Q(is_published=True)| Q(is_published=False)| Q(is_published__isnull=True))@@ -240,7 +241,7 @@ class ProductsQueryset(models.QuerySet):return self.published_with_variants(channel_slug)def annotate_publication_info(self, channel_slug: str):- return self.annotate_is_published(channel_slug).annotate_publication_date(+ return self.annotate_is_published(channel_slug).annotate_published_at(channel_slug)@@ -254,14 +255,14 @@ class ProductsQueryset(models.QuerySet):is_published=ExpressionWrapper(query, output_field=BooleanField()))- def annotate_publication_date(self, channel_slug: str):+ def annotate_published_at(self, channel_slug: str):query = Subquery(ProductChannelListing.objects.filter(product_id=OuterRef("pk"), channel__slug=str(channel_slug)- ).values_list("publication_date")[:1]+ ).values_list("published_at")[:1])return self.annotate(- publication_date=ExpressionWrapper(query, output_field=DateField())+ published_at=ExpressionWrapper(query, output_field=DateTimeField()))def annotate_visible_in_listings(self, channel_slug):@@ -547,7 +548,7 @@ class ProductChannelListing(PublishableModel):on_delete=models.CASCADE,)visible_in_listings = models.BooleanField(default=False)- available_for_purchase = models.DateField(blank=True, null=True)+ available_for_purchase_at = models.DateTimeField(blank=True, null=True)currency = models.CharField(max_length=settings.DEFAULT_CURRENCY_CODE_LENGTH)discounted_price_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,@@ -563,14 +564,14 @@ class ProductChannelListing(PublishableModel):unique_together = [["product", "channel"]]ordering = ("pk",)indexes = [- models.Index(fields=["publication_date"]),+ models.Index(fields=["published_at"]),BTreeIndex(fields=["discounted_price_amount"]),]def is_available_for_purchase(self):return (- self.available_for_purchase is not None- and datetime.date.today() >= self.available_for_purchase+ self.available_for_purchase_at is not None+ and datetime.datetime.now(pytz.UTC) >= self.available_for_purchase_at)@@ -847,10 +848,10 @@ class CollectionProduct(SortableModel):class CollectionsQueryset(models.QuerySet):def published(self, channel_slug: str):- today = datetime.date.today()+ today = datetime.datetime.now(pytz.UTC)return self.filter(- Q(channel_listings__publication_date__lte=today)- | Q(channel_listings__publication_date__isnull=True),+ Q(channel_listings__published_at__lte=today)+ | Q(channel_listings__published_at__isnull=True),channel_listings__channel__slug=str(channel_slug),channel_listings__channel__is_active=True,channel_listings__is_published=True,diff --git a/saleor/product/tests/test_category.py b/saleor/product/tests/test_category.pyindex 8ca052cfb6..5e819818a4 100644--- a/saleor/product/tests/test_category.py+++ b/saleor/product/tests/test_category.py@@ -43,7 +43,7 @@ def test_delete_categories(assert not product.categoryfor product_channel_listing in product.channel_listings.all():assert not product_channel_listing.is_published- assert not product_channel_listing.publication_date+ assert not product_channel_listing.published_at@patch("saleor.plugins.manager.PluginsManager.product_updated")diff --git a/saleor/product/tests/test_product_availability.py b/saleor/product/tests/test_product_availability.pyindex 4f8d845457..5b9d75045c 100644--- a/saleor/product/tests/test_product_availability.py+++ b/saleor/product/tests/test_product_availability.py@@ -2,6 +2,7 @@ import datetimefrom decimal import Decimalfrom unittest.mock import Mock+from django.utils import timezonefrom django_countries.fields import Countryfrom freezegun import freeze_timefrom prices import Money, TaxedMoney, TaxedMoneyRange@@ -183,9 +184,9 @@ def test_available_products_only_published(product_list, channel_USD):def test_available_products_only_available(product_list, channel_USD):channel_listing = product_list[0].channel_listings.get()- date_tomorrow = datetime.date.today() + datetime.timedelta(days=1)- channel_listing.publication_date = date_tomorrow- channel_listing.save(update_fields=["publication_date"])+ date_tomorrow = timezone.now() + datetime.timedelta(days=1)+ channel_listing.published_at = date_tomorrow+ channel_listing.save(update_fields=["published_at"])available_products = models.Product.objects.published(channel_USD.slug)assert available_products.count() == 2@@ -199,9 +200,9 @@ def test_available_products_only_available(product_list, channel_USD):def test_available_products_available_from_yesterday(product_list, channel_USD):channel_listing = product_list[0].channel_listings.get()- date_tomorrow = datetime.date.today() - datetime.timedelta(days=1)- channel_listing.publication_date = date_tomorrow- channel_listing.save(update_fields=["publication_date"])+ date_tomorrow = timezone.now() - datetime.timedelta(days=1)+ channel_listing.published_at = date_tomorrow+ channel_listing.save(update_fields=["published_at"])available_products = models.Product.objects.published(channel_USD.slug)assert available_products.count() == 3@@ -236,7 +237,7 @@ def test_available_products_available_with_many_channels(@freeze_time("2020-03-18 12:00:00")def test_product_is_visible_from_today(product):product_channel_listing = product.channel_listings.get()- product_channel_listing.publication_date = datetime.date.today()+ product_channel_listing.published_at = timezone.now()product_channel_listing.save()assert product_channel_listing.is_visible@@ -304,22 +305,22 @@ def test_filter_not_published_product_is_unpublished(product, channel_USD):def test_filter_not_published_product_published_tomorrow(product, channel_USD):- date_tomorrow = datetime.date.today() + datetime.timedelta(days=1)+ date_tomorrow = timezone.now() + datetime.timedelta(days=1)channel_listing = product.channel_listings.get()channel_listing.is_published = True- channel_listing.publication_date = date_tomorrow- channel_listing.save(update_fields=["is_published", "publication_date"])+ channel_listing.published_at = date_tomorrow+ channel_listing.save(update_fields=["is_published", "published_at"])available_products = models.Product.objects.not_published(channel_USD.slug)assert available_products.count() == 1def test_filter_not_published_product_not_published_tomorrow(product, channel_USD):- date_tomorrow = datetime.date.today() + datetime.timedelta(days=1)+ date_tomorrow = timezone.now() + datetime.timedelta(days=1)channel_listing = product.channel_listings.get()channel_listing.is_published = False- channel_listing.publication_date = date_tomorrow- channel_listing.save(update_fields=["is_published", "publication_date"])+ channel_listing.published_at = date_tomorrow+ channel_listing.save(update_fields=["is_published", "published_at"])available_products = models.Product.objects.not_published(channel_USD.slug)assert available_products.count() == 1diff --git a/saleor/product/utils/__init__.py b/saleor/product/utils/__init__.pyindex 633cf4b09c..2a999ee5ee 100644--- a/saleor/product/utils/__init__.py+++ b/saleor/product/utils/__init__.py@@ -49,7 +49,7 @@ def delete_categories(categories_ids: List[str], manager):products = products | collect_categories_tree_products(category)ProductChannelListing.objects.filter(product__in=products).update(- is_published=False, publication_date=None+ is_published=False, published_at=None)products = list(products)diff --git a/saleor/static/populatedb_data.json b/saleor/static/populatedb_data.jsonindex 56197c3d73..e3a878faa7 100644--- a/saleor/static/populatedb_data.json+++ b/saleor/static/populatedb_data.json@@ -1680,12 +1680,12 @@"model": "product.productchannellisting","pk": 1,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 72,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1693,12 +1693,12 @@"model": "product.productchannellisting","pk": 2,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 74,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1706,12 +1706,12 @@"model": "product.productchannellisting","pk": 3,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 122,"channel": 1,"visible_in_listings": false,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1719,12 +1719,12 @@"model": "product.productchannellisting","pk": 4,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 79,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1732,12 +1732,12 @@"model": "product.productchannellisting","pk": 5,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 115,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1745,12 +1745,12 @@"model": "product.productchannellisting","pk": 6,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 116,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1758,12 +1758,12 @@"model": "product.productchannellisting","pk": 7,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 73,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1771,12 +1771,12 @@"model": "product.productchannellisting","pk": 8,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 76,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1784,12 +1784,12 @@"model": "product.productchannellisting","pk": 9,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 89,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1797,12 +1797,12 @@"model": "product.productchannellisting","pk": 10,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 85,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1810,12 +1810,12 @@"model": "product.productchannellisting","pk": 11,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 78,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1823,12 +1823,12 @@"model": "product.productchannellisting","pk": 12,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 65,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2021-08-31",+ "available_for_purchase_at": "2021-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1836,12 +1836,12 @@"model": "product.productchannellisting","pk": 13,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 123,"channel": 1,"visible_in_listings": false,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1849,12 +1849,12 @@"model": "product.productchannellisting","pk": 14,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 120,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1862,12 +1862,12 @@"model": "product.productchannellisting","pk": 15,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 64,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2021-08-31",+ "available_for_purchase_at": "2021-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1875,12 +1875,12 @@"model": "product.productchannellisting","pk": 16,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 117,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1888,12 +1888,12 @@"model": "product.productchannellisting","pk": 17,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 61,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1901,12 +1901,12 @@"model": "product.productchannellisting","pk": 18,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 121,"channel": 1,"visible_in_listings": false,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1914,12 +1914,12 @@"model": "product.productchannellisting","pk": 19,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 71,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1927,12 +1927,12 @@"model": "product.productchannellisting","pk": 20,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 75,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1940,12 +1940,12 @@"model": "product.productchannellisting","pk": 21,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 107,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1953,12 +1953,12 @@"model": "product.productchannellisting","pk": 22,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 108,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1966,12 +1966,12 @@"model": "product.productchannellisting","pk": 23,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 109,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1979,12 +1979,12 @@"model": "product.productchannellisting","pk": 24,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 110,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -1992,12 +1992,12 @@"model": "product.productchannellisting","pk": 25,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 77,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -2005,12 +2005,12 @@"model": "product.productchannellisting","pk": 26,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 63,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2021-08-31",+ "available_for_purchase_at": "2021-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -2018,12 +2018,12 @@"model": "product.productchannellisting","pk": 27,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 81,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -2031,12 +2031,12 @@"model": "product.productchannellisting","pk": 28,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 119,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -2044,12 +2044,12 @@"model": "product.productchannellisting","pk": 29,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 84,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -2057,12 +2057,12 @@"model": "product.productchannellisting","pk": 30,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 83,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -2070,12 +2070,12 @@"model": "product.productchannellisting","pk": 31,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 62,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2021-08-31",+ "available_for_purchase_at": "2021-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -2083,12 +2083,12 @@"model": "product.productchannellisting","pk": 32,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 112,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -2096,12 +2096,12 @@"model": "product.productchannellisting","pk": 33,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 111,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -2109,12 +2109,12 @@"model": "product.productchannellisting","pk": 34,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 114,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -2122,12 +2122,12 @@"model": "product.productchannellisting","pk": 35,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 113,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -2135,12 +2135,12 @@"model": "product.productchannellisting","pk": 36,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 124,"channel": 1,"visible_in_listings": false,- "available_for_purchase": "2021-08-31",+ "available_for_purchase_at": "2021-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -2148,12 +2148,12 @@"model": "product.productchannellisting","pk": 37,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 118,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -2161,12 +2161,12 @@"model": "product.productchannellisting","pk": 38,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 86,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -2174,12 +2174,12 @@"model": "product.productchannellisting","pk": 39,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 88,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -2187,12 +2187,12 @@"model": "product.productchannellisting","pk": 40,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 82,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -2200,12 +2200,12 @@"model": "product.productchannellisting","pk": 41,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 87,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD"}},@@ -2213,12 +2213,12 @@"model": "product.productchannellisting","pk": 42,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 72,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2226,12 +2226,12 @@"model": "product.productchannellisting","pk": 43,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 74,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2239,12 +2239,12 @@"model": "product.productchannellisting","pk": 44,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 122,"channel": 2,"visible_in_listings": false,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2252,12 +2252,12 @@"model": "product.productchannellisting","pk": 45,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 79,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2265,12 +2265,12 @@"model": "product.productchannellisting","pk": 46,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 115,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2278,12 +2278,12 @@"model": "product.productchannellisting","pk": 47,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 116,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2291,12 +2291,12 @@"model": "product.productchannellisting","pk": 48,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 73,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2304,12 +2304,12 @@"model": "product.productchannellisting","pk": 49,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 76,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2317,12 +2317,12 @@"model": "product.productchannellisting","pk": 50,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 89,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2330,12 +2330,12 @@"model": "product.productchannellisting","pk": 51,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 85,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2343,12 +2343,12 @@"model": "product.productchannellisting","pk": 52,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 78,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2356,12 +2356,12 @@"model": "product.productchannellisting","pk": 53,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 65,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2021-08-31",+ "available_for_purchase_at": "2021-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2369,12 +2369,12 @@"model": "product.productchannellisting","pk": 54,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 123,"channel": 2,"visible_in_listings": false,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2382,12 +2382,12 @@"model": "product.productchannellisting","pk": 55,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 120,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2395,12 +2395,12 @@"model": "product.productchannellisting","pk": 56,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 64,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2021-08-31",+ "available_for_purchase_at": "2021-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2408,12 +2408,12 @@"model": "product.productchannellisting","pk": 57,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 117,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2421,12 +2421,12 @@"model": "product.productchannellisting","pk": 58,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 61,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2434,12 +2434,12 @@"model": "product.productchannellisting","pk": 59,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 121,"channel": 2,"visible_in_listings": false,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2447,12 +2447,12 @@"model": "product.productchannellisting","pk": 60,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 71,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2460,12 +2460,12 @@"model": "product.productchannellisting","pk": 61,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 75,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2473,12 +2473,12 @@"model": "product.productchannellisting","pk": 62,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 107,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2486,12 +2486,12 @@"model": "product.productchannellisting","pk": 63,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 108,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2499,12 +2499,12 @@"model": "product.productchannellisting","pk": 64,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 109,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2512,12 +2512,12 @@"model": "product.productchannellisting","pk": 65,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 110,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2525,12 +2525,12 @@"model": "product.productchannellisting","pk": 66,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 77,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2538,12 +2538,12 @@"model": "product.productchannellisting","pk": 67,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 63,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2021-08-31",+ "available_for_purchase_at": "2021-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2551,12 +2551,12 @@"model": "product.productchannellisting","pk": 68,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 81,"channel": 2,"visible_in_listings": false,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2564,12 +2564,12 @@"model": "product.productchannellisting","pk": 69,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 119,"channel": 2,"visible_in_listings": false,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2577,12 +2577,12 @@"model": "product.productchannellisting","pk": 70,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": false,"product": 84,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2590,12 +2590,12 @@"model": "product.productchannellisting","pk": 71,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": false,"product": 83,"channel": 2,"visible_in_listings": false,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN"}},@@ -2603,12 +2603,12 @@"model": "product.productchannellisting","pk": 72,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 125,"channel": 2,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "PLN","discounted_price_amount": "100.000"}@@ -2617,12 +2617,12 @@"model": "product.productchannellisting","pk": 73,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"product": 125,"channel": 1,"visible_in_listings": true,- "available_for_purchase": "2020-08-31",+ "available_for_purchase_at": "2020-08-31 10:10:10.0+00:00","currency": "USD","discounted_price_amount": "100.000"}@@ -10928,7 +10928,7 @@"model": "product.collectionchannellisting","pk": 1,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"collection": 1,"channel": 1@@ -10938,7 +10938,7 @@"model": "product.collectionchannellisting","pk": 2,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"collection": 2,"channel": 1@@ -10948,7 +10948,7 @@"model": "product.collectionchannellisting","pk": 3,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"collection": 1,"channel": 2@@ -10958,7 +10958,7 @@"model": "product.collectionchannellisting","pk": 4,"fields": {- "publication_date": null,+ "published_at": null,"is_published": false,"collection": 2,"channel": 2@@ -10968,7 +10968,7 @@"model": "product.collectionchannellisting","pk": 5,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"collection": 3,"channel": 1@@ -10978,7 +10978,7 @@"model": "product.collectionchannellisting","pk": 6,"fields": {- "publication_date": "2020-01-01",+ "published_at": "2020-01-01 10:10:10.0+00:00","is_published": true,"collection": 3,"channel": 2diff --git a/saleor/tests/fixtures.py b/saleor/tests/fixtures.pyindex bd12b65a9d..4a2f3b8494 100644--- a/saleor/tests/fixtures.py+++ b/saleor/tests/fixtures.py@@ -1698,7 +1698,7 @@ def categories_tree_with_published_products(ProductChannelListing(product=product,channel=channel_USD,- publication_date=datetime.date.today(),+ published_at=datetime.datetime.now(pytz.UTC),is_published=True,))@@ -1706,7 +1706,7 @@ def categories_tree_with_published_products(ProductChannelListing(product=product,channel=channel_PLN,- publication_date=datetime.date.today(),+ published_at=datetime.datetime.now(pytz.UTC),is_published=True,))@@ -1840,7 +1840,7 @@ def product(product_type, category, warehouse, channel_USD):discounted_price_amount="10.00",currency=channel_USD.currency_code,visible_in_listings=True,- available_for_purchase=datetime.date(1999, 1, 1),+ available_for_purchase_at=datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC),)associate_attribute_values_to_instance(product, product_attr, product_attr_value)@@ -1882,7 +1882,7 @@ def shippable_gift_card_product(discounted_price_amount="100.00",currency=channel_USD.currency_code,visible_in_listings=True,- available_for_purchase=datetime.date(1999, 1, 1),+ available_for_purchase_at=datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC),)variant = ProductVariant.objects.create(@@ -1919,7 +1919,7 @@ def product_price_0(category, warehouse, channel_USD):channel=channel_USD,is_published=True,visible_in_listings=True,- available_for_purchase=datetime.date(1999, 1, 1),+ available_for_purchase_at=datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC),)variant = ProductVariant.objects.create(product=product, sku="SKU_C")ProductVariantChannelListing.objects.create(@@ -1942,7 +1942,7 @@ def product_in_channel_JPY(product, channel_JPY, warehouse_JPY):discounted_price_amount="1200",currency=channel_JPY.currency_code,visible_in_listings=True,- available_for_purchase=datetime.date(1999, 1, 1),+ available_for_purchase_at=datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC),)variant = product.variants.get()ProductVariantChannelListing.objects.create(@@ -1975,7 +1975,7 @@ def non_shippable_gift_card_product(discounted_price_amount="200.00",currency=channel_USD.currency_code,visible_in_listings=True,- available_for_purchase=datetime.date(1999, 1, 1),+ available_for_purchase_at=datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC),)variant = ProductVariant.objects.create(@@ -2013,7 +2013,7 @@ def product_with_rich_text_attribute(discounted_price_amount="10.00",currency=channel_USD.currency_code,visible_in_listings=True,- available_for_purchase=datetime.date(1999, 1, 1),+ available_for_purchase_at=datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC),)associate_attribute_values_to_instance(product, product_attr, product_attr_value)@@ -2074,7 +2074,7 @@ def product_with_single_variant(product_type, category, warehouse, channel_USD):channel=channel_USD,is_published=True,visible_in_listings=True,- available_for_purchase=datetime.date(1999, 1, 1),+ available_for_purchase_at=datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC),)variant = ProductVariant.objects.create(product=product, sku="SKU_SINGLE_VARIANT")ProductVariantChannelListing.objects.create(@@ -2102,7 +2102,7 @@ def product_with_two_variants(product_type, category, warehouse, channel_USD):channel=channel_USD,is_published=True,visible_in_listings=True,- available_for_purchase=datetime.date(1999, 1, 1),+ available_for_purchase_at=datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC),)variants = [@@ -2166,7 +2166,7 @@ def product_with_variant_with_two_attributes(is_published=True,currency=channel_USD.currency_code,visible_in_listings=True,- available_for_purchase=datetime.date(1999, 1, 1),+ available_for_purchase_at=datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC),)variant = ProductVariant.objects.create(product=product, sku="prodVar1")@@ -2227,7 +2227,7 @@ def product_with_variant_with_external_media(is_published=True,currency=channel_USD.currency_code,visible_in_listings=True,- available_for_purchase=datetime.date(1999, 1, 1),+ available_for_purchase_at=datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC),)variant = ProductVariant.objects.create(product=product, sku="prodVar1")@@ -2275,7 +2275,7 @@ def product_with_variant_with_file_attribute(is_published=True,currency=channel_USD.currency_code,visible_in_listings=True,- available_for_purchase=datetime.date(1999, 1, 1),+ available_for_purchase_at=datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC),)variant = ProductVariant.objects.create(@@ -2336,7 +2336,7 @@ def product_with_default_variant(channel=channel_USD,is_published=True,visible_in_listings=True,- available_for_purchase=datetime.date(1999, 1, 1),+ available_for_purchase_at=datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC),)variant = ProductVariant.objects.create(product=product, sku="1234", track_inventory=True@@ -2371,7 +2371,7 @@ def variant_without_inventory_tracking(channel=channel_USD,is_published=True,visible_in_listings=True,- available_for_purchase=datetime.date.today(),+ available_for_purchase_at=datetime.datetime.now(pytz.UTC),)variant = ProductVariant.objects.create(product=product,@@ -2620,7 +2620,7 @@ def product_without_shipping(category, warehouse, channel_USD):channel=channel_USD,is_published=True,visible_in_listings=True,- available_for_purchase=datetime.date(1999, 1, 1),+ available_for_purchase_at=datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC),)variant = ProductVariant.objects.create(product=product, sku="SKU_B")ProductVariantChannelListing.objects.create(@@ -2683,7 +2683,9 @@ def product_list(product_type, category, warehouse, channel_USD, channel_PLN):discounted_price_amount=10,currency=channel_USD.currency_code,visible_in_listings=True,- available_for_purchase=datetime.date(1999, 1, 1),+ available_for_purchase_at=(+ datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC)+ ),),ProductChannelListing(product=products[1],@@ -2692,7 +2694,9 @@ def product_list(product_type, category, warehouse, channel_USD, channel_PLN):discounted_price_amount=20,currency=channel_USD.currency_code,visible_in_listings=True,- available_for_purchase=datetime.date(1999, 1, 1),+ available_for_purchase_at=(+ datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC)+ ),),ProductChannelListing(product=products[2],@@ -2701,7 +2705,9 @@ def product_list(product_type, category, warehouse, channel_USD, channel_PLN):discounted_price_amount=30,currency=channel_USD.currency_code,visible_in_listings=True,- available_for_purchase=datetime.date(1999, 1, 1),+ available_for_purchase_at=(+ datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC)+ ),),])@@ -3528,7 +3534,7 @@ def order_with_lines(channel=channel_USD,is_published=True,visible_in_listings=True,- available_for_purchase=datetime.date.today(),+ available_for_purchase_at=datetime.datetime.now(pytz.UTC),)variant = ProductVariant.objects.create(product=product, sku="SKU_AA")channel_listing = ProductVariantChannelListing.objects.create(@@ -3576,7 +3582,7 @@ def order_with_lines(channel=channel_USD,is_published=True,visible_in_listings=True,- available_for_purchase=datetime.date.today(),+ available_for_purchase_at=timezone.now(),)variant = ProductVariant.objects.create(product=product, sku="SKU_B")channel_listing = ProductVariantChannelListing.objects.create(@@ -3763,7 +3769,7 @@ def order_with_lines_channel_PLN(channel=channel_PLN,is_published=True,visible_in_listings=True,- available_for_purchase=datetime.date.today(),+ available_for_purchase_at=timezone.now(),)variant = ProductVariant.objects.create(product=product, sku="SKU_A_PLN")channel_listing = ProductVariantChannelListing.objects.create(@@ -3811,7 +3817,7 @@ def order_with_lines_channel_PLN(channel=channel_PLN,is_published=True,visible_in_listings=True,- available_for_purchase=datetime.date.today(),+ available_for_purchase_at=timezone.now(),)variant = ProductVariant.objects.create(product=product, sku="SKU_B_PLN")channel_listing = ProductVariantChannelListing.objects.create(@@ -3919,7 +3925,7 @@ def order_with_preorder_lines(channel=channel_USD,is_published=True,visible_in_listings=True,- available_for_purchase=datetime.date.today(),+ available_for_purchase_at=timezone.now(),)variant = ProductVariant.objects.create(product=product, sku="SKU_AA_P", is_preorder=True@@ -4450,7 +4456,7 @@ def published_collection(db, channel_USD):channel=channel_USD,collection=collection,is_published=True,- publication_date=datetime.date.today(),+ published_at=timezone.now(),)return collection@@ -4466,7 +4472,7 @@ def published_collection_PLN(db, channel_PLN):channel=channel_PLN,collection=collection,is_published=True,- publication_date=datetime.date.today(),+ published_at=timezone.now(),)return collection@@ -4939,7 +4945,7 @@ def digital_content(category, media_root, warehouse, channel_USD) -> DigitalContchannel=channel_USD,is_published=True,visible_in_listings=True,- available_for_purchase=datetime.date(1999, 1, 1),+ available_for_purchase_at=datetime.datetime(1999, 1, 1, tzinfo=pytz.UTC),)product_variant = ProductVariant.objects.create(product=product, sku="SKU_554")ProductVariantChannelListing.objects.create(diff --git a/saleor/webhook/payloads.py b/saleor/webhook/payloads.pyindex 192df374f4..0e32f4060c 100644--- a/saleor/webhook/payloads.py+++ b/saleor/webhook/payloads.py@@ -579,15 +579,21 @@ PRODUCT_FIELDS = (def serialize_product_channel_listing_payload(channel_listings):serializer = PayloadSerializer()fields = (- "publication_date",+ "published_at","id_published","visible_in_listings",- "available_for_purchase",+ "available_for_purchase_at",)channel_listing_payload = serializer.serialize(channel_listings,fields=fields,- extra_dict_data={"channel_slug": lambda pch: pch.channel.slug},+ extra_dict_data={+ "channel_slug": lambda pch: pch.channel.slug,+ # deprecated in 3.3 - published_at and available_for_purchase_at+ # should be used instead+ "publication_date": lambda pch: pch.published_at,+ "available_for_purchase": lambda pch: pch.available_for_purchase_at,+ },)return channel_listing_payload@@ -874,7 +880,7 @@ def generate_page_payload("metadata","title","content",- "publication_date",+ "published_at","is_published","updated_at",]@@ -882,7 +888,9 @@ def generate_page_payload([page],fields=page_fields,extra_dict_data={- "data": generate_meta(requestor_data=generate_requestor(requestor))+ "data": generate_meta(requestor_data=generate_requestor(requestor)),+ # deprecated in 3.3 - published_at should be used instead+ "publication_date": page.published_at,},)return page_payload