Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Improve contextual markers for shipping app
Marco Badanceba53cfaee9
diff --git a/saleor/shipping/models.py b/saleor/shipping/models.pyindex 6b713cfbf1..ac05c147da 100644--- a/saleor/shipping/models.py+++ b/saleor/shipping/models.py@@ -6,22 +6,30 @@ from django.conf import settingsfrom django.db import modelsfrom django.db.models import Qfrom django.utils.encoding import python_2_unicode_compatible-from django.utils.translation import pgettext_lazy, gettext as _+from django.utils.translation import pgettext_lazyfrom django_prices.models import PriceFieldfrom prices import PriceRangefrom django_countries import countriesANY_COUNTRY = ''-ANY_COUNTRY_DISPLAY = _('Rest of World')+ANY_COUNTRY_DISPLAY = pgettext_lazy('Country choice', 'Rest of World')COUNTRY_CODE_CHOICES = [(ANY_COUNTRY, ANY_COUNTRY_DISPLAY)] + list(countries)@python_2_unicode_compatibleclass ShippingMethod(models.Model):- name = models.CharField(max_length=100)- description = models.TextField(blank=True, default='')+ name = models.CharField(+ pgettext_lazy('Shipping method field', 'name'),+ max_length=100)+ description = models.TextField(+ pgettext_lazy('Shipping method field', 'description'),+ blank=True, default='')++ class Meta:+ verbose_name = pgettext_lazy('Shipping method model', 'shipping method')+ verbose_name_plural = pgettext_lazy('Shipping method model', 'shipping methods')def __str__(self):return self.name@@ -65,20 +73,27 @@ class ShippingMethodCountryQueryset(models.QuerySet):class ShippingMethodCountry(models.Model):country_code = models.CharField(+ pgettext_lazy('Shipping method country field', 'country code'),choices=COUNTRY_CODE_CHOICES, max_length=2, blank=True, default=ANY_COUNTRY)price = PriceField(- pgettext_lazy('Shipping method region field', 'price'),+ pgettext_lazy('Shipping method country field', 'price'),currency=settings.DEFAULT_CURRENCY, max_digits=12, decimal_places=2)- shipping_method = models.ForeignKey(ShippingMethod, related_name='price_per_country')+ shipping_method = models.ForeignKey(+ ShippingMethod, related_name='price_per_country',+ verbose_name=pgettext_lazy('Shipping method country field', 'shipping method'),)objects = ShippingMethodCountryQueryset.as_manager()class Meta:unique_together = ('country_code', 'shipping_method')+ verbose_name = pgettext_lazy(+ 'Shipping method country model', 'shipping method country')+ verbose_name_plural = pgettext_lazy(+ 'Shipping method country model', 'shipping method countries')def __str__(self):# https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.get_FOO_display # noqa- return "%s %s" % (self.shipping_method, self.get_country_code_display())+ return '%s %s' % (self.shipping_method, self.get_country_code_display())def get_total(self):return self.pricediff --git a/saleor/shipping/utils.py b/saleor/shipping/utils.pyindex 45e0146ead..e6cc4fde0b 100644--- a/saleor/shipping/utils.py+++ b/saleor/shipping/utils.py@@ -1,4 +1,3 @@-from django.db.models import Qfrom .models import ShippingMethodCountry