Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Merge branch 'master' into add-products-csv-export
IKarbowiak1ef9b9810597
diff --cc .isort.cfgindex 8c4afd3e1f,42a876e47e..a59c7f76db--- 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_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,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_jwt,graphql_relay,html_to_draftjs,i18naddress,jaeger_client,jwt,markdown,measurement,mptt,oauthlib,opentracing,phonenumber_field,phonenumbers,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_jwt,graphql_relay,html_to_draftjs,i18naddress,jaeger_client,jwt,markdown,measurement,mptt,oauthlib,openpyxl,opentracing,petl,phonenumber_field,phonenumbers,prices,promise,pytest,pytz,razorpay,requests,sentry_sdk,storages,stripe,templated_email,text_unidecode,tqdm,versatileimagefielddiff --cc pyproject.tomlindex bf9026b31e,989bed2a94..83a11436f5--- a/pyproject.toml+++ b/pyproject.toml@@@ -42,9 -42,8 +42,9 @@@ graphene-django = "^2.9.1graphene-federation = "^0.1.0"html-to-draftjs = "^1.0.1"markdown = "^3.1.1"- maxminddb = "^1.4.1"+ maxminddb = "^1.5.4"maxminddb-geolite2 = "^2018.701"+petl ="^1.3.0"opentracing = "^2.3.0"phonenumberslite = "^8.12.2"prices = "^1.0"@@@ -61,7 -60,7 +61,8 @@@ uwsgi = {version = "^2.0.8", platformweasyprint = ">=48"oauthlib = "^3.0"jaeger-client = "^4.3.0"+openpyxl = "^3.0.3"+ django-cache-url = "^3.1.2"[tool.poetry.dev-dependencies]black = "19.10b0"diff --cc templates/templated_email/compiled/export_products_csv.htmlindex 6a500db654,0000000000..3d4ed23796mode 100644,000000..100644--- a/templates/templated_email/compiled/export_products_csv.html+++ b/templates/templated_email/compiled/export_products_csv.html@@@ -1,405 -1,0 +1,329 @@@++ <!doctype html>+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">+ <head>+ <title>++ </title>+ <!--[if !mso]><!-- -->+ <meta http-equiv="X-UA-Compatible" content="IE=edge">+ <!--<![endif]-->+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1">+ <style type="text/css">+ #outlook a { padding:0; }+ body { margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%; }+ table, td { border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt; }+ img { border:0;height:auto;line-height:100%; outline:none;text-decoration:none;-ms-interpolation-mode:bicubic; }+ p { display:block;margin:13px 0; }+ </style>+ <!--[if mso]>+ <xml>+ <o:OfficeDocumentSettings>+ <o:AllowPNG/>+ <o:PixelsPerInch>96</o:PixelsPerInch>+ </o:OfficeDocumentSettings>+ </xml>+ <![endif]-->+ <!--[if lte mso 11]>+ <style type="text/css">+ .mj-outlook-group-fix { width:100% !important; }+ </style>+ <![endif]-->++ <!--[if !mso]><!-->+ <link href="https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700" rel="stylesheet" type="text/css">+ <style type="text/css">+ @import url(https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700);+ </style>+ <!--<![endif]-->++++ <style type="text/css">+ @media only screen and (min-width:480px) {+ .mj-column-per-100 { width:100% !important; max-width: 100%; }+ }+ </style>+++ <style type="text/css">++-- @media only screen and (max-width:480px) {- table.mj-full-width-mobile { width: 100% !important; }- td.mj-full-width-mobile { width: auto !important; }- }-+ </style>+ <style type="text/css">address {+ font-style: inherit;+ font-family: Ubuntu, Helvetica, Arial;+ }</style>++ </head>+ <body>+++ <div style>+ {% load i18n %}{% load static %}++ <!--[if mso | IE]>+ <table+ align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600"+ >+ <tr>+ <td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">+ <![endif]-->++- <div style="margin:0px auto;max-width:600px;">-- <table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">- <tbody>- <tr>- <td style="direction: ltr; font-size: 0px; padding: 20px 0; text-align: center;" align="center">- <!--[if mso | IE]>- <table role="presentation" border="0" cellpadding="0" cellspacing="0">-- <tr>-- <td- class="" style="vertical-align:top;width:600px;"- >- <![endif]-->-- <div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">-- <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">-- <tr>- <td align="center" style="font-size: 0px; padding: 10px 25px; word-break: break-word;">-- <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:collapse;border-spacing:0px;">- <tbody>- <tr>- <td style="padding: 5px; width: 176px;" width="176">-- <img height="38" src="{{ logo_url }}" style="border:0;display:block;outline:none;text-decoration:none;height:38px;width:100%;font-size:13px;" width="176">-- </td>- </tr>- </tbody>- </table>-- </td>- </tr>-- </table>-- </div>-- <!--[if mso | IE]>- </td>-- </tr>-- </table>- <![endif]-->- </td>- </tr>- </tbody>- </table>-- </div>--- <!--[if mso | IE]>- </td>- </tr>- </table>-- <table- align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600"- >- <tr>- <td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">- <![endif]-->--+ <div style="margin:0px auto;max-width:600px;">++ <table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">+ <tbody>+ <tr>+ <td style="direction: ltr; font-size: 0px; padding: 20px 0; text-align: center;" align="center">+ <!--[if mso | IE]>+ <table role="presentation" border="0" cellpadding="0" cellspacing="0">++ <tr>++ <td+ class="" style="vertical-align:top;width:600px;"+ >+ <![endif]-->++ <div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">++ <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">++ <tr>+ <td align="left" style="font-size: 0px; padding: 10px 25px; word-break: break-word;">++ <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:16px;line-height:1;text-align:left;color:#000000;">{% trans "Hi!" context "Standard e-mail greeting" %}</div>++ </td>+ </tr>++ <tr>+ <td align="left" style="font-size: 0px; padding: 10px 25px; word-break: break-word;">++ <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;">{% blocktrans context "Export products e-mail text" %}+ Your CSV file with products data is ready to download: <a href="{{ csv_link }}">{{ csv_link }}</a>+ {% endblocktrans %}</div>++ </td>+ </tr>++ </table>++ </div>++ <!--[if mso | IE]>+ </td>++ </tr>++ </table>+ <![endif]-->+ </td>+ </tr>+ </tbody>+ </table>++ </div>+++ <!--[if mso | IE]>+ </td>+ </tr>+ </table>++ <table+ align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600"+ >+ <tr>+ <td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">+ <![endif]-->+++ <div style="margin:0px auto;max-width:600px;">++ <table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">+ <tbody>+ <tr>+ <td style="direction: ltr; font-size: 0px; padding: 20px 0; text-align: center;" align="center">+ <!--[if mso | IE]>+ <table role="presentation" border="0" cellpadding="0" cellspacing="0">++ <tr>++ <td+ class="" style="vertical-align:top;width:600px;"+ >+ <![endif]-->++ <div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">++ <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">++ <tr>+ <td align="left" style="font-size: 0px; padding: 10px 25px; word-break: break-word;">++ <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;">{% blocktrans trimmed context "Base email text" %}+ This is an automatically generated e-mail, please do not reply.+ {% endblocktrans %}</div>++ </td>+ </tr>++ </table>++ </div>++ <!--[if mso | IE]>+ </td>++ </tr>++ </table>+ <![endif]-->+ </td>+ </tr>+ </tbody>+ </table>++ </div>+++ <!--[if mso | IE]>+ </td>+ </tr>+ </table>++ <table+ align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600"+ >+ <tr>+ <td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">+ <![endif]-->+++ <div style="background:#F2F2F2;background-color:#F2F2F2;margin:0px auto;max-width:600px;">++ <table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#F2F2F2;background-color:#F2F2F2;width:100%;">+ <tbody>+ <tr>+ <td style="direction: ltr; font-size: 0px; padding: 20px 0; text-align: center;" align="center">+ <!--[if mso | IE]>+ <table role="presentation" border="0" cellpadding="0" cellspacing="0">++ <tr>++ <td+ class="" style="vertical-align:top;width:600px;"+ >+ <![endif]-->++ <div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">++ <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">++ <tr>+ <td align="center" style="font-size: 0px; padding: 10px 25px; word-break: break-word;">++ <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:center;color:#000000;">{% blocktrans trimmed context "Base email footer" %}+ Sincerely, {{ site_name }}+ {% endblocktrans %}</div>++ </td>+ </tr>++ </table>++ </div>++ <!--[if mso | IE]>+ </td>++ </tr>++ </table>+ <![endif]-->+ </td>+ </tr>+ </tbody>+ </table>++ </div>+++ <!--[if mso | IE]>+ </td>+ </tr>+ </table>++ <table+ align="center" border="0" cellpadding="0" cellspacing="0" class="no-display-outlook" style="width:600px;" width="600"+ >+ <tr>+ <td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">+ <![endif]-->+++ <div class="no-display" style="display: none; margin: 0px auto; max-width: 600px;">++ <table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">+ <tbody>+ <tr>+ <td style="direction: ltr; font-size: 0px; padding: 20px 0; text-align: center;" align="center">+ <!--[if mso | IE]>+ <table role="presentation" border="0" cellpadding="0" cellspacing="0">++ <tr>++ <td+ class="" style="vertical-align:top;width:600px;"+ >+ <![endif]-->++ <div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">++ <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">++ <tr>+ <td align="left" style="font-size: 0px; padding: 10px 25px; word-break: break-word;">++ <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;">{% if schema_markup %}+ <script type="application/ld+json">{{ schema_markup|safe }}</script>+ {% endif %}</div>++ </td>+ </tr>++ </table>++ </div>++ <!--[if mso | IE]>+ </td>++ </tr>++ </table>+ <![endif]-->+ </td>+ </tr>+ </tbody>+ </table>++ </div>+++ <!--[if mso | IE]>+ </td>+ </tr>+ </table>+ <![endif]-->+++ </div>++ </body>+ </html>+diff --cc tests/test_emails.pyindex b460097ec6,1a57aae50d..1c9ca5cefc--- a/tests/test_emails.py+++ b/tests/test_emails.py@@@ -4,17 -4,11 +4,15 @@@ from urllib.parse import urlencodimport pytestfrom django.core import mailfrom django.core.exceptions import ImproperlyConfigured+from django.core.files import File- from django.templatetags.static import staticfrom templated_email import get_connectionimport saleor.account.emails as account_emails+import saleor.csv.emails as csv_emailsimport saleor.order.emails as emailsfrom saleor.core.emails import get_email_context, prepare_url- from saleor.core.utils import build_absolute_uri+from saleor.csv import ExportEvents+from saleor.csv.models import ExportEventfrom saleor.order.utils import add_variant_to_draft_order@@@ -363,48 -393,3 +397,46 @@@ def test_send_email_changed_notificatio# Render the email to ensure there is no erroremail_connection = get_connection()email_connection.get_email_message(to=recipients, **expected_call_kwargs)++[email protected]("saleor.csv.emails.send_templated_mail")+def test_send_email_with_link_to_download_csv(+ mocked_templated_email, site_settings, export_file, tmpdir+):+ from django.conf import settings++ settings.MEDIA_ROOT = tmpdir++ file_mock = mock.MagicMock(spec=File)+ file_mock.name = "temp_file.csv"++ export_file.content_file = file_mock+ export_file.save()++ csv_emails.send_email_with_link_to_download_csv(export_file, "export_products")+ template = csv_emails.EXPORT_TEMPLATES["export_products"]+ ctx = {+ "csv_link": f"http://mirumee.com/media/export_files/{file_mock.name}",+ "domain": "mirumee.com",- "logo_url": "http://mirumee.com/static/images/logo-light.svg",+ "site_name": "mirumee.com",+ }+ recipients = [export_file.created_by.email]+ expected_call_kwargs = {+ "context": ctx,+ "from_email": site_settings.default_from_email,+ "template_name": template,+ }+- # mocked_templated_email.assert_called_once()+ mocked_templated_email.assert_called_once_with(+ recipient_list=recipients, **expected_call_kwargs+ )++ # Render the email to ensure there is no error+ email_connection = get_connection()+ email_connection.get_email_message(to=recipients, **expected_call_kwargs)++ assert ExportEvent.objects.filter(+ export_file=export_file,+ user=export_file.created_by,+ type=ExportEvents.EXPORTED_FILE_SENT,+ )