Skip to content

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

Rename available_on to publication_date on product model

Michał Jelonekf76f8a85e44d
diff --git a/docs/architecture/products.rst b/docs/architecture/products.rst
index b0d5d090a9..c4763ece8d 100644
--- a/docs/architecture/products.rst
+++ b/docs/architecture/products.rst
@@ -27,7 +27,7 @@ Products
Describes common details of a few *product variants*. When the shop displays the category view, items on the list are distinct *products*. If the variant has no overridden property (example: price), the default value is taken from the *product*.
-- ``available_on``
+- ``publication_date``
Until this date the product is not listed in storefront and is unavailable for users.
- ``is_featured``
diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.py
index 1105441be5..abbad40d1a 100644
--- a/saleor/dashboard/product/forms.py
+++ b/saleor/dashboard/product/forms.py
@@ -248,7 +248,7 @@ class ProductForm(forms.ModelForm, AttributesMixin):
labels = {
'name': pgettext_lazy('Item name', 'Name'),
'price': pgettext_lazy('Currency amount', 'Price'),
- 'available_on': pgettext_lazy(
+ 'publication_date': pgettext_lazy(
'Availability date', 'Publish product on'),
'is_published': pgettext_lazy(
'Product published toggle', 'Published'),
diff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.py
index 8edb5e280c..7ce943203a 100644
--- a/saleor/graphql/product/mutations/products.py
+++ b/saleor/graphql/product/mutations/products.py
@@ -260,7 +260,7 @@ class ProductInput(graphene.InputObjectType):
attributes = graphene.List(
AttributeValueInput,
description='List of attributes.')
- available_on = graphene.types.datetime.Date(
+ publication_date = graphene.types.datetime.Date(
description='Publication date. ISO 8601 standard.')
category = graphene.ID(
description='ID of the product\'s category.', name='category')
diff --git a/saleor/graphql/product/types.py b/saleor/graphql/product/types.py
index 610d594fab..e95da9407e 100644
--- a/saleor/graphql/product/types.py
+++ b/saleor/graphql/product/types.py
@@ -267,6 +267,9 @@ class Product(CountableDjangoObjectType):
lambda: Collection,
description='List of collections for the product'),
model_field='collections')
+ available_on = graphene.Date(
+ deprecation_reason=(
+ 'availableOn is deprecated, use publicationDate instead'))
class Meta:
description = dedent("""Represents an individual item for sale in the
@@ -298,7 +301,7 @@ class Product(CountableDjangoObjectType):
@gql_optimizer.resolver_hints(
prefetch_related='variants',
- only=['available_on', 'charge_taxes', 'price', 'tax_rate'])
+ only=['publication_date', 'charge_taxes', 'price', 'tax_rate'])
def resolve_availability(self, info):
context = info.context
availability = get_availability(
@@ -338,6 +341,9 @@ class Product(CountableDjangoObjectType):
def resolve_collections(self, info):
return self.collections.all()
+ def resolve_available_on(self, info):
+ return self.publication_date
+
def prefetch_products(info, *args, **kwargs):
"""Prefetch products visible to the current user.
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 545a3aa495..1195496ccd 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -328,7 +328,7 @@ type CheckoutCreate {
input CheckoutCreateInput {
lines: [CheckoutLineInput]!
- email: String!
+ email: String
shippingAddress: AddressInput
billingAddress: AddressInput
}
@@ -1332,7 +1332,7 @@ type Product implements Node {
description: String!
category: Category!
price: Money
- availableOn: Date
+ publicationDate: Date
isPublished: Boolean!
attributes: [SelectedAttribute!]!
updatedAt: DateTime
@@ -1349,6 +1349,7 @@ type Product implements Node {
purchaseCost: MoneyRange
margin: Margin
imageById(id: ID): ProductImage
+ availableOn: Date @deprecated(reason: "availableOn is deprecated, use publicationDate instead")
}
type ProductAvailability {
@@ -1379,7 +1380,7 @@ type ProductCreate {
input ProductCreateInput {
attributes: [AttributeValueInput]
- availableOn: Date
+ publicationDate: Date
category: ID
chargeTaxes: Boolean
collections: [ID]
@@ -1444,7 +1445,7 @@ input ProductImageUpdateInput {
input ProductInput {
attributes: [AttributeValueInput]
- availableOn: Date
+ publicationDate: Date
category: ID
chargeTaxes: Boolean
collections: [ID]
diff --git a/saleor/product/migrations/0086_product_publication_date.py b/saleor/product/migrations/0086_product_publication_date.py
new file mode 100644
index 0000000000..c0ab68da0d
--- /dev/null
+++ b/saleor/product/migrations/0086_product_publication_date.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.1.5 on 2019-02-05 11:31
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('product', '0085_auto_20190125_0025'),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name='product',
+ old_name='available_on',
+ new_name='publication_date',
+ )
+ ]
diff --git a/saleor/product/models.py b/saleor/product/models.py
index 2e263a4965..65d2aa49d0 100644
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -101,7 +101,7 @@ class ProductQuerySet(models.QuerySet):
def available_products(self):
today = datetime.date.today()
return self.filter(
- Q(available_on__lte=today) | Q(available_on__isnull=True),
+ Q(publication_date__lte=today) | Q(publication_date__isnull=True),
Q(is_published=True))
def visible_to_user(self, user):
@@ -123,7 +123,7 @@ class Product(SeoModel):
currency=settings.DEFAULT_CURRENCY,
max_digits=settings.DEFAULT_MAX_DIGITS,
decimal_places=settings.DEFAULT_DECIMAL_PLACES)
- available_on = models.DateField(blank=True, null=True)
+ publication_date = models.DateField(blank=True, null=True)
is_published = models.BooleanField(default=True)
attributes = HStoreField(default=dict, blank=True)
updated_at = models.DateTimeField(auto_now=True, null=True)
@@ -172,7 +172,7 @@ class Product(SeoModel):
def is_available(self):
today = datetime.date.today()
- return self.available_on is None or self.available_on <= today
+ return self.publication_date is None or self.publication_date <= today
def get_first_image(self):
images = list(self.images.all())
diff --git a/saleor/product/utils/availability.py b/saleor/product/utils/availability.py
index 6a7c61aec5..50f7c8cae6 100644
--- a/saleor/product/utils/availability.py
+++ b/saleor/product/utils/availability.py
@@ -34,7 +34,7 @@ def get_product_availability_status(product):
return ProductAvailabilityStatus.OUT_OF_STOCK
if not are_all_variants_in_stock:
return ProductAvailabilityStatus.LOW_STOCK
- if not is_available and product.available_on is not None:
+ if not is_available and product.publication_date is not None:
return ProductAvailabilityStatus.NOT_YET_AVAILABLE
return ProductAvailabilityStatus.READY_FOR_PURCHASE
diff --git a/saleor/product/views.py b/saleor/product/views.py
index ccecdcb1b3..2e7297935d 100644
--- a/saleor/product/views.py
+++ b/saleor/product/views.py
@@ -56,7 +56,7 @@ def product_details(request, slug, product_id, form=None):
return HttpResponsePermanentRedirect(product.get_absolute_url())
today = datetime.date.today()
is_visible = (
- product.available_on is None or product.available_on <= today)
+ product.publication_date is None or product.publication_date <= today)
if form is None:
form = handle_cart_form(request, product, create_cart=False)[0]
availability = get_availability(
diff --git a/saleor/static/dashboard-next/auth/types/TokenAuth.ts b/saleor/static/dashboard-next/auth/types/TokenAuth.ts
index b3e37a805d..2cfb49f11f 100644
--- a/saleor/static/dashboard-next/auth/types/TokenAuth.ts
+++ b/saleor/static/dashboard-next/auth/types/TokenAuth.ts
@@ -31,7 +31,7 @@ export interface TokenAuth_tokenCreate_user {
export interface TokenAuth_tokenCreate {
__typename: "CreateToken";
token: string | null;
- errors: (TokenAuth_tokenCreate_errors | null)[] | null;
+ errors: (TokenAuth_tokenCreate_errors | null)[];
user: TokenAuth_tokenCreate_user | null;
}
diff --git a/saleor/static/dashboard-next/gql-types.ts b/saleor/static/dashboard-next/gql-types.ts
index 72331852f8..1445435b92 100644
--- a/saleor/static/dashboard-next/gql-types.ts
+++ b/saleor/static/dashboard-next/gql-types.ts
@@ -1790,7 +1790,7 @@ export interface ProductImageCreateMutation {
} | null;
isPublished: boolean;
chargeTaxes: boolean;
- availableOn: string | null;
+ publicationDate: string | null;
// List of product attributes assigned to this product.
attributes: Array<{
// Name of an attribute
@@ -1955,7 +1955,7 @@ export interface ProductImageReorderMutation {
export interface ProductUpdateMutationVariables {
id: string;
attributes?: Array<AttributeValueInput | null> | null;
- availableOn?: string | null;
+ publicationDate?: string | null;
category?: string | null;
chargeTaxes: boolean;
collections?: Array<string | null> | null;
@@ -2028,7 +2028,7 @@ export interface ProductUpdateMutation {
} | null;
isPublished: boolean;
chargeTaxes: boolean;
- availableOn: string | null;
+ publicationDate: string | null;
// List of product attributes assigned to this product.
attributes: Array<{
// Name of an attribute
@@ -2134,7 +2134,7 @@ export interface ProductUpdateMutation {
export interface ProductCreateMutationVariables {
attributes?: Array<AttributeValueInput | null> | null;
- availableOn?: string | null;
+ publicationDate?: string | null;
category: string;
chargeTaxes: boolean;
collections?: Array<string | null> | null;
@@ -2208,7 +2208,7 @@ export interface ProductCreateMutation {
} | null;
isPublished: boolean;
chargeTaxes: boolean;
- availableOn: string | null;
+ publicationDate: string | null;
// List of product attributes assigned to this product.
attributes: Array<{
// Name of an attribute
@@ -2684,7 +2684,7 @@ export interface ProductImageUpdateMutation {
} | null;
isPublished: boolean;
chargeTaxes: boolean;
- availableOn: string | null;
+ publicationDate: string | null;
// List of product attributes assigned to this product.
attributes: Array<{
// Name of an attribute
@@ -3147,7 +3147,7 @@ export interface ProductDetailsQuery {
} | null;
isPublished: boolean;
chargeTaxes: boolean;
- availableOn: string | null;
+ publicationDate: string | null;
// List of product attributes assigned to this product.
attributes: Array<{
// Name of an attribute
@@ -3817,7 +3817,7 @@ export interface ProductFragment {
} | null;
isPublished: boolean;
chargeTaxes: boolean;
- availableOn: string | null;
+ publicationDate: string | null;
// List of product attributes assigned to this product.
attributes: Array<{
// Name of an attribute
diff --git a/saleor/static/dashboard-next/products/components/ProductAvailabilityForm/ProductAvailabilityForm.tsx b/saleor/static/dashboard-next/products/components/ProductAvailabilityForm/ProductAvailabilityForm.tsx
index c64d5065c5..871977b3f3 100644
--- a/saleor/static/dashboard-next/products/components/ProductAvailabilityForm/ProductAvailabilityForm.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductAvailabilityForm/ProductAvailabilityForm.tsx
@@ -29,7 +29,7 @@ const styles = (theme: Theme) =>
interface ProductAvailabilityFormProps extends WithStyles<typeof styles> {
data: {
available: boolean;
- availableOn: string;
+ publicationDate: string;
};
errors: { [key: string]: string };
loading?: boolean;
@@ -41,7 +41,7 @@ export const ProductAvailabilityForm = withStyles(styles, {
})(
({
classes,
- data: { available, availableOn },
+ data: { available, publicationDate },
errors,
loading,
onChange
@@ -67,14 +67,14 @@ export const ProductAvailabilityForm = withStyles(styles, {
{available && (
<>
<TextField
- error={!!errors.availableOn}
+ error={!!errors.publicationDate}
disabled={loading}
label={i18n.t("Publish product on")}
- name="availableOn"
+ name="publicationDate"
type="date"
fullWidth={true}
- helperText={errors.availableOn}
- value={availableOn ? availableOn : ""}
+ helperText={errors.publicationDate}
+ value={publicationDate ? publicationDate : ""}
onChange={onChange}
className={classes.date}
InputLabelProps={{
diff --git a/saleor/static/dashboard-next/products/components/ProductCreatePage/ProductCreatePage.tsx b/saleor/static/dashboard-next/products/components/ProductCreatePage/ProductCreatePage.tsx
index d301adf7ef..8c30a77805 100644
--- a/saleor/static/dashboard-next/products/components/ProductCreatePage/ProductCreatePage.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductCreatePage/ProductCreatePage.tsx
@@ -26,7 +26,7 @@ export interface FormData {
value: string;
}>;
available: boolean;
- availableOn: string;
+ publicationDate: string;
category: ChoiceType;
chargeTaxes: boolean;
collections: ChoiceType[];
@@ -94,7 +94,6 @@ export const ProductCreatePage: React.StatelessComponent<
const initialData: FormData = {
attributes: [],
available: false,
- availableOn: "",
category: {
label: "",
value: ""
@@ -113,6 +112,7 @@ export const ProductCreatePage: React.StatelessComponent<
productAttributes: [] as ProductCreateData_productTypes_edges_node_productAttributes[]
}
},
+ publicationDate: "",
seoDescription: "",
seoTitle: "",
sku: null,
diff --git a/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx b/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
index f73e955ffa..d7ffee1b12 100644
--- a/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
@@ -71,7 +71,6 @@ export interface FormData {
value: string;
}>;
available: boolean;
- availableOn: string;
category: ChoiceType | null;
chargeTaxes: boolean;
collections: ChoiceType[];
@@ -89,6 +88,7 @@ export interface FormData {
>;
};
} | null;
+ publicationDate: string;
seoDescription: string;
seoTitle: string;
sku: string;
@@ -130,7 +130,6 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
}))
: undefined,
available: product.isPublished,
- availableOn: product.availableOn,
category: product.category
? {
label: product.category.name,
@@ -159,6 +158,7 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
}
}
: undefined,
+ publicationDate: product.publicationDate,
seoDescription: product.seoDescription,
seoTitle: product.seoTitle,
sku:
@@ -177,7 +177,6 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
: {
attributes: [],
available: false,
- availableOn: "",
category: null,
chargeTaxes: false,
collections: [],
@@ -185,6 +184,7 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
name: "",
price: "",
productType: null,
+ publicationDate: "",
seoDescription: "",
seoTitle: "",
sku: "",
diff --git a/saleor/static/dashboard-next/products/fixtures.ts b/saleor/static/dashboard-next/products/fixtures.ts
index 7597190718..4f2ef28b59 100644
--- a/saleor/static/dashboard-next/products/fixtures.ts
+++ b/saleor/static/dashboard-next/products/fixtures.ts
@@ -122,7 +122,6 @@ export const product: (
}
}
},
- availableOn: "2018-08-25T18:45:54.125Z",
category: { __typename: "Category", id: "Q2F0ZWdvcnk6MQ==", name: "Apparel" },
chargeTaxes: true,
collections: [
@@ -215,6 +214,7 @@ export const product: (
}
]
},
+ publicationDate: "2018-08-25T18:45:54.125Z",
purchaseCost: {
__typename: "MoneyRange",
start: {
@@ -407,7 +407,6 @@ export const products = (placeholderImage: string) => [
}
],
availability: { available: true },
- availableOn: null,
category: { id: "Q2F0ZWdvcnk6MQ==", name: "Apparel" },
collections: {
edges: [{ node: { id: "Q29sbGVjdGlvbjoy", name: "Winter sale" } }]
@@ -437,6 +436,7 @@ export const products = (placeholderImage: string) => [
id: "pt41284",
name: "Awesome Wooden Pizza"
},
+ publicationDate: null,
purchaseCost: {
start: { amount: 274.99389477595827, currency: "XAG" },
stop: { amount: 274.99389477595827, currency: "XAG" }
@@ -568,7 +568,6 @@ export const products = (placeholderImage: string) => [
}
],
availability: { available: true },
- availableOn: null,
category: { id: "Q2F0ZWdvcnk6MQ==", name: "Apparel" },
collections: {
edges: [{ node: { id: "Q29sbGVjdGlvbjoy", name: "Winter sale" } }]
@@ -594,6 +593,7 @@ export const products = (placeholderImage: string) => [
name: "Handcrafted Wooden Towels",
price: { amount: 432.2991706153576, currency: "ZWL" },
productType: { hasVariants: false, id: "pt29020", name: "Future" },
+ publicationDate: null,
purchaseCost: {
start: { amount: 432.2991706153576, currency: "ZWL" },
stop: { amount: 8213.684241691793, currency: "ZWL" }
@@ -765,7 +765,6 @@ export const products = (placeholderImage: string) => [
}
],
availability: { available: false },
- availableOn: null,
category: { id: "Q2F0ZWdvcnk6MQ==", name: "Apparel" },
collections: {
edges: [{ node: { id: "Q29sbGVjdGlvbjoy", name: "Winter sale" } }]
@@ -791,6 +790,7 @@ export const products = (placeholderImage: string) => [
name: "Handcrafted Metal Cheese",
price: { amount: 688.3543328975433, currency: "XDR" },
productType: { hasVariants: true, id: "pt23508", name: "SMS" },
+ publicationDate: null,
purchaseCost: {
start: { amount: 688.3543328975433, currency: "XDR" },
stop: { amount: 3441.7716644877164, currency: "XDR" }
@@ -973,7 +973,6 @@ export const products = (placeholderImage: string) => [
}
],
availability: { available: false },
- availableOn: null,
category: { id: "Q2F0ZWdvcnk6MQ==", name: "Apparel" },
collections: {
edges: [{ node: { id: "Q29sbGVjdGlvbjoy", name: "Winter sale" } }]
@@ -999,6 +998,7 @@ export const products = (placeholderImage: string) => [
name: "Refined Rubber Keyboard",
price: { amount: 540.3817687240911, currency: "SLL" },
productType: { hasVariants: false, id: "pt20625", name: "Virtual" },
+ publicationDate: null,
purchaseCost: {
start: { amount: 540.3817687240911, currency: "SLL" },
stop: { amount: 4863.43591851682, currency: "SLL" }
@@ -1190,7 +1190,6 @@ export const products = (placeholderImage: string) => [
}
],
availability: { available: true },
- availableOn: null,
category: { id: "Q2F0ZWdvcnk6MQ==", name: "Apparel" },
collections: {
edges: [{ node: { id: "Q29sbGVjdGlvbjoy", name: "Winter sale" } }]
@@ -1216,6 +1215,7 @@ export const products = (placeholderImage: string) => [
name: "Gorgeous Metal Gloves",
price: { amount: 4.359138839276078, currency: "AMD" },
productType: { hasVariants: true, id: "pt91547", name: "Vermont" },
+ publicationDate: null,
purchaseCost: {
start: { amount: 4.359138839276078, currency: "AMD" },
stop: { amount: 74.10536026769333, currency: "AMD" }
@@ -1446,7 +1446,6 @@ export const products = (placeholderImage: string) => [
}
],
availability: { available: false },
- availableOn: null,
category: { id: "Q2F0ZWdvcnk6MQ==", name: "Apparel" },
collections: {
edges: [{ node: { id: "Q29sbGVjdGlvbjoy", name: "Winter sale" } }]
@@ -1472,6 +1471,7 @@ export const products = (placeholderImage: string) => [
name: "Small Cotton Shirt",
price: { amount: 538.0974149450597, currency: "GMD" },
productType: { hasVariants: false, id: "pt69941", name: "Gorgeous" },
+ publicationDate: null,
purchaseCost: {
start: { amount: 538.0974149450597, currency: "GMD" },
stop: { amount: 6457.168979340716, currency: "GMD" }
@@ -1641,7 +1641,6 @@ export const products = (placeholderImage: string) => [
}
],
availability: { available: false },
- availableOn: null,
category: { id: "Q2F0ZWdvcnk6MQ==", name: "Apparel" },
collections: {
edges: [{ node: { id: "Q29sbGVjdGlvbjoy", name: "Winter sale" } }]
@@ -1667,6 +1666,7 @@ export const products = (placeholderImage: string) => [
name: "Fantastic Cotton Tuna",
price: { amount: 56.90596710694962, currency: "CVE" },
productType: { hasVariants: true, id: "pt41677", name: "TCP" },
+ publicationDate: null,
purchaseCost: {
start: { amount: 56.90596710694962, currency: "CVE" },
stop: { amount: 227.62386842779847, currency: "CVE" }
@@ -1750,7 +1750,6 @@ export const products = (placeholderImage: string) => [
}
],
availability: { available: false },
- availableOn: null,
category: { id: "Q2F0ZWdvcnk6MQ==", name: "Apparel" },
collections: {
edges: [{ node: { id: "Q29sbGVjdGlvbjoy", name: "Winter sale" } }]
@@ -1776,6 +1775,7 @@ export const products = (placeholderImage: string) => [
name: "Tasty Steel Pants",
price: { amount: 981.0598640464501, currency: "XAG" },
productType: { hasVariants: true, id: "pt93233", name: "Buckinghamshire" },
+ publicationDate: null,
purchaseCost: {
start: { amount: 981.0598640464501, currency: "XAG" },
stop: { amount: 16678.017688789652, currency: "XAG" }
@@ -1957,7 +1957,6 @@ export const products = (placeholderImage: string) => [
}
],
availability: { available: true },
- availableOn: null,
category: { id: "Q2F0ZWdvcnk6MQ==", name: "Apparel" },
collections: {
edges: [{ node: { id: "Q29sbGVjdGlvbjoy", name: "Winter sale" } }]
@@ -1983,6 +1982,7 @@ export const products = (placeholderImage: string) => [
name: "Ergonomic Cotton Shoes",
price: { amount: 449.93166054829857, currency: "WST" },
productType: { hasVariants: true, id: "pt53386", name: "Jewelery" },
+ publicationDate: null,
purchaseCost: {
start: { amount: 449.93166054829857, currency: "WST" },
stop: { amount: 4949.248266031284, currency: "WST" }
@@ -2089,7 +2089,6 @@ export const products = (placeholderImage: string) => [
}
],
availability: { available: false },
- availableOn: null,
category: { id: "Q2F0ZWdvcnk6MQ==", name: "Apparel" },
collections: {
edges: [{ node: { id: "Q29sbGVjdGlvbjoy", name: "Winter sale" } }]
@@ -2115,6 +2114,7 @@ export const products = (placeholderImage: string) => [
name: "Unbranded Steel Tuna",
price: { amount: 590.5928694420302, currency: "MGA" },
productType: { hasVariants: true, id: "pt48315", name: "Agent" },
+ publicationDate: null,
purchaseCost: {
start: { amount: 590.5928694420302, currency: "MGA" },
stop: { amount: 590.5928694420302, currency: "MGA" }
diff --git a/saleor/static/dashboard-next/products/mutations.ts b/saleor/static/dashboard-next/products/mutations.ts
index fa399c9921..120a289e27 100644
--- a/saleor/static/dashboard-next/products/mutations.ts
+++ b/saleor/static/dashboard-next/products/mutations.ts
@@ -104,7 +104,7 @@ export const productUpdateMutation = gql`
mutation ProductUpdate(
$id: ID!
$attributes: [AttributeValueInput]
- $availableOn: Date
+ $publicationDate: Date
$category: ID
$chargeTaxes: Boolean!
$collections: [ID]
@@ -117,7 +117,7 @@ export const productUpdateMutation = gql`
id: $id
input: {
attributes: $attributes
- availableOn: $availableOn
+ publicationDate: $publicationDate
category: $category
chargeTaxes: $chargeTaxes
collections: $collections
@@ -148,7 +148,7 @@ export const simpleProductUpdateMutation = gql`
mutation SimpleProductUpdate(
$id: ID!
$attributes: [AttributeValueInput]
- $availableOn: Date
+ $publicationDate: Date
$category: ID
$chargeTaxes: Boolean!
$collections: [ID]
@@ -163,7 +163,7 @@ export const simpleProductUpdateMutation = gql`
id: $id
input: {
attributes: $attributes
- availableOn: $availableOn
+ publicationDate: $publicationDate
category: $category
chargeTaxes: $chargeTaxes
collections: $collections
@@ -201,7 +201,7 @@ export const productCreateMutation = gql`
${fragmentProduct}
mutation ProductCreate(
$attributes: [AttributeValueInput]
- $availableOn: Date
+ $publicationDate: Date
$category: ID!
$chargeTaxes: Boolean!
$collections: [ID]
@@ -214,7 +214,7 @@ export const productCreateMutation = gql`
productCreate(
input: {
attributes: $attributes
- availableOn: $availableOn
+ publicationDate: $publicationDate
category: $category
chargeTaxes: $chargeTaxes
collections: $collections
diff --git a/saleor/static/dashboard-next/products/queries.ts b/saleor/static/dashboard-next/products/queries.ts
index 44cdebfe7a..395b933caf 100644
--- a/saleor/static/dashboard-next/products/queries.ts
+++ b/saleor/static/dashboard-next/products/queries.ts
@@ -78,7 +78,7 @@ export const fragmentProduct = gql`
}
isPublished
chargeTaxes
- availableOn
+ publicationDate
attributes {
attribute {
id
diff --git a/saleor/static/dashboard-next/products/types/Product.ts b/saleor/static/dashboard-next/products/types/Product.ts
index e3b5380b21..56a121dd50 100644
--- a/saleor/static/dashboard-next/products/types/Product.ts
+++ b/saleor/static/dashboard-next/products/types/Product.ts
@@ -155,7 +155,7 @@ export interface Product {
purchaseCost: Product_purchaseCost | null;
isPublished: boolean;
chargeTaxes: boolean;
- availableOn: any | null;
+ publicationDate: any | null;
attributes: Product_attributes[];
availability: Product_availability | null;
images: (Product_images | null)[] | null;
diff --git a/saleor/static/dashboard-next/products/types/ProductCreate.ts b/saleor/static/dashboard-next/products/types/ProductCreate.ts
index c474a9b109..b3e3b29e6d 100644
--- a/saleor/static/dashboard-next/products/types/ProductCreate.ts
+++ b/saleor/static/dashboard-next/products/types/ProductCreate.ts
@@ -163,7 +163,7 @@ export interface ProductCreate_productCreate_product {
purchaseCost: ProductCreate_productCreate_product_purchaseCost | null;
isPublished: boolean;
chargeTaxes: boolean;
- availableOn: any | null;
+ publicationDate: any | null;
attributes: ProductCreate_productCreate_product_attributes[];
availability: ProductCreate_productCreate_product_availability | null;
images: (ProductCreate_productCreate_product_images | null)[] | null;
@@ -184,7 +184,7 @@ export interface ProductCreate {
export interface ProductCreateVariables {
attributes?: (AttributeValueInput | null)[] | null;
- availableOn?: any | null;
+ publicationDate?: any | null;
category: string;
chargeTaxes: boolean;
collections?: (string | null)[] | null;
diff --git a/saleor/static/dashboard-next/products/types/ProductDetails.ts b/saleor/static/dashboard-next/products/types/ProductDetails.ts
index e539c0aed3..fc08c370b6 100644
--- a/saleor/static/dashboard-next/products/types/ProductDetails.ts
+++ b/saleor/static/dashboard-next/products/types/ProductDetails.ts
@@ -155,7 +155,7 @@ export interface ProductDetails_product {
purchaseCost: ProductDetails_product_purchaseCost | null;
isPublished: boolean;
chargeTaxes: boolean;
- availableOn: any | null;
+ publicationDate: any | null;
attributes: ProductDetails_product_attributes[];
availability: ProductDetails_product_availability | null;
images: (ProductDetails_product_images | null)[] | null;
diff --git a/saleor/static/dashboard-next/products/types/ProductImageCreate.ts b/saleor/static/dashboard-next/products/types/ProductImageCreate.ts
index 6c3b8c9c87..bae3768f3b 100644
--- a/saleor/static/dashboard-next/products/types/ProductImageCreate.ts
+++ b/saleor/static/dashboard-next/products/types/ProductImageCreate.ts
@@ -161,7 +161,7 @@ export interface ProductImageCreate_productImageCreate_product {
purchaseCost: ProductImageCreate_productImageCreate_product_purchaseCost | null;
isPublished: boolean;
chargeTaxes: boolean;
- availableOn: any | null;
+ publicationDate: any | null;
attributes: ProductImageCreate_productImageCreate_product_attributes[];
availability: ProductImageCreate_productImageCreate_product_availability | null;
images: (ProductImageCreate_productImageCreate_product_images | null)[] | null;
diff --git a/saleor/static/dashboard-next/products/types/ProductImageUpdate.ts b/saleor/static/dashboard-next/products/types/ProductImageUpdate.ts
index 8d94ef2086..e19ef9dd1f 100644
--- a/saleor/static/dashboard-next/products/types/ProductImageUpdate.ts
+++ b/saleor/static/dashboard-next/products/types/ProductImageUpdate.ts
@@ -161,7 +161,7 @@ export interface ProductImageUpdate_productImageUpdate_product {
purchaseCost: ProductImageUpdate_productImageUpdate_product_purchaseCost | null;
isPublished: boolean;
chargeTaxes: boolean;
- availableOn: any | null;
+ publicationDate: any | null;
attributes: ProductImageUpdate_productImageUpdate_product_attributes[];
availability: ProductImageUpdate_productImageUpdate_product_availability | null;
images: (ProductImageUpdate_productImageUpdate_product_images | null)[] | null;
diff --git a/saleor/static/dashboard-next/products/types/ProductUpdate.ts b/saleor/static/dashboard-next/products/types/ProductUpdate.ts
index fa98911d84..5e1c733dc5 100644
--- a/saleor/static/dashboard-next/products/types/ProductUpdate.ts
+++ b/saleor/static/dashboard-next/products/types/ProductUpdate.ts
@@ -163,7 +163,7 @@ export interface ProductUpdate_productUpdate_product {
purchaseCost: ProductUpdate_productUpdate_product_purchaseCost | null;
isPublished: boolean;
chargeTaxes: boolean;
- availableOn: any | null;
+ publicationDate: any | null;
attributes: ProductUpdate_productUpdate_product_attributes[];
availability: ProductUpdate_productUpdate_product_availability | null;
images: (ProductUpdate_productUpdate_product_images | null)[] | null;
@@ -185,7 +185,7 @@ export interface ProductUpdate {
export interface ProductUpdateVariables {
id: string;
attributes?: (AttributeValueInput | null)[] | null;
- availableOn?: any | null;
+ publicationDate?: any | null;
category?: string | null;
chargeTaxes: boolean;
collections?: (string | null)[] | null;
diff --git a/saleor/static/dashboard-next/products/types/SimpleProductUpdate.ts b/saleor/static/dashboard-next/products/types/SimpleProductUpdate.ts
index 2dc0060a90..32fa533201 100644
--- a/saleor/static/dashboard-next/products/types/SimpleProductUpdate.ts
+++ b/saleor/static/dashboard-next/products/types/SimpleProductUpdate.ts
@@ -163,7 +163,7 @@ export interface SimpleProductUpdate_productUpdate_product {
purchaseCost: SimpleProductUpdate_productUpdate_product_purchaseCost | null;
isPublished: boolean;
chargeTaxes: boolean;
- availableOn: any | null;
+ publicationDate: any | null;
attributes: SimpleProductUpdate_productUpdate_product_attributes[];
availability: SimpleProductUpdate_productUpdate_product_availability | null;
images: (SimpleProductUpdate_productUpdate_product_images | null)[] | null;
@@ -294,7 +294,7 @@ export interface SimpleProductUpdate {
export interface SimpleProductUpdateVariables {
id: string;
attributes?: (AttributeValueInput | null)[] | null;
- availableOn?: any | null;
+ publicationDate?: any | null;
category?: string | null;
chargeTaxes: boolean;
collections?: (string | null)[] | null;
diff --git a/saleor/static/dashboard-next/products/views/ProductCreate.tsx b/saleor/static/dashboard-next/products/views/ProductCreate.tsx
index 91ee311ec7..5bf1617991 100644
--- a/saleor/static/dashboard-next/products/views/ProductCreate.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductCreate.tsx
@@ -73,10 +73,6 @@ export const ProductUpdate: React.StatelessComponent<
productCreate({
variables: {
attributes: formData.attributes,
- availableOn:
- formData.availableOn !== ""
- ? formData.availableOn
- : null,
category: formData.category.value,
chargeTaxes: formData.chargeTaxes,
collections: formData.collections.map(
@@ -87,7 +83,11 @@ export const ProductUpdate: React.StatelessComponent<
name: formData.name,
price: decimal(formData.price),
productType:
- formData.productType.value.id
+ formData.productType.value.id,
+ publicationDate:
+ formData.publicationDate !== ""
+ ? formData.publicationDate
+ : null
}
});
};
diff --git a/saleor/static/dashboard-next/products/views/ProductUpdate/index.tsx b/saleor/static/dashboard-next/products/views/ProductUpdate/index.tsx
index 73514a5ab6..108799586d 100644
--- a/saleor/static/dashboard-next/products/views/ProductUpdate/index.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductUpdate/index.tsx
@@ -115,10 +115,6 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
if (product.productType.hasVariants) {
updateProduct.mutate({
attributes: data.attributes,
- availableOn:
- data.availableOn !== ""
- ? data.availableOn
- : null,
category: data.category.value,
chargeTaxes: data.chargeTaxes,
collections: data.collections.map(
@@ -128,15 +124,15 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
id: product.id,
isPublished: data.available,
name: data.name,
- price: decimal(data.price)
+ price: decimal(data.price),
+ publicationDate:
+ data.publicationDate !== ""
+ ? data.publicationDate
+ : null
});
} else {
updateSimpleProduct.mutate({
attributes: data.attributes,
- availableOn:
- data.availableOn !== ""
- ? data.availableOn
- : null,
category: data.category.value,
chargeTaxes: data.chargeTaxes,
collections: data.collections.map(
@@ -152,7 +148,11 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
productVariantInput: {
quantity: data.stockQuantity,
sku: data.sku
- }
+ },
+ publicationDate:
+ data.publicationDate !== ""
+ ? data.publicationDate
+ : null
});
}
}
diff --git a/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snap b/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snap
index 1a252b2f38..0877dcf375 100644
--- a/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snap
+++ b/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snap
@@ -47584,7 +47584,7 @@ exports[`Storyshots Views / Products / Product edit when data is fully loaded 1`
<input
aria-invalid="false"
class="MuiInputBase-input-id MuiInput-input-id MuiInputBase-inputType-id MuiInput-inputType-id"
- name="availableOn"
+ name="publicationDate"
type="date"
value="2018-08-25T18:45:54.125Z"
/>
@@ -49398,7 +49398,7 @@ exports[`Storyshots Views / Products / Product edit when product has no images 1
<input
aria-invalid="false"
class="MuiInputBase-input-id MuiInput-input-id MuiInputBase-inputType-id MuiInput-inputType-id"
- name="availableOn"
+ name="publicationDate"
type="date"
value="2018-08-25T18:45:54.125Z"
/>
@@ -50444,7 +50444,7 @@ exports[`Storyshots Views / Products / Product edit when product has no variants
<input
aria-invalid="false"
class="MuiInputBase-input-id MuiInput-input-id MuiInputBase-inputType-id MuiInput-inputType-id"
- name="availableOn"
+ name="publicationDate"
type="date"
value="2018-08-25T18:45:54.125Z"
/>
diff --git a/saleor/static/db.json b/saleor/static/db.json
index 8b93877bf4..5eaa7a50d4 100644
--- a/saleor/static/db.json
+++ b/saleor/static/db.json
@@ -153,7 +153,7 @@
"amount": "15.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{}",
"updated_at": "2018-11-05T11:30:13.329Z",
@@ -177,7 +177,7 @@
"amount": "15.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{}",
"updated_at": "2018-11-05T11:30:13.431Z",
@@ -201,7 +201,7 @@
"amount": "15.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{}",
"updated_at": "2018-11-05T11:30:13.446Z",
@@ -225,7 +225,7 @@
"amount": "15.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{}",
"updated_at": "2018-11-05T11:30:13.462Z",
@@ -249,7 +249,7 @@
"amount": "15.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{}",
"updated_at": "2018-11-05T11:30:13.477Z",
@@ -273,7 +273,7 @@
"amount": "3.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"16\": \"49\"}",
"updated_at": "2018-11-05T11:30:13.493Z",
@@ -297,7 +297,7 @@
"amount": "3.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"16\": \"3\"}",
"updated_at": "2018-11-05T11:30:13.508Z",
@@ -321,7 +321,7 @@
"amount": "3.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"16\": \"52\"}",
"updated_at": "2018-11-05T11:30:13.523Z",
@@ -345,7 +345,7 @@
"amount": "3.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"16\": \"50\"}",
"updated_at": "2018-11-05T11:30:13.538Z",
@@ -369,7 +369,7 @@
"amount": "3.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"16\": \"1\"}",
"updated_at": "2018-11-05T11:30:13.553Z",
@@ -393,7 +393,7 @@
"amount": "3.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"16\": \"2\"}",
"updated_at": "2018-11-05T11:30:13.568Z",
@@ -417,7 +417,7 @@
"amount": "3.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"16\": \"54\"}",
"updated_at": "2018-11-05T11:30:13.583Z",
@@ -441,7 +441,7 @@
"amount": "3.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"16\": \"53\"}",
"updated_at": "2018-11-05T11:30:13.597Z",
@@ -465,7 +465,7 @@
"amount": "3.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"16\": \"51\"}",
"updated_at": "2018-11-05T11:30:13.613Z",
@@ -489,7 +489,7 @@
"amount": "15.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"20\": \"67\"}",
"updated_at": "2018-11-05T11:30:13.628Z",
@@ -513,7 +513,7 @@
"amount": "15.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"20\": \"67\"}",
"updated_at": "2018-11-05T11:30:13.644Z",
@@ -537,7 +537,7 @@
"amount": "3.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"15\": \"46\", \"21\": \"68\"}",
"updated_at": "2018-11-05T11:30:13.661Z",
@@ -561,7 +561,7 @@
"amount": "3.20",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"15\": \"46\", \"21\": \"69\"}",
"updated_at": "2018-11-05T11:30:13.686Z",
@@ -585,7 +585,7 @@
"amount": "20.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"23\": \"72\"}",
"updated_at": "2018-11-05T11:30:13.713Z",
@@ -609,7 +609,7 @@
"amount": "20.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"23\": \"72\"}",
"updated_at": "2018-11-05T11:30:13.730Z",
@@ -633,7 +633,7 @@
"amount": "59.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{}",
"updated_at": "2018-11-05T11:30:13.746Z",
@@ -657,7 +657,7 @@
"amount": "49.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{}",
"updated_at": "2018-11-05T11:30:13.792Z",
@@ -681,7 +681,7 @@
"amount": "30.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"25\": \"82\"}",
"updated_at": "2018-11-05T11:30:13.840Z",
@@ -705,7 +705,7 @@
"amount": "30.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"25\": \"82\"}",
"updated_at": "2018-11-05T11:30:13.867Z",
@@ -729,7 +729,7 @@
"amount": "30.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"25\": \"82\"}",
"updated_at": "2018-11-05T11:30:13.884Z",
@@ -753,7 +753,7 @@
"amount": "30.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"25\": \"82\"}",
"updated_at": "2018-11-05T11:30:13.901Z",
@@ -777,7 +777,7 @@
"amount": "30.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"25\": \"82\"}",
"updated_at": "2018-11-05T11:30:13.918Z",
@@ -801,7 +801,7 @@
"amount": "30.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"25\": \"82\"}",
"updated_at": "2018-11-05T11:30:13.935Z",
@@ -825,7 +825,7 @@
"amount": "30.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"25\": \"82\"}",
"updated_at": "2018-11-05T11:30:13.972Z",
@@ -849,7 +849,7 @@
"amount": "30.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"25\": \"82\"}",
"updated_at": "2018-11-05T11:30:13.999Z",
@@ -873,7 +873,7 @@
"amount": "30.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"25\": \"82\"}",
"updated_at": "2018-11-05T11:30:14.025Z",
@@ -897,7 +897,7 @@
"amount": "30.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"25\": \"82\"}",
"updated_at": "2018-11-05T11:30:14.050Z",
@@ -921,7 +921,7 @@
"amount": "30.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"25\": \"82\"}",
"updated_at": "2018-11-05T11:30:14.066Z",
@@ -945,7 +945,7 @@
"amount": "30.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"25\": \"82\"}",
"updated_at": "2018-11-05T11:30:14.083Z",
@@ -969,7 +969,7 @@
"amount": "30.00",
"currency": "USD"
},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{\"25\": \"82\"}",
"updated_at": "2018-11-05T11:30:14.101Z",
diff --git a/templates/dashboard/product/form.html b/templates/dashboard/product/form.html
index 80b056859a..e1c326dd3c 100644
--- a/templates/dashboard/product/form.html
+++ b/templates/dashboard/product/form.html
@@ -77,7 +77,7 @@
{{ product_form.is_published|materializecss }}
</div>
<div class="col s12 m9">
- {{ product_form.available_on|materializecss }}
+ {{ product_form.publication_date|materializecss }}
</div>
</div>
{% include "dashboard/includes/_google_preview.html" with object=product form=product_form %}
diff --git a/templates/product/details.html b/templates/product/details.html
index 1540663689..cfd0216cf1 100644
--- a/templates/product/details.html
+++ b/templates/product/details.html
@@ -59,7 +59,7 @@
{% block content %}
{% if not is_visible %}
<div class="alert alert-warning" role="alert">
- {% blocktrans trimmed with date=product.available_on|date context "Product details text" %}
+ {% blocktrans trimmed with date=product.publication_date|date context "Product details text" %}
<strong>Warning!</strong>
You are previewing a product that will become visible on <strong>{{ date }}</strong>.
{% endblocktrans %}
diff --git a/tests/test_product.py b/tests/test_product.py
index 13028b68b0..24ed60adc3 100644
--- a/tests/test_product.py
+++ b/tests/test_product.py
@@ -58,7 +58,7 @@ def test_product_page_redirects_to_correct_slug(client, product):
def test_product_preview(admin_client, client, product):
- product.available_on = (
+ product.publication_date = (
datetime.date.today() + datetime.timedelta(days=7))
product.save()
response = client.get(product.get_absolute_url())
@@ -615,7 +615,7 @@ def test_product_json_deserialization(category, product_type):
"description": "Future almost cup national",
"category": {category_pk},
"price": {{"_type": "Money", "amount": "35.98", "currency": "USD"}},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{{\\"9\\": \\"24\\", \\"10\\": \\"26\\"}}",
"updated_at": "2018-07-19T13:30:24.195Z",
@@ -662,7 +662,7 @@ def test_json_no_currency_deserialization(category, product_type):
"description": "Future almost cup national",
"category": {category_pk},
"price": {{"_type": "Money", "amount": "35.98"}},
- "available_on": null,
+ "publication_date": null,
"is_published": true,
"attributes": "{{\\"9\\": \\"24\\", \\"10\\": \\"26\\"}}",
"updated_at": "2018-07-19T13:30:24.195Z",
diff --git a/tests/test_product_availability.py b/tests/test_product_availability.py
index dd1575bc83..6e209ccdea 100644
--- a/tests/test_product_availability.py
+++ b/tests/test_product_availability.py
@@ -47,7 +47,8 @@ def test_product_availability_status(unavailable_product):
assert status == ProductAvailabilityStatus.READY_FOR_PURCHASE
# set product availability date from future
- product.available_on = datetime.date.today() + datetime.timedelta(days=1)
+ product.publication_date = (
+ datetime.date.today() + datetime.timedelta(days=1))
product.save()
status = get_product_availability_status(product)
assert status == ProductAvailabilityStatus.NOT_YET_AVAILABLE
@@ -99,7 +100,7 @@ def test_available_products_only_published(product_list):
def test_available_products_only_available(product_list):
product = product_list[0]
date_tomorrow = datetime.date.today() + datetime.timedelta(days=1)
- product.available_on = date_tomorrow
+ product.publication_date = date_tomorrow
product.save()
available_products = models.Product.objects.available_products()
assert available_products.count() == 1