Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Improve contextual markers for checkout app
Marco Badana6a03c216c51
diff --git a/saleor/checkout/forms.py b/saleor/checkout/forms.pyindex 9d8b1ea963..9a7491b3d9 100644--- a/saleor/checkout/forms.py+++ b/saleor/checkout/forms.py@@ -1,6 +1,6 @@from django import formsfrom django.utils.safestring import mark_safe-from django.utils.translation import ugettext_lazy as _+from django.utils.translation import pgettext_lazyfrom django_prices.templatetags.prices_i18n import format_pricefrom ..shipping.models import ShippingMethodCountry@@ -15,10 +15,13 @@ class ShippingAddressesForm(forms.Form):NEW_ADDRESS = 'new_address'CHOICES = (- (NEW_ADDRESS, _('Enter a new address')),+ (NEW_ADDRESS, pgettext_lazy(+ 'Shipping addresses form choice', 'Enter a new address')),)- address = CheckoutAddressField(choices=CHOICES, initial=NEW_ADDRESS)+ address = CheckoutAddressField(+ label=pgettext_lazy('Shipping addresses form field label', 'Address'),+ choices=CHOICES, initial=NEW_ADDRESS)def __init__(self, *args, **kwargs):additional_addresses = kwargs.pop('additional_addresses', [])@@ -34,8 +37,10 @@ class BillingAddressesForm(ShippingAddressesForm):NEW_ADDRESS = 'new_address'SHIPPING_ADDRESS = 'shipping_address'CHOICES = (- (NEW_ADDRESS, _('Enter a new address')),- (SHIPPING_ADDRESS, _('Same as shipping'))+ (NEW_ADDRESS, pgettext_lazy(+ 'Billing addresses form choice', 'Enter a new address')),+ (SHIPPING_ADDRESS, pgettext_lazy(+ 'Billing addresses form choice', 'Same as shipping')))address = CheckoutAddressField(choices=CHOICES, initial=SHIPPING_ADDRESS)@@ -61,7 +66,8 @@ class ShippingMethodForm(forms.Form):method = ShippingCountryChoiceField(queryset=ShippingMethodCountry.objects.select_related('shipping_method').order_by('price').all(),- label=_('Shipping method'), required=True)+ label=pgettext_lazy('Shipping method form field label', 'Shipping method'),+ required=True)def __init__(self, country_code, *args, **kwargs):super(ShippingMethodForm, self).__init__(*args, **kwargs)@@ -77,10 +83,12 @@ class ShippingMethodForm(forms.Form):class AnonymousUserShippingForm(forms.Form):email = forms.EmailField(- required=True, widget=forms.EmailInput(attrs={'autocomplete': 'shipping email'}))+ required=True, widget=forms.EmailInput(attrs={'autocomplete': 'shipping email'}),+ label=pgettext_lazy('Shipping form field label', 'Email'))class AnonymousUserBillingForm(forms.Form):email = forms.EmailField(- required=True, widget=forms.EmailInput(attrs={'autocomplete': 'billing email'}))+ required=True, widget=forms.EmailInput(attrs={'autocomplete': 'billing email'}),+ label=pgettext_lazy('Billing form field label', 'Email'))diff --git a/saleor/checkout/views/discount.py b/saleor/checkout/views/discount.pyindex 2646350265..960f906cf6 100644--- a/saleor/checkout/views/discount.py+++ b/saleor/checkout/views/discount.py@@ -50,7 +50,7 @@ def validate_voucher(view):del checkout.voucher_codecheckout.recalculate_discount()msg = pgettext(- 'checkout warning',+ 'Checkout warning','This voucher has expired. Please review your checkout.')messages.warning(request, msg)return redirect('checkout:summary')diff --git a/saleor/checkout/views/summary.py b/saleor/checkout/views/summary.pyindex 217014a8f1..3571a87ad4 100644--- a/saleor/checkout/views/summary.py+++ b/saleor/checkout/views/summary.py@@ -1,6 +1,7 @@from django.contrib import messagesfrom django.shortcuts import redirectfrom django.template.response import TemplateResponse+from django.utils.translation import pgettextfrom ..forms import (AnonymousUserBillingForm, BillingAddressesForm,@@ -23,7 +24,8 @@ def create_order(checkout):def handle_order_placement(request, checkout):order, success_redirect = create_order(checkout)if not order:- messages.warning(request, 'Please review your checkout.')+ msg = pgettext('Checkout warning', 'Please review your checkout.')+ messages.warning(request, msg)return success_redirect