Skip to content

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

Merge branch 'master' into add-products-csv-export

IKarbowiakd03b7275142e
diff --cc .isort.cfg
index 1ed3a39cb1,d709086dbb..b8795de6a5
--- a/.isort.cfg
+++ b/.isort.cfg
@@@ -1,2 -1,2 +1,2 @@@
[settings]
- known_third_party = PIL,babel,braintree,celery,dj_database_url,dj_email_url,django,django_cache_url,django_countries,django_filters,django_measurement,django_prices,django_prices_openexchangerates,django_prices_vatlayer,draftjs_sanitizer,faker,freezegun,geolite2,google_measurement_protocol,graphene,graphene_django,graphene_federation,graphql,graphql_jwt,graphql_relay,html_to_draftjs,i18naddress,jaeger_client,jwt,markdown,measurement,mptt,oauthlib,openpyxl,opentracing,petl,phonenumber_field,phonenumbers,pkg_resources,prices,promise,pytest,pytz,razorpay,requests,sentry_sdk,storages,stripe,templated_email,text_unidecode,tqdm,versatileimagefield
-known_third_party = PIL,babel,braintree,celery,dj_database_url,dj_email_url,django,django_cache_url,django_countries,django_filters,django_measurement,django_prices,django_prices_openexchangerates,django_prices_vatlayer,draftjs_sanitizer,faker,freezegun,geolite2,google_measurement_protocol,graphene,graphene_django,graphene_federation,graphql,graphql_relay,html_to_draftjs,i18naddress,jaeger_client,jwt,markdown,measurement,mptt,oauthlib,opentracing,phonenumber_field,phonenumbers,pkg_resources,prices,promise,pytest,pytimeparse,pytz,razorpay,requests,sentry_sdk,storages,stripe,templated_email,text_unidecode,tqdm,versatileimagefield
++known_third_party = PIL,babel,braintree,celery,dj_database_url,dj_email_url,django,django_cache_url,django_countries,django_filters,django_measurement,django_prices,django_prices_openexchangerates,django_prices_vatlayer,draftjs_sanitizer,faker,freezegun,geolite2,google_measurement_protocol,graphene,graphene_django,graphene_federation,graphql,graphql_relay,html_to_draftjs,i18naddress,jaeger_client,jwt,markdown,measurement,mptt,oauthlib,openpyxl,opentracing,petl,phonenumber_field,phonenumbers,pkg_resources,prices,promise,pytest,pytimeparse,pytz,razorpay,requests,sentry_sdk,storages,stripe,templated_email,text_unidecode,tqdm,versatileimagefield
diff --cc CHANGELOG.md
index ec32d027cf,c3d91e65fc..e44d4e91fe
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -7,9 -7,11 +7,12 @@@ All notable, unreleased changes to thi
- Add our implementation of UUID scalar - #5646 by @koradon
- Add AppTokenVerify mutation - #5716 by @korycins
- Fix specific product voucher in draft orders - #5727 by @fowczarek
+- Add products csv export - #5255 by @IKarbowiak
- Explicit country assignment in default shipping zones - #5736 by @maarcingebala
- Drop `json_content` field from the `Menu` model - #5761 by @maarcingebala
+ - Refactor JWT support - #5734 by @korycins
+ - Strip warehouse name in mutations - #5766 by @koradon
+ - Add missing OrderEvents during checkout flow - #5684 by @koradon
## 2.10.1
diff --cc poetry.lock
index 4630d88e80,289fd91ff3..e1462454f5
--- a/poetry.lock
+++ b/poetry.lock
@@@ -1374,7 -1324,7 +1360,7 @@@ description = "Python version of Google
name = "phonenumberslite"
optional = false
python-versions = "*"
--version = "8.12.5"
++version = "8.12.6"
[[package]]
category = "main"
@@@ -2244,7 -2202,7 +2238,7 @@@ idna = ">=2.0
multidict = ">=4.0"
[metadata]
- content-hash = "4cc8adf6a992f59053250c83dc117177e9a3c74dc6ef81172176caf593dfc236"
-content-hash = "844421a2f32e9be107fb139b8c3d646339d4af74548378e13b1d50df84a75190"
++content-hash = "cc5ec869de4a06c72d1085e08aeb0a98c5553d3fa466903504d25b3e00a902e7"
python-versions = "~3.8"
[metadata.files]
@@@ -2829,12 -2773,9 +2819,12 @@@ pathspec =
{file = "pathspec-0.8.0-py2.py3-none-any.whl", hash = "sha256:7d91249d21749788d07a2d0f94147accd8f845507400749ea19c1ec9054a12b0"},
{file = "pathspec-0.8.0.tar.gz", hash = "sha256:da45173eb3a6f2a5a487efba21f050af2b41948be6ab52b6a1e3ff22bb8b7061"},
]
+petl = [
+ {file = "petl-1.3.0.tar.gz", hash = "sha256:943a6e3211616d25ebc4dcd900ca4f96f53ccd9dbb612271a23a7efdaf3f8c00"},
+]
phonenumberslite = [
-- {file = "phonenumberslite-8.12.5-py2.py3-none-any.whl", hash = "sha256:7e101c2d0be6ead83e2706c355aaba236df97e9a7b78aed5bda5d4b0eee11178"},
-- {file = "phonenumberslite-8.12.5.tar.gz", hash = "sha256:6e1d31d8a5ad1fe280c3f7ba5b9c08da82245d59946ee06856712ef704f59e19"},
++ {file = "phonenumberslite-8.12.6-py2.py3-none-any.whl", hash = "sha256:f898bff9cb2fe6a0f6e6d6d8d27e550acf77af4cf20ec22f4f02c0a399ae6f39"},
++ {file = "phonenumberslite-8.12.6.tar.gz", hash = "sha256:19c8f083676061ca5848104aaecfd0d6378d1fc9b37d3777a8636fce05bca6d1"},
]
pillow = [
{file = "Pillow-7.1.2-cp35-cp35m-macosx_10_10_intel.whl", hash = "sha256:ae2b270f9a0b8822b98655cb3a59cdb1bd54a34807c6c56b76dd2e786c3b7db3"},
@@@ -3104,11 -3049,11 +3098,11 @@@ regex =
{file = "regex-2020.6.8.tar.gz", hash = "sha256:e9b64e609d37438f7d6e68c2546d2cb8062f3adb27e6336bc129b51be20773ac"},
]
requests = [
- {file = "requests-2.23.0-py2.py3-none-any.whl", hash = "sha256:43999036bfa82904b6af1d99e4882b560e5e2c68e5c4b0aa03b655f3d7d73fee"},
- {file = "requests-2.23.0.tar.gz", hash = "sha256:b3f43d496c6daba4493e7c431722aeb7dbc6288f52a6e04e7b6023b0247817e6"},
+ {file = "requests-2.24.0-py2.py3-none-any.whl", hash = "sha256:fe75cc94a9443b9246fc7049224f75604b113c36acb93f87b80ed42c44cbb898"},
+ {file = "requests-2.24.0.tar.gz", hash = "sha256:b3559a131db72c33ee969480840fff4bb6dd111de7dd27c8ee1f820f4f00231b"},
]
rsa = [
- {file = "rsa-4.6-py2.py3-none-any.whl", hash = "sha256:23778f5523461cf86ae075f9482a99317f362bca752ae57cb118044066f4026f"},
+ {file = "rsa-4.6-py3-none-any.whl", hash = "sha256:6166864e23d6b5195a5cfed6cd9fed0fe774e226d8f854fcb23b7bbef0350233"},
{file = "rsa-4.6.tar.gz", hash = "sha256:109ea5a66744dd859bf16fe904b8d8b627adafb9408753161e766a92e7d681fa"},
]
rx = [
diff --cc pyproject.toml
index 1fd5e17dcd,a8e83713ac..15102e0413
--- a/pyproject.toml
+++ b/pyproject.toml
@@@ -61,8 -59,9 +60,10 @@@ uwsgi = {version = "^2.0.19", platform
weasyprint = ">=48"
oauthlib = "^3.0"
jaeger-client = "^4.3.0"
+openpyxl = "^3.0.3"
django-cache-url = "^3.1.2"
+ pyjwt = "^1.7.1"
+ pytimeparse = "^1.1.8"
[tool.poetry.dev-dependencies]
black = "19.10b0"
diff --cc requirements.txt
index abe8984f8f,261ca6d9da..a80e85a9bc
--- a/requirements.txt
+++ b/requirements.txt
@@@ -70,10 -67,8 +69,10 @@@ maxminddb-geolite2==2018.70
measurement==3.2.0
mpmath==1.1.0
oauthlib==3.1.0
+openpyxl==3.0.3
opentracing==2.3.0
-phonenumberslite==8.12.5
+petl==1.3.0
- phonenumberslite==8.12.5
++phonenumberslite==8.12.6
pillow==7.1.2
prices==1.0.0
promise==2.3
diff --cc requirements_dev.txt
index e0aee5ff32,d32abbf844..8ea4ed9c25
--- a/requirements_dev.txt
+++ b/requirements_dev.txt
@@@ -108,8 -104,7 +107,8 @@@ openpyxl==3.0.
opentracing==2.3.0
packaging==20.4
pathspec==0.8.0
-phonenumberslite==8.12.5
+petl==1.3.0
- phonenumberslite==8.12.5
++phonenumberslite==8.12.6
pillow==7.1.2
pluggy==0.13.1
pre-commit==2.5.1
diff --cc saleor/graphql/api.py
index 1923083033,c2877afa1a..c389eaaf63
--- a/saleor/graphql/api.py
+++ b/saleor/graphql/api.py
@@@ -3,8 -3,7 +3,8 @@@ from graphene_federation import build_s
from .account.schema import AccountMutations, AccountQueries
from .app.schema import AppMutations, AppQueries
from .checkout.schema import CheckoutMutations, CheckoutQueries
- from .core.schema import CoreMutations, CoreQueries
+ from .core.schema import CoreQueries
+from .csv.schema import CsvMutations, CsvQueries
from .discount.schema import DiscountMutations, DiscountQueries
from .giftcard.schema import GiftCardMutations, GiftCardQueries
from .menu.schema import MenuMutations, MenuQueries
@@@ -49,8 -47,6 +49,7 @@@ class Mutation
AccountMutations,
AppMutations,
CheckoutMutations,
- CoreMutations,
+ CsvMutations,
DiscountMutations,
PluginsMutations,
GiftCardMutations,
diff --cc saleor/graphql/csv/types.py
index 5493456490,0000000000..3b9a524ac9
mode 100644,000000..100644
--- a/saleor/graphql/csv/types.py
+++ b/saleor/graphql/csv/types.py
@@@ -1,92 -1,0 +1,92 @@@
+import graphene
- from graphql_jwt.exceptions import PermissionDenied
+
++from ...core.exceptions import PermissionDenied
+from ...core.permissions import AccountPermissions, AppPermission
+from ...csv import models
+from ..account.types import User
+from ..app.types import App
+from ..core.connection import CountableDjangoObjectType
+from ..core.types.common import Job
+from ..utils import get_user_or_app_from_context
+from .enums import ExportEventEnum
+
+
+class ExportEvent(CountableDjangoObjectType):
+ date = graphene.types.datetime.DateTime(
+ description="Date when event happened at in ISO 8601 format.", required=True,
+ )
+ type = ExportEventEnum(description="Export event type.", required=True)
+ user = graphene.Field(
+ User, description="User who performed the action.", required=False
+ )
+ app = graphene.Field(
+ App, description="App which performed the action.", required=False
+ )
+ message = graphene.String(description="Content of the event.", required=True,)
+
+ class Meta:
+ description = "History log of export file."
+ model = models.ExportEvent
+ interfaces = [graphene.relay.Node]
+ only_fields = ["id"]
+
+ @staticmethod
+ def resolve_user(root: models.ExportEvent, info):
+ requestor = get_user_or_app_from_context(info.context)
+ if requestor == root.user or requestor.has_perm(
+ AccountPermissions.MANAGE_STAFF
+ ):
+ return root.user
+ raise PermissionDenied()
+
+ @staticmethod
+ def resolve_app(root: models.ExportEvent, info):
+ requestor = get_user_or_app_from_context(info.context)
+ if requestor == root.app or requestor.has_perm(AppPermission.MANAGE_APPS):
+ return root.app
+ raise PermissionDenied()
+
+ @staticmethod
+ def resolve_message(root: models.ExportEvent, _info):
+ return root.parameters.get("message", None)
+
+
+class ExportFile(CountableDjangoObjectType):
+ url = graphene.String(description="The URL of field to download.")
+ events = graphene.List(
+ graphene.NonNull(ExportEvent),
+ description="List of events associated with the export.",
+ )
+
+ class Meta:
+ description = "Represents a job data of exported file."
+ interfaces = [graphene.relay.Node, Job]
+ model = models.ExportFile
+ only_fields = ["id", "user", "app", "url"]
+
+ @staticmethod
+ def resolve_url(root: models.ExportFile, info):
+ content_file = root.content_file
+ if not content_file:
+ return None
+ return info.context.build_absolute_uri(content_file.url)
+
+ @staticmethod
+ def resolve_user(root: models.ExportFile, info):
+ requestor = get_user_or_app_from_context(info.context)
+ if requestor == root.user or requestor.has_perm(
+ AccountPermissions.MANAGE_STAFF
+ ):
+ return root.user
+ raise PermissionDenied()
+
+ @staticmethod
+ def resolve_app(root: models.ExportFile, info):
+ requestor = get_user_or_app_from_context(info.context)
+ if requestor == root.app or requestor.has_perm(AppPermission.MANAGE_APPS):
+ return root.app
+ raise PermissionDenied()
+
+ @staticmethod
+ def resolve_events(root: models.ExportFile, _info):
+ return root.events.all().order_by("pk")
diff --cc saleor/graphql/schema.graphql
index bdef99a43f,26a069198a..bdb44d2c5e
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@@ -2564,10 -2461,6 +2576,7 @@@ type Mutation
voucherCataloguesAdd(id: ID!, input: CatalogueInput!): VoucherAddCatalogues
voucherCataloguesRemove(id: ID!, input: CatalogueInput!): VoucherRemoveCatalogues
voucherTranslate(id: ID!, input: NameTranslationInput!, languageCode: LanguageCodeEnum!): VoucherTranslate
+ exportProducts(input: ExportProductsInput!): ExportProducts
- tokenCreate(email: String!, password: String!): CreateToken
- tokenRefresh(token: String!): RefreshToken
- tokenVerify(token: String!): VerifyToken
checkoutAddPromoCode(checkoutId: ID!, promoCode: String!): CheckoutAddPromoCode
checkoutBillingAddressUpdate(billingAddress: AddressInput!, checkoutId: ID!): CheckoutBillingAddressUpdate
checkoutComplete(checkoutId: ID!, redirectUrl: String, storeSource: Boolean = false): CheckoutComplete