Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Added createdByEmail filter in GiftCard (#13132)
Smit Parmara576e993bab7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8f4918d464..ac094f2276 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -19,6 +19,8 @@ All notable, unreleased changes to this project will be documented in this file.- Add `orderNoteAdd` and `orderNoteUpdate` mutations and deprecate `orderAddNote` mutation - #12434 by @pawelzar- Deprecate `Order.trackingClientId` field - #13146 by @SzymJ+- Fix error "Cannot return null for non-nullable field Webhook.name" - #12989 by @Smit-Parmar+- Added `GiftCardFilterInput.createdByEmail` filter - #13132 by @Smit-Parmar### Saleor Apps@@ -27,7 +29,6 @@ All notable, unreleased changes to this project will be documented in this file.### Other changes- Expand metric units to support more types of products. - #13043 by @FremahA-- Fix Error Cannot return null for non-nullable field Webhook.name. - #12989 by @cyborg7898- Remove unused `django-versatileimagefield` package - #13148 by @SzymJ- Remove unused `google-measurement-protocol` package - #13146 by @SzymJ- Add missing descriptions to App module. - #13163 by @fowczarekdiff --git a/saleor/graphql/giftcard/filters.py b/saleor/graphql/giftcard/filters.pyindex 8024fd9663..67b3baf4de 100644--- a/saleor/graphql/giftcard/filters.py+++ b/saleor/graphql/giftcard/filters.py@@ -85,6 +85,12 @@ def filter_code(qs, _, value):return qs.filter(code=value)+def filter_created_by_email(qs, _, value):+ if not value:+ return qs+ return qs.filter(created_by_email=value)++class GiftCardFilter(MetadataFilterBase):tags = ListObjectTypeFilter(input_class=graphene.String, method=filter_tags_list)products = GlobalIDMultipleChoiceFilter(method=filter_products)@@ -99,6 +105,7 @@ class GiftCardFilter(MetadataFilterBase):)is_active = django_filters.BooleanFilter()code = django_filters.CharFilter(method=filter_code)+ created_by_email = django_filters.CharFilter(method=filter_created_by_email)class Meta:model = models.GiftCarddiff --git a/saleor/graphql/giftcard/tests/queries/test_gift_card_filtering.py b/saleor/graphql/giftcard/tests/queries/test_gift_card_filtering.pyindex 9a2ae6dee4..2cac2df41c 100644--- a/saleor/graphql/giftcard/tests/queries/test_gift_card_filtering.py+++ b/saleor/graphql/giftcard/tests/queries/test_gift_card_filtering.py@@ -10,6 +10,7 @@ QUERY_GIFT_CARDS = """edges {node {id+ createdByEmaillast4CodeCharsproduct {name@@ -495,3 +496,25 @@ def test_query_filter_gift_cards_by_metadata(content = get_graphql_content(response)data = content["data"]["giftCards"]["edges"]assert len(data) == 1+++def test_query_filter_gift_cards_by_created_by_email(+ staff_api_client,+ gift_card,+ permission_manage_gift_card,+):+ # given+ query = QUERY_GIFT_CARDS++ variables = {"filter": {"createdByEmail": gift_card.created_by_email}}++ # when+ response = staff_api_client.post_graphql(+ query, variables, permissions=[permission_manage_gift_card]+ )++ # then+ content = get_graphql_content(response)+ data = content["data"]["giftCards"]["edges"]+ assert len(data) == 1+ assert data[0]["node"]["createdByEmail"] == "[email protected]"diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex db86aa397f..1e59f81324 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -12643,6 +12643,7 @@ input GiftCardFilterInput @doc(category: "Gift cards") {currentBalance: PriceRangeInputinitialBalance: PriceRangeInputcode: String+ createdByEmail: String}type GiftCardTagCountableConnection @doc(category: "Gift cards") {