Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Merge branch 'master' into feature/extending_app_support
Maciej Korycinski34b9c885bf09
diff --cc CHANGELOG.mdindex cb91b4c4de,46bf4732ba..19a3980a5b--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -4,11 -4,7 +4,12 @@@ All notable, unreleased changes to thi## [Unreleased]+### Features++- Merge `manage_webhooks` permission with `manage_apps` - #5556 by @korycins+- Add App support - #5767 by @korycins++ - Invoices backend - #5732 by @tomaszszymanski129### Breaking Changes- Refactor JWT support - These changes could require a handling JWT token in the storefront. Storefront needs to handle a case when the backend returns the exception about the invalid token. - #5734, #5816 by @korycinsdiff --cc saleor/csv/migrations/0002_exportfile_message.pyindex 0000000000,0000000000..c59e47f1a7new file mode 100644--- /dev/null+++ b/saleor/csv/migrations/0002_exportfile_message.py@@@ -1,0 -1,0 +1,18 @@@++# Generated by Django 3.0.6 on 2020-07-10 11:07++++from django.db import migrations, models++++++class Migration(migrations.Migration):++++ dependencies = [++ ("csv", "0001_initial"),++ ]++++ operations = [++ migrations.AddField(++ model_name="exportfile",++ name="message",++ field=models.CharField(blank=True, max_length=255, null=True),++ ),++ ]diff --cc saleor/graphql/schema.graphqlindex 1985b6471f,a9b7f3a383..a9aa16b92b--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@@ -1838,6 -1763,108 +1838,109 @@@ type Errormessage: String}+ type ExportError {+ field: String+ message: String+ code: ExportErrorCode!+ }++ enum ExportErrorCode {+ INVALID+ NOT_FOUND+ REQUIRED+ }++ type ExportEvent implements Node {+ id: ID!+ date: DateTime!+ type: ExportEventsEnum!+ user: User+ app: App+ message: String!+ }++ enum ExportEventsEnum {+ EXPORT_PENDING+ EXPORT_SUCCESS+ EXPORT_FAILED+ EXPORT_DELETED+ EXPORTED_FILE_SENT+ EXPORT_FAILED_INFO_SENT+ }++ type ExportFile implements Node & Job {+ id: ID!+ user: User+ app: App+ status: JobStatusEnum!+ createdAt: DateTime!+ updatedAt: DateTime!++ message: String+ url: String+ events: [ExportEvent!]+ }++ type ExportFileCountableConnection {+ pageInfo: PageInfo!+ edges: [ExportFileCountableEdge!]!+ totalCount: Int+ }++ type ExportFileCountableEdge {+ node: ExportFile!+ cursor: String!+ }++ input ExportFileFilterInput {+ createdAt: DateTimeRangeInput+ updatedAt: DateTimeRangeInput+ status: JobStatusEnum+ user: String+ app: String+ }++ enum ExportFileSortField {+ STATUS+ CREATED_AT+ UPDATED_AT+ }++ input ExportFileSortingInput {+ direction: OrderDirection!+ field: ExportFileSortField!+ }++ input ExportInfoInput {+ attributes: [ID!]+ warehouses: [ID!]+ fields: [ProductFieldEnum!]+ }++ type ExportProducts {+ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")+ exportFile: ExportFile+ exportErrors: [ExportError!]!+ }++ input ExportProductsInput {+ scope: ExportScope!+ filter: ProductFilterInput+ ids: [ID!]+ exportInfo: ExportInfoInput+ fileType: FileTypesEnum!+ }++ enum ExportScope {+ ALL+ IDS+ FILTER+ }++ enum FileTypesEnum {+ CSV+ XLSX+ }+type Fulfillment implements Node & ObjectWithMetadata {id: ID!fulfillmentOrder: Int!@@@ -2032,6 -2059,78 +2135,79 @@@ input IntRangeInputlte: Int}+ type Invoice implements ObjectWithMetadata & Job & Node {++ status: JobStatusEnum!+ id: ID!+ metadata: [MetadataItem]!- status: JobStatusEnum!+ number: String+ externalUrl: String+ privateMetadata: [MetadataItem]!+ privateMeta: [MetaStore]! @deprecated(reason: "Use the `privetaMetadata` field. This field will be removed after 2020-07-31.")+ meta: [MetaStore]! @deprecated(reason: "Use the `metadata` field. This field will be removed after 2020-07-31.")+ createdAt: DateTime!+ updatedAt: DateTime!++ message: String+ url: String+ }++ type InvoiceCreate {+ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")+ invoiceErrors: [InvoiceError!]!+ invoice: Invoice+ }++ input InvoiceCreateInput {+ number: String!+ url: String!+ }++ type InvoiceDelete {+ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")+ invoiceErrors: [InvoiceError!]!+ invoice: Invoice+ }++ type InvoiceError {+ field: String+ message: String+ code: InvoiceErrorCode!+ }++ enum InvoiceErrorCode {+ REQUIRED+ NOT_READY+ URL_NOT_SET+ EMAIL_NOT_SET+ NUMBER_NOT_SET+ NOT_FOUND+ INVALID_STATUS+ }++ type InvoiceRequest {+ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")+ order: Order+ invoiceErrors: [InvoiceError!]!+ invoice: Invoice+ }++ type InvoiceRequestDelete {+ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")+ invoiceErrors: [InvoiceError!]!+ invoice: Invoice+ }++ type InvoiceSendEmail {+ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")+ invoiceErrors: [InvoiceError!]!+ invoice: Invoice+ }++ type InvoiceUpdate {+ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")+ invoiceErrors: [InvoiceError!]!+ invoice: Invoice+ }+scalar JSONStringinterface Job {diff --cc saleor/invoice/migrations/0002_invoice_message.pyindex 0000000000,0000000000..0dd75a79e9new file mode 100644--- /dev/null+++ b/saleor/invoice/migrations/0002_invoice_message.py@@@ -1,0 -1,0 +1,18 @@@++# Generated by Django 3.0.6 on 2020-07-10 11:07++++from django.db import migrations, models++++++class Migration(migrations.Migration):++++ dependencies = [++ ("invoice", "0001_initial"),++ ]++++ operations = [++ migrations.AddField(++ model_name="invoice",++ name="message",++ field=models.CharField(blank=True, max_length=255, null=True),++ ),++ ]diff --cc saleor/tests/fixtures.pyindex fb99a0123d,da003dd0b8..9ad3314017--- a/saleor/tests/fixtures.py+++ b/saleor/tests/fixtures.py@@@ -2245,9 -2256,76 +2273,84 @@@ def allocations(order_list, stock))+def app_installation():+ app_installation = AppInstallation.objects.create(+ app_name="External App", manifest_url="http://localhost:3000/manifest",+ )+ return app_installation+++++ @pytest.fixture+ def user_export_file(staff_user):+ job = ExportFile.objects.create(user=staff_user)+ return job+++ @pytest.fixture+ def app_export_file(app):+ job = ExportFile.objects.create(app=app)+ return job+++ @pytest.fixture+ def export_file_list(staff_user):+ export_file_list = list(+ ExportFile.objects.bulk_create(+ [+ ExportFile(user=staff_user),+ ExportFile(user=staff_user,),+ ExportFile(user=staff_user, status=JobStatus.SUCCESS,),+ ExportFile(user=staff_user, status=JobStatus.SUCCESS),+ ExportFile(user=staff_user, status=JobStatus.FAILED,),+ ]+ )+ )++ updated_date = datetime.datetime(+ 2019, 4, 18, tzinfo=timezone.get_current_timezone()+ )+ created_date = datetime.datetime(+ 2019, 4, 10, tzinfo=timezone.get_current_timezone()+ )+ new_created_and_updated_dates = [+ (created_date, updated_date),+ (created_date, updated_date + datetime.timedelta(hours=2)),+ (+ created_date + datetime.timedelta(hours=2),+ updated_date - datetime.timedelta(days=2),+ ),+ (created_date - datetime.timedelta(days=2), updated_date),+ (+ created_date - datetime.timedelta(days=5),+ updated_date - datetime.timedelta(days=5),+ ),+ ]+ for counter, export_file in enumerate(export_file_list):+ created, updated = new_created_and_updated_dates[counter]+ export_file.created_at = created+ export_file.updated_at = updated++ ExportFile.objects.bulk_update(export_file_list, ["created_at", "updated_at"])++ return export_file_list+++ @pytest.fixture+ def user_export_event(user_export_file):+ return ExportEvent.objects.create(+ type=ExportEvents.EXPORT_FAILED,+ export_file=user_export_file,+ user=user_export_file.user,+ parameters={"message": "Example error message"},+ )+++ @pytest.fixture+ def app_export_event(app_export_file):+ return ExportEvent.objects.create(+ type=ExportEvents.EXPORT_FAILED,+ export_file=app_export_file,+ app=app_export_file.app,+ parameters={"message": "Example error message"},+ )