Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add MANAGE_PAGE_TYPES_AND_ATTRIBUTES permission to PageType (#12141)
Krzysztof Waliczekbe09b6c9435b
diff --git a/saleor/graphql/page/tests/queries/test_page_type.py b/saleor/graphql/page/tests/queries/test_page_type.pyindex 8b10afb62f..879af6d773 100644--- a/saleor/graphql/page/tests/queries/test_page_type.py+++ b/saleor/graphql/page/tests/queries/test_page_type.py@@ -62,6 +62,38 @@ def test_page_type_query_by_staff(assert available_attributes[0]["node"]["slug"] == author_page_attribute.slug+def test_page_type_query_by_staff_with_page_type_permission(+ staff_api_client,+ page_type,+ author_page_attribute,+ permission_manage_page_types_and_attributes,+ color_attribute,+ page,+):+ # given+ staff_user = staff_api_client.user+ staff_user.user_permissions.add(permission_manage_page_types_and_attributes)++ variables = {"id": graphene.Node.to_global_id("PageType", page_type.pk)}++ # when+ response = staff_api_client.post_graphql(PAGE_TYPE_QUERY, variables)++ # then+ content = get_graphql_content(response)+ page_type_data = content["data"]["pageType"]++ assert page_type_data["slug"] == page_type.slug+ assert page_type_data["name"] == page_type.name+ assert {attr["slug"] for attr in page_type_data["attributes"]} == {+ attr.slug for attr in page_type.page_attributes.all()+ }+ assert page_type_data["hasPages"] is True+ available_attributes = page_type_data["availableAttributes"]["edges"]+ assert len(available_attributes) == 1+ assert available_attributes[0]["node"]["slug"] == author_page_attribute.slug++def test_page_type_query_by_staff_no_perm(staff_api_client, page_type, author_page_attribute):diff --git a/saleor/graphql/page/types.py b/saleor/graphql/page/types.pyindex 88aea9928c..82eb8766df 100644--- a/saleor/graphql/page/types.py+++ b/saleor/graphql/page/types.py@@ -4,7 +4,7 @@ import graphenefrom ...attribute import models as attribute_modelsfrom ...page import models-from ...permission.enums import PagePermissions+from ...permission.enums import PagePermissions, PageTypePermissionsfrom ..attribute.filters import AttributeFilterInput, AttributeWhereInputfrom ..attribute.types import Attribute, AttributeCountableConnection, SelectedAttributefrom ..core import ResolveInfo@@ -44,6 +44,7 @@ class PageType(ModelObjectType[models.PageType]):description="Attributes that can be assigned to the page type.",permissions=[PagePermissions.MANAGE_PAGES,+ PageTypePermissions.MANAGE_PAGE_TYPES_AND_ATTRIBUTES,],)has_pages = PermissionsField(@@ -51,6 +52,7 @@ class PageType(ModelObjectType[models.PageType]):description="Whether page type has pages assigned.",permissions=[PagePermissions.MANAGE_PAGES,+ PageTypePermissions.MANAGE_PAGE_TYPES_AND_ATTRIBUTES,],)diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex a3f3fcf5d5..182e67bbc3 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -7559,7 +7559,7 @@ type PageType implements Node & ObjectWithMetadata {"""Attributes that can be assigned to the page type.- Requires one of the following permissions: MANAGE_PAGES.+ Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES."""availableAttributes(filter: AttributeFilterInput@@ -7581,7 +7581,7 @@ type PageType implements Node & ObjectWithMetadata {"""Whether page type has pages assigned.- Requires one of the following permissions: MANAGE_PAGES.+ Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES."""hasPages: Boolean}