Skip to content

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

Allow to pass metadata directly in create and update mutations for product app models (#10689)

SzymJdf06a6c57296
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 48dbce78f1..84974c184c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Add ability to filter customers by ids. #10694 by @kadewu
- Add optional field `audience` to mutation `tokenCreate`. If provided, the created tokens will have key `aud` with value: `custom:{audience-input-value}` - #10845 by @korycins
- Use `AttributeValue.name` instead of `AttributeValue.slug` to determine uniqueness of a value instance for dropdown and multiselect attributes. - #10881 by @jakubkuc
+- Add ability to pass metadata directly in create/update mutations for product app models - #10689 by @SzymJ
### Other changes
diff --git a/saleor/graphql/account/mutations/account.py b/saleor/graphql/account/mutations/account.py
index 20b18d14be..a0e7364cc3 100644
--- a/saleor/graphql/account/mutations/account.py
+++ b/saleor/graphql/account/mutations/account.py
@@ -85,6 +85,7 @@ class AccountRegister(ModelMutation):
object_type = User
error_type_class = AccountError
error_type_field = "account_errors"
+ support_meta_field = True
@classmethod
def mutate(cls, root, info, **data):
@@ -94,9 +95,6 @@ class AccountRegister(ModelMutation):
@classmethod
def clean_input(cls, info, instance, data, input_cls=None):
- data["metadata"] = {
- item["key"]: item["value"] for item in data.get("metadata") or []
- }
if not settings.ENABLE_ACCOUNT_CONFIRMATION_BY_EMAIL:
return super().clean_input(info, instance, data, input_cls=None)
elif not data.get("redirect_url"):
diff --git a/saleor/graphql/checkout/mutations/checkout_complete.py b/saleor/graphql/checkout/mutations/checkout_complete.py
index 2ec44773ff..08daac5d07 100644
--- a/saleor/graphql/checkout/mutations/checkout_complete.py
+++ b/saleor/graphql/checkout/mutations/checkout_complete.py
@@ -25,11 +25,12 @@ from ...account.i18n import I18nMixin
from ...app.dataloaders import load_app
from ...core.descriptions import ADDED_IN_34, ADDED_IN_38, DEPRECATED_IN_3X_INPUT
from ...core.fields import JSONString
+from ...core.mutations import BaseMutation
from ...core.scalars import UUID
from ...core.types import CheckoutError, NonNullList
from ...core.validators import validate_one_of_args_is_in_mutation
from ...discount.dataloaders import load_discounts
-from ...meta.mutations import BaseMutationWithMetadata, MetadataInput
+from ...meta.mutations import MetadataInput
from ...order.types import Order
from ...plugins.dataloaders import load_plugin_manager
from ...site.dataloaders import load_site
@@ -38,7 +39,7 @@ from ..types import Checkout
from .utils import get_checkout
-class CheckoutComplete(BaseMutationWithMetadata, I18nMixin):
+class CheckoutComplete(BaseMutation, I18nMixin):
order = graphene.Field(Order, description="Placed order.")
confirmation_needed = graphene.Boolean(
required=True,
@@ -210,11 +211,13 @@ class CheckoutComplete(BaseMutationWithMetadata, I18nMixin):
)
raise e
- cls.validate_metadata(
- info,
- id or checkout_id or graphene.Node.to_global_id("Checkout", token),
- data.get("metadata"),
- )
+ metadata = data.get("metadata")
+ if metadata is not None:
+ cls.check_metadata_permissions(
+ info,
+ id or checkout_id or graphene.Node.to_global_id("Checkout", token),
+ )
+ cls.validate_metadata_keys(metadata)
validate_checkout_email(checkout)
diff --git a/saleor/graphql/checkout/mutations/order_create_from_checkout.py b/saleor/graphql/checkout/mutations/order_create_from_checkout.py
index 8cd9535ad5..d8d3e096eb 100644
--- a/saleor/graphql/checkout/mutations/order_create_from_checkout.py
+++ b/saleor/graphql/checkout/mutations/order_create_from_checkout.py
@@ -10,9 +10,10 @@ from ....core.permissions import CheckoutPermissions
from ....discount.models import NotApplicable
from ...app.dataloaders import load_app
from ...core.descriptions import ADDED_IN_32, ADDED_IN_38, PREVIEW_FEATURE
+from ...core.mutations import BaseMutation
from ...core.types import Error, NonNullList
from ...discount.dataloaders import load_discounts
-from ...meta.mutations import BaseMutationWithMetadata, MetadataInput
+from ...meta.mutations import MetadataInput
from ...order.types import Order
from ...plugins.dataloaders import load_plugin_manager
from ..enums import OrderCreateFromCheckoutErrorCode
@@ -36,7 +37,7 @@ class OrderCreateFromCheckoutError(Error):
)
-class OrderCreateFromCheckout(BaseMutationWithMetadata):
+class OrderCreateFromCheckout(BaseMutation):
order = graphene.Field(Order, description="Placed order.")
class Arguments:
@@ -77,6 +78,8 @@ class OrderCreateFromCheckout(BaseMutationWithMetadata):
object_type = Order
permissions = (CheckoutPermissions.HANDLE_CHECKOUTS,)
error_type_class = OrderCreateFromCheckoutError
+ support_meta_field = True
+ support_private_meta_field = True
@classmethod
def check_permissions(cls, context, permissions=None):
@@ -97,13 +100,15 @@ class OrderCreateFromCheckout(BaseMutationWithMetadata):
only_type=Checkout,
code=OrderCreateFromCheckoutErrorCode.CHECKOUT_NOT_FOUND.value,
)
+ metadata = data.get("metadata")
+ private_metadata = data.get("private_metadata")
- cls.validate_metadata(
- info,
- checkout_id,
- data.get("metadata"),
- data.get("private_metadata"),
- )
+ if cls._meta.support_meta_field and metadata is not None:
+ cls.check_metadata_permissions(info, checkout_id)
+ cls.validate_metadata_keys(metadata)
+ if cls._meta.support_private_meta_field and private_metadata is not None:
+ cls.check_metadata_permissions(info, checkout_id, private=True)
+ cls.validate_metadata_keys(private_metadata)
tracking_code = analytics.get_client_id(info.context)
diff --git a/saleor/graphql/core/mutations.py b/saleor/graphql/core/mutations.py
index f50f13755d..f09638ffb5 100644
--- a/saleor/graphql/core/mutations.py
+++ b/saleor/graphql/core/mutations.py
@@ -2,7 +2,7 @@ import os
import secrets
from enum import Enum
from itertools import chain
-from typing import Iterable, Optional, Tuple, Union
+from typing import Iterable, List, Optional, Tuple, Union
from uuid import UUID
import graphene
@@ -18,6 +18,7 @@ from graphene import ObjectType
from graphene.types.mutation import MutationOptions
from graphql.error import GraphQLError
+from ...core.error_codes import MetadataErrorCode
from ...core.exceptions import PermissionDenied
from ...core.permissions import (
AuthorizationFilters,
@@ -25,6 +26,8 @@ from ...core.permissions import (
one_of_permissions_or_auth_filter_required,
)
from ...core.utils.events import call_event
+from ..meta.permissions import PRIVATE_META_PERMISSION_MAP, PUBLIC_META_PERMISSION_MAP
+from ..payment.utils import metadata_contains_empty_key
from ..plugins.dataloaders import load_plugin_manager
from ..utils import get_nodes, resolve_global_ids_to_primary_keys
from .context import set_mutation_flag_in_context, setup_context_user
@@ -137,6 +140,8 @@ class BaseMutation(graphene.Mutation):
error_type_class=None,
error_type_field=None,
errors_mapping=None,
+ support_meta_field=False,
+ support_private_meta_field=False,
**options,
):
if not _meta:
@@ -155,6 +160,8 @@ class BaseMutation(graphene.Mutation):
_meta.error_type_class = error_type_class
_meta.error_type_field = error_type_field
_meta.errors_mapping = errors_mapping
+ _meta.support_meta_field = support_meta_field
+ _meta.support_private_meta_field = support_private_meta_field
if permissions and auto_permission_message:
permissions_msg = message_one_of_permissions_required(permissions)
@@ -409,6 +416,54 @@ class BaseMutation(graphene.Mutation):
def call_event(func_obj, *func_args):
return call_event(func_obj, *func_args)
+ @classmethod
+ def update_metadata(cls, instance, meta_data_list: List, is_private: bool = False):
+ if is_private:
+ instance.store_value_in_private_metadata(
+ {data.key: data.value for data in meta_data_list}
+ )
+ else:
+ instance.store_value_in_metadata(
+ {data.key: data.value for data in meta_data_list}
+ )
+
+ @classmethod
+ def validate_metadata_keys(cls, metadata_list: List[dict]):
+ if metadata_contains_empty_key(metadata_list):
+ raise ValidationError(
+ {
+ "input": ValidationError(
+ "Metadata key cannot be empty.",
+ code=MetadataErrorCode.REQUIRED.value,
+ )
+ }
+ )
+
+ @classmethod
+ def validate_and_update_metadata(
+ cls, instance, metadata_list, private_metadata_list
+ ):
+ if cls._meta.support_meta_field and metadata_list is not None:
+ cls.validate_metadata_keys(metadata_list)
+ cls.update_metadata(instance, metadata_list)
+ if cls._meta.support_private_meta_field and private_metadata_list is not None:
+ cls.validate_metadata_keys(private_metadata_list)
+ cls.update_metadata(instance, private_metadata_list, is_private=True)
+
+ @classmethod
+ def check_metadata_permissions(cls, info, object_id, private=False):
+ type_name, db_id = graphene.Node.from_global_id(object_id)
+
+ if private:
+ meta_permission = PRIVATE_META_PERMISSION_MAP.get(type_name)
+ else:
+ meta_permission = PUBLIC_META_PERMISSION_MAP.get(type_name)
+
+ if not meta_permission:
+ raise NotImplementedError(
+ f"Couldn't resolve permission to item type: {type_name}. "
+ )
+
class ModelMutation(BaseMutation):
class Meta:
@@ -582,7 +637,11 @@ class ModelMutation(BaseMutation):
instance = cls.get_instance(info, **data)
data = data.get("input")
cleaned_input = cls.clean_input(info, instance, data)
+ metadata_list = cleaned_input.pop("metadata", None)
+ private_metadata_list = cleaned_input.pop("private_metadata", None)
instance = cls.construct_instance(instance, cleaned_input)
+
+ cls.validate_and_update_metadata(instance, metadata_list, private_metadata_list)
cls.clean_instance(info, instance)
cls.save(info, instance, cleaned_input)
cls._save_m2m(info, instance, cleaned_input)
diff --git a/saleor/graphql/meta/mutations.py b/saleor/graphql/meta/mutations.py
index a5af81f223..8af6e914df 100644
--- a/saleor/graphql/meta/mutations.py
+++ b/saleor/graphql/meta/mutations.py
@@ -399,49 +399,3 @@ class DeletePrivateMetadata(BaseMetadataMutation):
instance.delete_value_from_private_metadata(key)
_save_instance(instance, "private_metadata")
return cls.success_response(instance)
-
-
-class BaseMutationWithMetadata(BaseMutation):
- class Meta:
- abstract = True
-
- @classmethod
- def validate_metadata_keys(cls, metadata_list: List[dict]):
- if metadata_contains_empty_key(metadata_list):
- raise ValidationError(
- {
- "input": ValidationError(
- "Metadata key cannot be empty.",
- code=MetadataErrorCode.REQUIRED.value,
- )
- }
- )
-
- @classmethod
- def check_metadata_permissions(cls, type_name, info, object_id, private=False):
- if private:
- meta_permission = PRIVATE_META_PERMISSION_MAP.get(type_name)
- else:
- meta_permission = PUBLIC_META_PERMISSION_MAP.get(type_name)
-
- if not meta_permission:
- raise NotImplementedError(
- f"Couldn't resolve permission to item type: {type_name}. "
- )
-
- if not cls.check_permissions(info.context, meta_permission(info, object_id)):
- metadata_type = "private metadata" if private else "metadata"
- message = f"You do not have permission to update {metadata_type}."
- raise PermissionDenied(message)
-
- @classmethod
- def validate_metadata(cls, info, obj_id, metadata=None, private_metadata=None):
- type_name, db_id = graphene.Node.from_global_id(obj_id)
-
- if metadata:
- cls.check_metadata_permissions(type_name, info, db_id)
- cls.validate_metadata_keys(metadata)
-
- if private_metadata:
- cls.check_metadata_permissions(type_name, info, db_id, True)
- cls.validate_metadata_keys(private_metadata)
diff --git a/saleor/graphql/payment/mutations.py b/saleor/graphql/payment/mutations.py
index 882ecbd7fe..23ef32fcff 100644
--- a/saleor/graphql/payment/mutations.py
+++ b/saleor/graphql/payment/mutations.py
@@ -669,7 +669,9 @@ class TransactionCreate(BaseMutation):
return False
@classmethod
- def validate_metadata_keys(cls, metadata_list: List[dict], field_name, error_code):
+ def validate_metadata_keys( # type: ignore
+ cls, metadata_list: List[dict], field_name, error_code
+ ):
if metadata_contains_empty_key(metadata_list):
raise ValidationError(
{
diff --git a/saleor/graphql/product/mutations/digital_contents.py b/saleor/graphql/product/mutations/digital_contents.py
index 00566f9dbc..4d713f4246 100644
--- a/saleor/graphql/product/mutations/digital_contents.py
+++ b/saleor/graphql/product/mutations/digital_contents.py
@@ -7,8 +7,10 @@ from ....product import models
from ....product.error_codes import ProductErrorCode
from ...channel import ChannelContext
from ...core.context import set_mutation_flag_in_context
+from ...core.descriptions import ADDED_IN_38
from ...core.mutations import BaseMutation, ModelMutation
-from ...core.types import ProductError, Upload
+from ...core.types import NonNullList, ProductError, Upload
+from ...meta.mutations import MetadataInput
from ...plugins.dataloaders import load_plugin_manager
from ..types import DigitalContent, DigitalContentUrl, ProductVariant
@@ -36,6 +38,21 @@ class DigitalContentInput(graphene.InputObjectType):
description="Overwrite default automatic_fulfillment setting for variant.",
required=False,
)
+ metadata = NonNullList(
+ MetadataInput,
+ description=(
+ "Fields required to update the digital content metadata." + ADDED_IN_38
+ ),
+ required=False,
+ )
+ private_metadata = NonNullList(
+ MetadataInput,
+ description=(
+ "Fields required to update the digital content private metadata."
+ + ADDED_IN_38
+ ),
+ required=False,
+ )
class DigitalContentUploadInput(DigitalContentInput):
@@ -66,6 +83,8 @@ class DigitalContentCreate(BaseMutation):
error_type_class = ProductError
error_type_field = "product_errors"
permissions = (ProductPermissions.MANAGE_PRODUCTS,)
+ support_meta_field = True
+ support_private_meta_field = True
@classmethod
def clean_input(cls, info, data, instance):
@@ -111,6 +130,12 @@ class DigitalContentCreate(BaseMutation):
digital_content.automatic_fulfillment = clean_input.get(
"automatic_fulfillment", False
)
+ metadata_list = clean_input.pop("metadata", None)
+ private_metadata_list = clean_input.pop("private_metadata", None)
+
+ cls.validate_and_update_metadata(
+ digital_content, metadata_list, private_metadata_list
+ )
variant.digital_content = digital_content
variant.digital_content.save()
@@ -175,6 +200,8 @@ class DigitalContentUpdate(BaseMutation):
error_type_class = ProductError
error_type_field = "product_errors"
permissions = (ProductPermissions.MANAGE_PRODUCTS,)
+ support_meta_field = True
+ support_private_meta_field = True
@classmethod
def clean_input(cls, info, data):
@@ -228,6 +255,13 @@ class DigitalContentUpdate(BaseMutation):
"automatic_fulfillment", False
)
+ metadata_list = clean_input.pop("metadata", None)
+ private_metadata_list = clean_input.pop("private_metadata", None)
+
+ cls.validate_and_update_metadata(
+ digital_content, metadata_list, private_metadata_list
+ )
+
variant.digital_content = digital_content
variant.digital_content.save()
diff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.py
index 292168bc22..b9bfcb055d 100644
--- a/saleor/graphql/product/mutations/products.py
+++ b/saleor/graphql/product/mutations/products.py
@@ -38,6 +38,7 @@ from ...attribute.utils import AttributeAssignmentMixin, AttrValuesInput
from ...channel import ChannelContext
from ...core.descriptions import (
ADDED_IN_31,
+ ADDED_IN_38,
DEPRECATED_IN_3X_INPUT,
PREVIEW_FEATURE,
RICH_CONTENT,
@@ -58,6 +59,7 @@ from ...core.utils import (
validate_slug_and_generate_if_needed,
)
from ...core.utils.reordering import perform_reordering
+from ...meta.mutations import MetadataInput
from ...plugins.dataloaders import load_plugin_manager
from ...warehouse.types import Warehouse
from ..types import Category, Collection, Product, ProductMedia, ProductVariant
@@ -78,6 +80,18 @@ class CategoryInput(graphene.InputObjectType):
seo = SeoInput(description="Search engine optimization fields.")
background_image = Upload(description="Background image file.")
background_image_alt = graphene.String(description="Alt text for a product media.")
+ metadata = NonNullList(
+ MetadataInput,
+ description=("Fields required to update the category metadata." + ADDED_IN_38),
+ required=False,
+ )
+ private_metadata = NonNullList(
+ MetadataInput,
+ description=(
+ "Fields required to update the category private metadata." + ADDED_IN_38
+ ),
+ required=False,
+ )
class CategoryCreate(ModelMutation):
@@ -100,6 +114,8 @@ class CategoryCreate(ModelMutation):
permissions = (ProductPermissions.MANAGE_PRODUCTS,)
error_type_class = ProductError
error_type_field = "product_errors"
+ support_meta_field = True
+ support_private_meta_field = True
@classmethod
def clean_input(cls, info, instance, data):
@@ -154,6 +170,8 @@ class CategoryUpdate(CategoryCreate):
permissions = (ProductPermissions.MANAGE_PRODUCTS,)
error_type_class = ProductError
error_type_field = "product_errors"
+ support_meta_field = True
+ support_private_meta_field = True
@classmethod
def construct_instance(cls, instance, cleaned_data):
@@ -209,6 +227,20 @@ class CollectionInput(graphene.InputObjectType):
publication_date = graphene.Date(
description=(f"Publication date. ISO 8601 standard. {DEPRECATED_IN_3X_INPUT}")
)
+ metadata = NonNullList(
+ MetadataInput,
+ description=(
+ "Fields required to update the collection metadata." + ADDED_IN_38
+ ),
+ required=False,
+ )
+ private_metadata = NonNullList(
+ MetadataInput,
+ description=(
+ "Fields required to update the collection private metadata." + ADDED_IN_38
+ ),
+ required=False,
+ )
class CollectionCreateInput(CollectionInput):
@@ -232,6 +264,8 @@ class CollectionCreate(ModelMutation):
permissions = (ProductPermissions.MANAGE_PRODUCTS,)
error_type_class = CollectionError
error_type_field = "collection_errors"
+ support_meta_field = True
+ support_private_meta_field = True
@classmethod
def clean_input(cls, info, instance, data):
@@ -287,6 +321,8 @@ class CollectionUpdate(CollectionCreate):
permissions = (ProductPermissions.MANAGE_PRODUCTS,)
error_type_class = CollectionError
error_type_field = "collection_errors"
+ support_meta_field = True
+ support_private_meta_field = True
@classmethod
def construct_instance(cls, instance, cleaned_data):
@@ -543,6 +579,18 @@ class ProductInput(graphene.InputObjectType):
seo = SeoInput(description="Search engine optimization fields.")
weight = WeightScalar(description="Weight of the Product.", required=False)
rating = graphene.Float(description="Defines the product rating value.")
+ metadata = NonNullList(
+ MetadataInput,
+ description=("Fields required to update the product metadata." + ADDED_IN_38),
+ required=False,
+ )
+ private_metadata = NonNullList(
+ MetadataInput,
+ description=(
+ "Fields required to update the product private metadata." + ADDED_IN_38
+ ),
+ required=False,
+ )
class StockInput(graphene.InputObjectType):
@@ -578,6 +626,8 @@ class ProductCreate(ModelMutation):
permissions = (ProductPermissions.MANAGE_PRODUCTS,)
error_type_class = ProductError
error_type_field = "product_errors"
+ support_meta_field = True
+ support_private_meta_field = True
@classmethod
def clean_attributes(
@@ -707,6 +757,8 @@ class ProductUpdate(ProductCreate):
permissions = (ProductPermissions.MANAGE_PRODUCTS,)
error_type_class = ProductError
error_type_field = "product_errors"
+ support_meta_field = True
+ support_private_meta_field = True
@classmethod
def clean_attributes(
@@ -831,6 +883,21 @@ class ProductVariantInput(graphene.InputObjectType):
"that can be bought in a single checkout." + ADDED_IN_31 + PREVIEW_FEATURE
),
)
+ metadata = NonNullList(
+ MetadataInput,
+ description=(
+ "Fields required to update the product variant metadata." + ADDED_IN_38
+ ),
+ required=False,
+ )
+ private_metadata = NonNullList(
+ MetadataInput,
+ description=(
+ "Fields required to update the product variant private metadata."
+ + ADDED_IN_38
+ ),
+ required=False,
+ )
class ProductVariantCreateInput(ProductVariantInput):
@@ -865,6 +932,8 @@ class ProductVariantCreate(ModelMutation):
error_type_class = ProductError
error_type_field = "product_errors"
errors_mapping = {"price_amount": "price"}
+ support_meta_field = True
+ support_private_meta_field = True
@classmethod
def clean_attributes(
@@ -1104,6 +1173,8 @@ class ProductVariantUpdate(ProductVariantCreate):
error_type_class = ProductError
error_type_field = "product_errors"
errors_mapping = {"price_amount": "price"}
+ support_meta_field = True
+ support_private_meta_field = True
@classmethod
def clean_attributes(
diff --git a/saleor/graphql/product/tests/test_category.py b/saleor/graphql/product/tests/test_category.py
index c03cac64b3..ba2e12b88f 100644
--- a/saleor/graphql/product/tests/test_category.py
+++ b/saleor/graphql/product/tests/test_category.py
@@ -355,7 +355,8 @@ CATEGORY_CREATE_MUTATION = """
mutation(
$name: String, $slug: String,
$description: JSONString, $backgroundImage: Upload,
- $backgroundImageAlt: String, $parentId: ID) {
+ $backgroundImageAlt: String, $parentId: ID,
+ $metadata: [MetadataInput!], $privateMetadata: [MetadataInput!]) {
categoryCreate(
input: {
name: $name
@@ -363,6 +364,8 @@ CATEGORY_CREATE_MUTATION = """
description: $description
backgroundImage: $backgroundImage
backgroundImageAlt: $backgroundImageAlt
+ metadata: $metadata
+ privateMetadata: $privateMetadata
},
parent: $parentId
) {
@@ -378,6 +381,14 @@ CATEGORY_CREATE_MUTATION = """
backgroundImage{
alt
}
+ metadata {
+ key
+ value
+ }
+ privateMetadata {
+ key
+ value
+ }
}
errors {
field
@@ -392,8 +403,7 @@ CATEGORY_CREATE_MUTATION = """
def test_category_create_mutation(
monkeypatch, staff_api_client, permission_manage_products, media_root
):
- query = CATEGORY_CREATE_MUTATION
-
+ # given
category_name = "Test category"
description = "description"
category_slug = slugify(category_name)
@@ -401,6 +411,9 @@ def test_category_create_mutation(
image_file, image_name = create_image()
image_alt = "Alt text for an image."
+ metadata_key = "md key"
+ metadata_value = "md value"
+
# test creating root category
variables = {
"name": category_name,
@@ -408,13 +421,19 @@ def test_category_create_mutation(
"backgroundImage": image_name,
"backgroundImageAlt": image_alt,
"slug": category_slug,
+ "metadata": [{"key": metadata_key, "value": metadata_value}],
+ "privateMetadata": [{"key": metadata_key, "value": metadata_value}],
}
- body = get_multipart_request_body(query, variables, image_file, image_name)
+ body = get_multipart_request_body(
+ CATEGORY_CREATE_MUTATION, variables, image_file, image_name
+ )
response = staff_api_client.post_multipart(
body, permissions=[permission_manage_products]
)
content = get_graphql_content(response)
data = content["data"]["categoryCreate"]
+
+ # then
assert data["errors"] == []
assert data["category"]["name"] == category_name
assert data["category"]["description"] == category_description
@@ -428,6 +447,8 @@ def test_category_create_mutation(
assert file_name.startswith(f"category-backgrounds/{img_name}")
assert file_name.endswith(format)
assert data["category"]["backgroundImage"]["alt"] == image_alt
+ assert category.metadata == {metadata_key: metadata_value}
+ assert category.private_metadata == {metadata_key: metadata_value}
# test creating subcategory
parent_id = data["category"]["id"]
@@ -437,7 +458,7 @@ def test_category_create_mutation(
"parentId": parent_id,
"slug": f"{category_slug}-2",
}
- response = staff_api_client.post_graphql(query, variables)
+ response = staff_api_client.post_graphql(CATEGORY_CREATE_MUTATION, variables)
content = get_graphql_content(response)
data = content["data"]["categoryCreate"]
assert data["errors"] == []
@@ -570,7 +591,8 @@ def test_category_create_mutation_without_background_image(
MUTATION_CATEGORY_UPDATE_MUTATION = """
mutation($id: ID!, $name: String, $slug: String,
$backgroundImage: Upload, $backgroundImageAlt: String,
- $description: JSONString) {
+ $description: JSONString,
+ $metadata: [MetadataInput!], $privateMetadata: [MetadataInput!]) {
categoryUpdate(
id: $id
@@ -580,6 +602,8 @@ MUTATION_CATEGORY_UPDATE_MUTATION = """
backgroundImage: $backgroundImage
backgroundImageAlt: $backgroundImageAlt
slug: $slug
+ metadata: $metadata
+ privateMetadata: $privateMetadata
}
) {
category {
@@ -606,6 +630,8 @@ MUTATION_CATEGORY_UPDATE_MUTATION = """
def test_category_update_mutation(
monkeypatch, staff_api_client, category, permission_manage_products, media_root
):
+ # given
+
# create child category and test that the update mutation won't change
# it's parent
child_category = category.children.create(name="child")
@@ -618,6 +644,14 @@ def test_category_update_mutation(
image_file, image_name = create_image()
image_alt = "Alt text for an image."
+ old_meta = {"old": "meta"}
+ child_category.store_value_in_metadata(items=old_meta)
+ child_category.store_value_in_private_metadata(items=old_meta)
+ child_category.save(update_fields=["metadata", "private_metadata"])
+
+ metadata_key = "md key"
+ metadata_value = "md value"
+
category_id = graphene.Node.to_global_id("Category", child_category.pk)
variables = {
"name": category_name,
@@ -626,15 +660,21 @@ def test_category_update_mutation(
"backgroundImageAlt": image_alt,
"id": category_id,
"slug": category_slug,
+ "metadata": [{"key": metadata_key, "value": metadata_value}],
+ "privateMetadata": [{"key": metadata_key, "value": metadata_value}],
}
body = get_multipart_request_body(
MUTATION_CATEGORY_UPDATE_MUTATION, variables, image_file, image_name
)
+
+ # when
response = staff_api_client.post_multipart(
body, permissions=[permission_manage_products]
)
content = get_graphql_content(response)
data = content["data"]["categoryUpdate"]
+
+ # then
assert data["errors"] == []
assert data["category"]["id"] == category_id
assert data["category"]["name"] == category_name
@@ -646,6 +686,8 @@ def test_category_update_mutation(
assert category.description_plaintext == description
assert category.background_image.file
assert data["category"]["backgroundImage"]["alt"] == image_alt
+ assert category.metadata == {metadata_key: metadata_value, **old_meta}
+ assert category.private_metadata == {metadata_key: metadata_value, **old_meta}
@freeze_time("2022-05-12 12:00:00")
diff --git a/saleor/graphql/product/tests/test_collection.py b/saleor/graphql/product/tests/test_collection.py
index a4620b9e4c..7cede86e45 100644
--- a/saleor/graphql/product/tests/test_collection.py
+++ b/saleor/graphql/product/tests/test_collection.py
@@ -433,7 +433,8 @@ CREATE_COLLECTION_MUTATION = """
mutation createCollection(
$name: String!, $slug: String,
$description: JSONString, $products: [ID!],
- $backgroundImage: Upload, $backgroundImageAlt: String) {
+ $backgroundImage: Upload, $backgroundImageAlt: String
+ $metadata: [MetadataInput!], $privateMetadata: [MetadataInput!]) {
collectionCreate(
input: {
name: $name,
@@ -441,7 +442,10 @@ CREATE_COLLECTION_MUTATION = """
description: $description,
products: $products,
backgroundImage: $backgroundImage,
- backgroundImageAlt: $backgroundImageAlt}) {
+ backgroundImageAlt: $backgroundImageAlt
+ metadata: $metadata
+ privateMetadata: $privateMetadata
+ }) {
collection {
name
slug
@@ -452,6 +456,14 @@ CREATE_COLLECTION_MUTATION = """
backgroundImage{
alt
}
+ metadata {
+ key
+ value
+ }
+ privateMetadata {
+ key
+ value
+ }
}
errors {
field
@@ -474,14 +486,16 @@ def test_create_collection(
media_root,
permission_manage_products,
):
- query = CREATE_COLLECTION_MUTATION
-
+ # given
product_ids = [to_global_id("Product", product.pk) for product in product_list]
image_file, image_name = create_image()
image_alt = "Alt text for an image."
name = "test-name"
slug = "test-slug"
description = dummy_editorjs("description", True)
+ metadata_key = "md key"
+ metadata_value = "md value"
+
variables = {
"name": name,
"slug": slug,
@@ -489,13 +503,21 @@ def test_create_collection(
"products": product_ids,
"backgroundImage": image_name,
"backgroundImageAlt": image_alt,
+ "metadata": [{"key": metadata_key, "value": metadata_value}],
+ "privateMetadata": [{"key": metadata_key, "value": metadata_value}],
}
- body = get_multipart_request_body(query, variables, image_file, image_name)
+ body = get_multipart_request_body(
+ CREATE_COLLECTION_MUTATION, variables, image_file, image_name
+ )
+
+ # when
response = staff_api_client.post_multipart(
body, permissions=[permission_manage_products]
)
content = get_graphql_content(response)
data = content["data"]["collectionCreate"]["collection"]
+
+ # then
assert data["name"] == name
assert data["slug"] == slug
assert data["description"] == description
@@ -508,6 +530,9 @@ def test_create_collection(
assert file_name.startswith(f"collection-backgrounds/{img_name}")
assert file_name.endswith(format)
assert data["backgroundImage"]["alt"] == image_alt
+ assert collection.metadata == {metadata_key: metadata_value}
+ assert collection.private_metadata == {metadata_key: metadata_value}
+
created_webhook_mock.assert_called_once()
updated_webhook_mock.assert_not_called()
@@ -612,22 +637,42 @@ def test_update_collection(
collection,
permission_manage_products,
):
+ # given
query = """
mutation updateCollection(
- $name: String!, $slug: String!, $description: JSONString, $id: ID!) {
+ $name: String!, $slug: String!, $description: JSONString, $id: ID!,
+ $metadata: [MetadataInput!], $privateMetadata: [MetadataInput!]
+ ) {
collectionUpdate(
- id: $id, input: {name: $name, slug: $slug, description: $description}) {
+ id: $id, input: {
+ name: $name, slug: $slug, description: $description,
+ metadata: $metadata, privateMetadata: $privateMetadata
+ }) {
collection {
name
slug
description
+ metadata {
+ key
+ value
+ }
+ privateMetadata {
+ key
+ value
+ }
}
}
}
"""
description = dummy_editorjs("test description", True)
+ old_meta = {"old": "meta"}
+ collection.store_value_in_metadata(items=old_meta)
+ collection.store_value_in_private_metadata(items=old_meta)
+ collection.save(update_fields=["metadata", "private_metadata"])
+ metadata_key = "md key"
+ metadata_value = "md value"
name = "new-name"
slug = "new-slug"
@@ -637,14 +682,23 @@ def test_update_collection(
"slug": slug,
"description": description,
"id": to_global_id("Collection", collection.id),
+ "metadata": [{"key": metadata_key, "value": metadata_value}],
+ "privateMetadata": [{"key": metadata_key, "value": metadata_value}],
}
+
+ # when
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_products]
)
content = get_graphql_content(response)
data = content["data"]["collectionUpdate"]["collection"]
+ collection.refresh_from_db()
+
+ # then
assert data["name"] == name
assert data["slug"] == slug
+ assert collection.metadata == {metadata_key: metadata_value, **old_meta}
+ assert collection.private_metadata == {metadata_key: metadata_value, **old_meta}
created_webhook_mock.assert_not_called()
updated_webhook_mock.assert_called_once()
diff --git a/saleor/graphql/product/tests/test_digital_content.py b/saleor/graphql/product/tests/test_digital_content.py
index 13ec5e7277..0a0074f77a 100644
--- a/saleor/graphql/product/tests/test_digital_content.py
+++ b/saleor/graphql/product/tests/test_digital_content.py
@@ -189,6 +189,64 @@ def test_digital_content_create_mutation_default_settings(
assert variant.digital_content.use_default_settings
+def test_digital_content_create_mutation_with_metadata(
+ monkeypatch, staff_api_client, variant, permission_manage_products, media_root
+):
+ # given
+ query = """
+ mutation createDigitalContent($variant: ID!,
+ $input: DigitalContentUploadInput!) {
+ digitalContentCreate(variantId: $variant, input: $input) {
+ variant {
+ id
+ }
+ content {
+ metadata {
+ key
+ value
+ }
+ privateMetadata {
+ key
+ value
+ }
+ }
+ }
+ }
+ """
+
+ image_file, image_name = create_image()
+ url_valid_days = 3
+ max_downloads = 5
+ metadata_key = "md key"
+ metadata_value = "md value"
+
+ variables = {
+ "variant": graphene.Node.to_global_id("ProductVariant", variant.id),
+ "input": {
+ "useDefaultSettings": False,
+ "maxDownloads": max_downloads,
+ "urlValidDays": url_valid_days,
+ "automaticFulfillment": True,
+ "contentFile": image_name,
+ "metadata": [{"key": metadata_key, "value": metadata_value}],
+ "privateMetadata": [{"key": metadata_key, "value": metadata_value}],
+ },
+ }
+
+ body = get_multipart_request_body(query, variables, image_file, image_name)
+
+ # when
+ response = staff_api_client.post_multipart(
+ body, permissions=[permission_manage_products]
+ )
+ get_graphql_content(response)
+ variant.refresh_from_db()
+
+ # then
+ assert variant.digital_content.metadata == {metadata_key: metadata_value}
+ assert variant.digital_content.private_metadata == {metadata_key: metadata_value}
+
+
def test_digital_content_create_mutation_removes_old_content(
monkeypatch, staff_api_client, variant, permission_manage_products, media_root
):
@@ -267,6 +325,7 @@ def test_digital_content_delete_mutation(
def test_digital_content_update_mutation(
monkeypatch, staff_api_client, variant, digital_content, permission_manage_products
):
+ # given
url_valid_days = 3
max_downloads = 5
query = """
@@ -280,6 +339,14 @@ def test_digital_content_update_mutation(
maxDownloads
urlValidDays
automaticFulfillment
+ metadata {
+ key
+ value
+ }
+ privateMetadata {
+ key
+ value
+ }
}
}
}
@@ -287,6 +354,12 @@ def test_digital_content_update_mutation(
digital_content.automatic_fulfillment = False
variant.digital_content = digital_content
+ old_meta = {"old": "meta"}
+ metadata_key = "md key"
+ metadata_value = "md value"
+ variant.digital_content.store_value_in_metadata(items=old_meta)
+ variant.digital_content.store_value_in_private_metadata(items=old_meta)
+ variant.digital_content.save(update_fields=["metadata", "private_metadata"])
variant.digital_content.save()
variables = {
@@ -296,18 +369,28 @@ def test_digital_content_update_mutation(
"urlValidDays": url_valid_days,
"automaticFulfillment": True,
"useDefaultSettings": False,
+ "metadata": [{"key": metadata_key, "value": metadata_value}],
+ "privateMetadata": [{"key": metadata_key, "value": metadata_value}],
},
}
+ # when
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_products]
)
get_graphql_content(response)
variant = ProductVariant.objects.get(id=variant.id)
digital_content = variant.digital_content
+
+ # then
assert digital_content.max_downloads == max_downloads
assert digital_content.url_valid_days == url_valid_days
assert digital_content.automatic_fulfillment
+ assert digital_content.metadata == {metadata_key: metadata_value, **old_meta}
+ assert digital_content.private_metadata == {
+ metadata_key: metadata_value,
+ **old_meta,
+ }
def test_digital_content_update_mutation_missing_content(
diff --git a/saleor/graphql/product/tests/test_product.py b/saleor/graphql/product/tests/test_product.py
index 7ee456b616..65d345bca8 100644
--- a/saleor/graphql/product/tests/test_product.py
+++ b/saleor/graphql/product/tests/test_product.py
@@ -4569,6 +4569,14 @@ CREATE_PRODUCT_MUTATION = """
productType {
name
}
+ metadata {
+ key
+ value
+ }
+ privateMetadata {
+ key
+ value
+ }
attributes {
attribute {
slug
@@ -4613,10 +4621,11 @@ def test_create_product(
permission_manage_products,
monkeypatch,
):
- query = CREATE_PRODUCT_MUTATION
+ # given
description_json = json.dumps(description_json)
-
+ metadata_key = "md key"
+ metadata_value = "md value"
product_type_id = graphene.Node.to_global_id("ProductType", product_type.pk)
category_id = graphene.Node.to_global_id("Category", category.pk)
product_name = "test name"
@@ -4656,14 +4665,19 @@ def test_create_product(
{"id": color_attr_id, "values": [color_value_name]},
{"id": size_attr_id, "values": [non_existent_attr_value]},
],
+ "metadata": [{"key": metadata_key, "value": metadata_value}],
+ "privateMetadata": [{"key": metadata_key, "value": metadata_value}],
}
}
+ # when
response = staff_api_client.post_graphql(
- query, variables, permissions=[permission_manage_products]
+ CREATE_PRODUCT_MUTATION, variables, permissions=[permission_manage_products]
)
content = get_graphql_content(response)
data = content["data"]["productCreate"]
+
+ # then
assert data["errors"] == []
assert data["product"]["name"] == product_name
assert data["product"]["slug"] == product_slug
@@ -4680,6 +4694,9 @@ def test_create_product(
assert color_value_slug in values
product = Product.objects.first()
+ assert product.metadata == {metadata_key: metadata_value}
+ assert product.private_metadata == {metadata_key: metadata_value}
+
created_webhook_mock.assert_called_once_with(product)
updated_webhook_mock.assert_not_called()
@@ -7133,6 +7150,14 @@ MUTATION_UPDATE_PRODUCT = """
productType {
name
}
+ metadata {
+ key
+ value
+ }
+ privateMetadata {
+ key
+ value
+ }
attributes {
attribute {
id
@@ -7176,7 +7201,8 @@ def test_update_product(
monkeypatch,
color_attribute,
):
- query = MUTATION_UPDATE_PRODUCT
+ # given
+
expected_other_description_json = other_description_json
text = expected_other_description_json["blocks"][0]["data"]["text"]
expected_other_description_json["blocks"][0]["data"]["text"] = strip_tags(text)
@@ -7189,6 +7215,14 @@ def test_update_product(
product_charge_taxes = True
product_tax_rate = "STANDARD"
+ old_meta = {"old": "meta"}
+ product.store_value_in_metadata(items=old_meta)
+ product.store_value_in_private_metadata(items=old_meta)
+ product.save(update_fields=["metadata", "private_metadata"])
+
+ metadata_key = "md key"
+ metadata_value = "md value"
+
# Mock tax interface with fake response from tax gateway
monkeypatch.setattr(
PluginsManager,
@@ -7209,14 +7243,20 @@ def test_update_product(
"chargeTaxes": product_charge_taxes,
"taxCode": product_tax_rate,
"attributes": [{"id": attribute_id, "values": [attr_value]}],
+ "metadata": [{"key": metadata_key, "value": metadata_value}],
+ "privateMetadata": [{"key": metadata_key, "value": metadata_value}],
},
}
+ # when
response = staff_api_client.post_graphql(
- query, variables, permissions=[permission_manage_products]
+ MUTATION_UPDATE_PRODUCT, variables, permissions=[permission_manage_products]
)
content = get_graphql_content(response)
data = content["data"]["productUpdate"]
+ product.refresh_from_db()
+
+ # then
assert data["errors"] == []
assert data["product"]["name"] == product_name
assert data["product"]["slug"] == product_slug
@@ -7224,6 +7264,8 @@ def test_update_product(
assert data["product"]["chargeTaxes"] == product_charge_taxes
assert data["product"]["taxType"]["taxCode"] == product_tax_rate
assert not data["product"]["category"]["name"] == category.name
+ assert product.metadata == {metadata_key: metadata_value, **old_meta}
+ assert product.private_metadata == {metadata_key: metadata_value, **old_meta}
attributes = data["product"]["attributes"]
diff --git a/saleor/graphql/product/tests/test_variant.py b/saleor/graphql/product/tests/test_variant.py
index 8a79144128..efd15ff735 100644
--- a/saleor/graphql/product/tests/test_variant.py
+++ b/saleor/graphql/product/tests/test_variant.py
@@ -582,6 +582,14 @@ CREATE_VARIANT_MUTATION = """
globalThreshold
endDate
}
+ metadata {
+ key
+ value
+ }
+ privateMetadata {
+ key
+ value
+ }
}
}
}
@@ -601,11 +609,12 @@ def test_create_variant_with_name(
warehouse,
):
# given
- query = CREATE_VARIANT_MUTATION
product_id = graphene.Node.to_global_id("Product", product.pk)
sku = "1"
name = "test-name"
weight = 10.22
+ metadata_key = "md key"
+ metadata_value = "md value"
variant_slug = product_type.variant_attributes.first().slug
attribute_id = graphene.Node.to_global_id(
"Attribute", product_type.variant_attributes.first().pk
@@ -627,12 +636,14 @@ def test_create_variant_with_name(
"weight": weight,
"attributes": [{"id": attribute_id, "values": [variant_value]}],
"trackInventory": True,
+ "metadata": [{"key": metadata_key, "value": metadata_value}],
+ "privateMetadata": [{"key": metadata_key, "value": metadata_value}],
}
}
# when
response = staff_api_client.post_graphql(
- query, variables, permissions=[permission_manage_products]
+ CREATE_VARIANT_MUTATION, variables, permissions=[permission_manage_products]
)
content = get_graphql_content(response)["data"]["productVariantCreate"]
flush_post_commit_hooks()
@@ -649,6 +660,11 @@ def test_create_variant_with_name(
assert len(data["stocks"]) == 1
assert data["stocks"][0]["quantity"] == stocks[0]["quantity"]
assert data["stocks"][0]["warehouse"]["slug"] == warehouse.slug
+ assert data["metadata"][0]["key"] == metadata_key
+ assert data["metadata"][0]["value"] == metadata_value
+ assert data["privateMetadata"][0]["key"] == metadata_key
+ assert data["privateMetadata"][0]["value"] == metadata_value
+
created_webhook_mock.assert_called_once_with(product.variants.last())
updated_webhook_mock.assert_not_called()
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index a8989fc2a7..86abb2363a 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -15606,6 +15606,20 @@ input CategoryInput {
"""Alt text for a product media."""
backgroundImageAlt: String
+
+ """
+ Fields required to update the category metadata.
+
+ Added in Saleor 3.8.
+ """
+ metadata: [MetadataInput!]
+
+ """
+ Fields required to update the category private metadata.
+
+ Added in Saleor 3.8.
+ """
+ privateMetadata: [MetadataInput!]
}
input SeoInput {
@@ -15621,6 +15635,14 @@ Variables of this type must be set to null in mutations. They will be replaced w
"""
scalar Upload
+input MetadataInput {
+ """Key of a metadata item."""
+ key: String!
+
+ """Value of a metadata item."""
+ value: String!
+}
+
"""
Deletes a category.
@@ -15762,6 +15784,20 @@ input CollectionCreateInput {
"""
publicationDate: Date
+ """
+ Fields required to update the collection metadata.
+
+ Added in Saleor 3.8.
+ """
+ metadata: [MetadataInput!]
+
+ """
+ Fields required to update the collection private metadata.
+
+ Added in Saleor 3.8.
+ """
+ privateMetadata: [MetadataInput!]
+
"""List of products to be added to the collection."""
products: [ID!]
}
@@ -15866,6 +15902,20 @@ input CollectionInput {
DEPRECATED: this field will be removed in Saleor 4.0.
"""
publicationDate: Date
+
+ """
+ Fields required to update the collection metadata.
+
+ Added in Saleor 3.8.
+ """
+ metadata: [MetadataInput!]
+
+ """
+ Fields required to update the collection private metadata.
+
+ Added in Saleor 3.8.
+ """
+ privateMetadata: [MetadataInput!]
}
"""
@@ -15992,6 +16042,20 @@ input ProductCreateInput {
"""Defines the product rating value."""
rating: Float
+ """
+ Fields required to update the product metadata.
+
+ Added in Saleor 3.8.
+ """
+ metadata: [MetadataInput!]
+
+ """
+ Fields required to update the product private metadata.
+
+ Added in Saleor 3.8.
+ """
+ privateMetadata: [MetadataInput!]
+
"""ID of the type that product belongs to."""
productType: ID!
}
@@ -16101,6 +16165,20 @@ input ProductInput {
"""Defines the product rating value."""
rating: Float
+
+ """
+ Fields required to update the product metadata.
+
+ Added in Saleor 3.8.
+ """
+ metadata: [MetadataInput!]
+
+ """
+ Fields required to update the product private metadata.
+
+ Added in Saleor 3.8.
+ """
+ privateMetadata: [MetadataInput!]
}
"""
@@ -16443,6 +16521,20 @@ input DigitalContentUploadInput {
"""Overwrite default automatic_fulfillment setting for variant."""
automaticFulfillment: Boolean
+ """
+ Fields required to update the digital content metadata.
+
+ Added in Saleor 3.8.
+ """
+ metadata: [MetadataInput!]
+
+ """
+ Fields required to update the digital content private metadata.
+
+ Added in Saleor 3.8.
+ """
+ privateMetadata: [MetadataInput!]
+
"""Represents an file in a multipart request."""
contentFile: Upload!
}
@@ -16486,6 +16578,20 @@ input DigitalContentInput {
"""Overwrite default automatic_fulfillment setting for variant."""
automaticFulfillment: Boolean
+
+ """
+ Fields required to update the digital content metadata.
+
+ Added in Saleor 3.8.
+ """
+ metadata: [MetadataInput!]
+
+ """
+ Fields required to update the digital content private metadata.
+
+ Added in Saleor 3.8.
+ """
+ privateMetadata: [MetadataInput!]
}
"""
@@ -16551,6 +16657,20 @@ input ProductVariantCreateInput {
"""
quantityLimitPerCustomer: Int
+ """
+ Fields required to update the product variant metadata.
+
+ Added in Saleor 3.8.
+ """
+ metadata: [MetadataInput!]
+
+ """
+ Fields required to update the product variant private metadata.
+
+ Added in Saleor 3.8.
+ """
+ privateMetadata: [MetadataInput!]
+
"""Product ID of which type is the variant."""
product: ID!
@@ -16664,6 +16784,20 @@ input ProductVariantBulkCreateInput {
"""
quantityLimitPerCustomer: Int
+ """
+ Fields required to update the product variant metadata.
+
+ Added in Saleor 3.8.
+ """
+ metadata: [MetadataInput!]
+
+ """
+ Fields required to update the product variant private metadata.
+
+ Added in Saleor 3.8.
+ """
+ privateMetadata: [MetadataInput!]
+
"""Stocks of a product available for sale."""
stocks: [StockInput!]
@@ -16845,6 +16979,20 @@ input ProductVariantInput {
Note: this API is currently in Feature Preview and can be subject to changes at later point.
"""
quantityLimitPerCustomer: Int
+
+ """
+ Fields required to update the product variant metadata.
+
+ Added in Saleor 3.8.
+ """
+ metadata: [MetadataInput!]
+
+ """
+ Fields required to update the product variant private metadata.
+
+ Added in Saleor 3.8.
+ """
+ privateMetadata: [MetadataInput!]
}
"""
@@ -17139,14 +17287,6 @@ input TransactionCreateInput {
privateMetadata: [MetadataInput!]
}
-input MetadataInput {
- """Key of a metadata item."""
- key: String!
-
- """Value of a metadata item."""
- value: String!
-}
-
input TransactionEventInput {
"""Current status of the payment transaction."""
status: TransactionStatus!