Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Explicitly call gettext
Patryk Zawadzki4da6bc92b680
diff --git a/cart/__init__.py b/cart/__init__.pyindex 3fc22c6610..8eadb69ade 100755--- a/cart/__init__.py+++ b/cart/__init__.py@@ -1,5 +1,5 @@from django.conf import settings-from django.utils.translation import ugettext as _+from django.utils.translation import ugettextfrom satchless import cart@@ -16,16 +16,14 @@ class Cart(cart.Cart):SESSION_KEY = 'cart'def __unicode__(self):- return _('Cart (%(cart_count)s)' % {'cart_count': self.count()})+ return ugettext('Your cart (%(cart_count)s)') % {+ 'cart_count': self.count()}def check_quantity(self, product, quantity, data=None):if quantity > product.stock:raise InsufficientStockException(product)return super(Cart, self).check_quantity(product, quantity, data)- def get_default_currency(self):- return settings.SATCHLESS_DEFAULT_CURRENCY-def get_cart_from_request(request):try:diff --git a/cart/forms.py b/cart/forms.pyindex 3528f0b937..894214983d 100644--- a/cart/forms.py+++ b/cart/forms.py@@ -2,27 +2,28 @@ from . import InsufficientStockExceptionfrom decimal import Decimalfrom django import formsfrom django.forms.formsets import BaseFormSet-from django.utils.translation import pgettext as _, gettext as _g+from django.utils.translation import pgettext, ugettextclass QuantityField(forms.DecimalField):- pass+ def __init__(self, *args, **kwargs):+ return super(QuantityField, self).__init__(+ *args, max_value=None, min_value=Decimal(0), max_digits=10,+ decimal_places=4, initial=Decimal(1), **kwargs)class AddToCartForm(forms.Form):- quantity = QuantityField(_('Form field', 'quantity'), min_value=Decimal(0),- max_digits=10, decimal_places=4,- initial=Decimal(1))+ quantity = QuantityField(pgettext('Form field', 'quantity'))error_messages = {- 'insufficient-stock': _g('Only %(remaining)d remaining in stock.')}+ 'insufficient-stock': ugettext(+ 'Only %(remaining)d remaining in stock.')}def __init__(self, *args, **kwargs):self.cart = kwargs.pop('cart')self.product = kwargs.pop('product')self.cart_line = self.cart.get_line(self.product)-super(AddToCartForm, self).__init__(*args, **kwargs)def clean_quantity(self):@@ -63,16 +64,15 @@ class ReplaceCartLineFormSet(BaseFormSet):form = ReplaceCartLineFormextra = 0- can_order = False,+ can_order = Falsecan_delete = Falsemax_num = Nonedef __init__(self, *args, **kwargs):self.cart = kwargs.pop('cart')- kwargs['initial'] = [{'quantity':cart_line.get_quantity()}+ kwargs['initial'] = [{'quantity': cart_line.get_quantity()}for cart_line in self.cartif cart_line.get_quantity()]-super(ReplaceCartLineFormSet, self).__init__(*args, **kwargs)def _construct_form(self, i, **kwargs):diff --git a/order/models.py b/order/models.pyindex 0ed72cce12..b5085b2e49 100644--- a/order/models.py+++ b/order/models.py@@ -1,6 +1,6 @@from django.conf import settingsfrom django.db import models-from django.utils.translation import pgettext_lazy as _+from django.utils.translation import pgettext_lazyfrom django_prices.models import PriceFieldfrom prices import Pricefrom satchless.item import ItemSet, ItemLine@@ -29,72 +29,77 @@ class PaymentInfo(ItemLine):class Order(models.Model, ItemSet):STATUS_CHOICES = (- ('checkout', _('Order status field value', 'undergoing checkout')),- ('payment-pending', _('Order status field value',- 'waiting for payment')),- ('payment-complete', _('Order status field value', 'paid')),- ('payment-failed', _('Order status field value', 'payment failed')),- ('delivery', _('Order status field value', 'shipped')),- ('cancelled', _('Order status field value', 'cancelled')),- )-- status = models.CharField(_('Order field', 'order status'), max_length=32,- choices=STATUS_CHOICES, default='checkout')- created = models.DateTimeField(_('Order field', 'created'),- default=datetime.datetime.now,- editable=False, blank=True)- last_status_change = models.DateTimeField(_('Order field',- 'last status change'),- default=datetime.datetime.now,- editable=False, blank=True)- user = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True,- related_name='+', verbose_name=_('Order field',- 'user'))- billing_first_name = models.CharField(_('Order field billing',- 'first name'),- max_length=256, blank=True)- billing_last_name = models.CharField(_('Order field billing', 'last name'),- max_length=256, blank=True)- billing_company_name = models.CharField(_('Order field billing',- 'company name'),- max_length=256, blank=True)- billing_street_address_1 = models.CharField(_('Order field billing',- 'street address 1'),- max_length=256, blank=True)- billing_street_address_2 = models.CharField(_('Order field billing',- 'street address 2'),- max_length=256, blank=True)- billing_city = models.CharField(_('Order field billing', 'city'),- max_length=256, blank=True)- billing_postal_code = models.CharField(_('Order field billing',- 'postal code'),- max_length=20, blank=True)- billing_country = models.CharField(_('Order field billing', 'country'),- choices=countries.COUNTRY_CHOICES,- max_length=2, blank=True)- billing_country_area = models.CharField(_('Order field billing',- 'country administrative area'),- max_length=128, blank=True)- billing_tax_id = models.CharField(_('Order field billing', 'tax ID'),- max_length=40, blank=True)- billing_phone = models.CharField(_('Order field billing',- 'phone number'), max_length=30,- blank=True)- payment_type = models.CharField(_('Order field', 'payment type'),- max_length=256, blank=True)- payment_type_name = models.CharField(_('Order field', 'payment name'),- max_length=128, blank=True,- editable=False)- payment_type_description = models.TextField(_('Order field',- 'payment description'),- blank=True)- payment_price = PriceField(_('Order field', 'payment unit price'),- currency=settings.SATCHLESS_DEFAULT_CURRENCY,- max_digits=12, decimal_places=4, default=0,- editable=False)- token = models.CharField(_('Order field', 'token'), max_length=36,- blank=True, default='')-+ ('checkout', pgettext_lazy(+ 'Order status field value', 'undergoing checkout')),+ ('payment-pending', pgettext_lazy(+ 'Order status field value', 'waiting for payment')),+ ('payment-complete', pgettext_lazy(+ 'Order status field value', 'paid')),+ ('payment-failed', pgettext_lazy(+ 'Order status field value', 'payment failed')),+ ('delivery', pgettext_lazy('Order status field value', 'shipped')),+ ('cancelled', pgettext_lazy('Order status field value', 'cancelled')))++ status = models.CharField(+ pgettext_lazy('Order field', 'order status'),+ max_length=32, choices=STATUS_CHOICES, default='checkout')+ created = models.DateTimeField(+ pgettext_lazy('Order field', 'created'),+ default=datetime.datetime.now, editable=False, blank=True)+ last_status_change = models.DateTimeField(+ pgettext_lazy('Order field', 'last status change'),+ default=datetime.datetime.now, editable=False, blank=True)+ user = models.ForeignKey(+ settings.AUTH_USER_MODEL, blank=True, null=True, related_name='+',+ verbose_name=pgettext_lazy('Order field', 'user'))+ billing_first_name = models.CharField(+ pgettext_lazy('Order field billing', 'first name'),+ max_length=256, blank=True)+ billing_last_name = models.CharField(+ pgettext_lazy('Order field billing', 'last name'),+ max_length=256, blank=True)+ billing_company_name = models.CharField(+ pgettext_lazy('Order field billing', 'company name'),+ max_length=256, blank=True)+ billing_street_address_1 = models.CharField(+ pgettext_lazy('Order field billing', 'street address 1'),+ max_length=256, blank=True)+ billing_street_address_2 = models.CharField(+ pgettext_lazy('Order field billing', 'street address 2'),+ max_length=256, blank=True)+ billing_city = models.CharField(+ pgettext_lazy('Order field billing', 'city'),+ max_length=256, blank=True)+ billing_postal_code = models.CharField(+ pgettext_lazy('Order field billing', 'postal code'),+ max_length=20, blank=True)+ billing_country = models.CharField(+ pgettext_lazy('Order field billing', 'country'),+ choices=countries.COUNTRY_CHOICES, max_length=2, blank=True)+ billing_country_area = models.CharField(+ pgettext_lazy('Order field billing', 'country administrative area'),+ max_length=128, blank=True)+ billing_tax_id = models.CharField(+ pgettext_lazy('Order field billing', 'tax ID'),+ max_length=40, blank=True)+ billing_phone = models.CharField(+ pgettext_lazy('Order field billing', 'phone number'),+ max_length=30, blank=True)+ payment_type = models.CharField(+ pgettext_lazy('Order field', 'payment type'),+ max_length=256, blank=True)+ payment_type_name = models.CharField(+ pgettext_lazy('Order field', 'payment name'),+ max_length=128, blank=True, editable=False)+ payment_type_description = models.TextField(+ pgettext_lazy('Order field', 'payment description'), blank=True)+ payment_price = PriceField(+ pgettext_lazy('Order field', 'payment unit price'),+ currency=settings.SATCHLESS_DEFAULT_CURRENCY,+ max_digits=12, decimal_places=4, default=0, editable=False)+ token = models.CharField(+ pgettext_lazy('Order field', 'token'),+ max_length=36, blank=True, default='')class Meta:ordering = ('-last_status_change',)@@ -121,9 +126,6 @@ class Order(models.Model, ItemSet):def __unicode__(self):return self.token- def get_default_currency(self):- return settings.SATCHLESS_DEFAULT_CURRENCY-@propertydef billing_full_name(self):return u'%s %s' % (self.billing_first_name, self.billing_last_name)@@ -189,45 +191,47 @@ class DeliveryInfo(ItemLine):class DeliveryGroup(models.Model, ItemSet):order = models.ForeignKey('order', related_name='groups', editable=False)- delivery_price = PriceField(_('DeliveryGroup field', 'unit price'),- currency=settings.SATCHLESS_DEFAULT_CURRENCY,- max_digits=12, decimal_places=4,- default=0, editable=False)- delivery_type = models.CharField(_('DeliveryGroup field', 'type'),- max_length=256, blank=True)- delivery_type_name = models.CharField(_('DeliveryGroup field', 'name'),- max_length=128, blank=True,- editable=False)- delivery_type_description = models.TextField(_('DeliveryGroup field',- 'description'), blank=True,- editable=False)- require_shipping_address = models.BooleanField(default=False,- editable=False)- shipping_first_name = models.CharField(_('DeliveryGroup field',- 'first name'), max_length=256)- shipping_last_name = models.CharField(_('DeliveryGroup field',- 'last name'), max_length=256)- shipping_company_name = models.CharField(_('DeliveryGroup field',- 'company name'),- max_length=256, blank=True)- shipping_street_address_1 = models.CharField(_('DeliveryGroup field',- 'street address 1'),- max_length=256)- shipping_street_address_2 = models.CharField(_('DeliveryGroup field',- 'street address 2'),- max_length=256, blank=True)- shipping_city = models.CharField(_('DeliveryGroup field', 'city'),- max_length=256)- shipping_postal_code = models.CharField(_('DeliveryGroup field',- 'postal code'), max_length=20)- shipping_country = models.CharField(_('DeliveryGroup field', 'country'),- choices=countries.COUNTRY_CHOICES,- max_length=2, blank=True)- shipping_country_area = models.CharField(_('DeliveryGroup field',- 'country administrative area'),- max_length=128, blank=True)- shipping_phone = models.CharField(_('DeliveryGroup field', 'phone number'),- max_length=30, blank=True)+ delivery_price = PriceField(+ pgettext_lazy('DeliveryGroup field', 'unit price'),+ currency=settings.SATCHLESS_DEFAULT_CURRENCY, max_digits=12,+ decimal_places=4, default=0, editable=False)+ delivery_type = models.CharField(+ pgettext_lazy('DeliveryGroup field', 'type'),+ max_length=256, blank=True)+ delivery_type_name = models.CharField(+ pgettext_lazy('DeliveryGroup field', 'name'),+ max_length=128, blank=True, editable=False)+ delivery_type_description = models.TextField(+ pgettext_lazy('DeliveryGroup field', 'description'),+ blank=True, editable=False)+ require_shipping_address = models.BooleanField(+ default=False, editable=False)+ shipping_first_name = models.CharField(+ pgettext_lazy('DeliveryGroup field', 'first name'), max_length=256)+ shipping_last_name = models.CharField(+ pgettext_lazy('DeliveryGroup field', 'last name'), max_length=256)+ shipping_company_name = models.CharField(+ pgettext_lazy('DeliveryGroup field', 'company name'),+ max_length=256, blank=True)+ shipping_street_address_1 = models.CharField(+ pgettext_lazy('DeliveryGroup field', 'street address 1'),+ max_length=256)+ shipping_street_address_2 = models.CharField(+ pgettext_lazy('DeliveryGroup field', 'street address 2'),+ max_length=256, blank=True)+ shipping_city = models.CharField(+ pgettext_lazy('DeliveryGroup field', 'city'), max_length=256)+ shipping_postal_code = models.CharField(+ pgettext_lazy('DeliveryGroup field', 'postal code'), max_length=20)+ shipping_country = models.CharField(+ pgettext_lazy('DeliveryGroup field', 'country'),+ choices=countries.COUNTRY_CHOICES, max_length=2, blank=True)+ shipping_country_area = models.CharField(+ pgettext_lazy('DeliveryGroup field', 'country administrative area'),+ max_length=128, blank=True)+ shipping_phone = models.CharField(+ pgettext_lazy('DeliveryGroup field', 'phone number'),+ max_length=30, blank=True)def __iter__(self):for i in self.get_items():@@ -236,9 +240,6 @@ class DeliveryGroup(models.Model, ItemSet):if delivery:yield delivery- def get_default_currency(self):- return settings.SATCHLESS_DEFAULT_CURRENCY-def get_delivery(self):return DeliveryInfo(name=self.delivery_type_name,price=self.delivery_price,@@ -257,25 +258,23 @@ class DeliveryGroup(models.Model, ItemSet):class OrderedItem(models.Model, ItemLine):- delivery_group = models.ForeignKey(DeliveryGroup, related_name='items',- editable=False,- verbose_name=_('OrderedItem field',- 'delivery group'))- product = models.ForeignKey(Product, blank=True, null=True,- related_name='+',- on_delete=models.SET_NULL,- verbose_name=_('OrderedItem field',- 'product'))- product_name = models.CharField(_('OrderedItem field', 'product name'),- max_length=128)- quantity = models.DecimalField(_('OrderedItem field', 'quantity'),- max_digits=10, decimal_places=4)- unit_price_net = models.DecimalField(_('OrderedItem field',- 'unit price (net)'),- max_digits=12, decimal_places=4)- unit_price_gross = models.DecimalField(_('OrderedItem field',- 'unit price (gross)'),- max_digits=12, decimal_places=4)+ delivery_group = models.ForeignKey(+ DeliveryGroup, related_name='items', editable=False)+ product = models.ForeignKey(+ Product, blank=True, null=True, related_name='+',+ on_delete=models.SET_NULL,+ verbose_name=pgettext_lazy('OrderedItem field', 'product'))+ product_name = models.CharField(+ pgettext_lazy('OrderedItem field', 'product name'), max_length=128)+ quantity = models.DecimalField(+ pgettext_lazy('OrderedItem field', 'quantity'),+ max_digits=10, decimal_places=4)+ unit_price_net = models.DecimalField(+ pgettext_lazy('OrderedItem field', 'unit price (net)'),+ max_digits=12, decimal_places=4)+ unit_price_gross = models.DecimalField(+ pgettext_lazy('OrderedItem field', 'unit price (gross)'),+ max_digits=12, decimal_places=4)def get_price_per_item(self, **kwargs):return Price(net=self.unit_price_net, gross=self.unit_price_gross,diff --git a/product/models.py b/product/models.pyindex 20b201adeb..e450014af5 100644--- a/product/models.py+++ b/product/models.py@@ -3,7 +3,7 @@ from django.db import modelsfrom django.db.models.query import QuerySetfrom django.db.models.fields.related import SingleRelatedObjectDescriptorfrom django.utils.safestring import mark_safe-from django.utils.translation import pgettext_lazy as _+from django.utils.translation import pgettext_lazyfrom django_prices.models import PriceFieldfrom mptt.models import MPTTModelfrom satchless.item import Item@@ -81,14 +81,15 @@ class Subtyped(models.Model):class Category(MPTTModel):- name = models.CharField(_('Category field', 'name'), max_length=128)- slug = models.SlugField(_('Category field', 'slug'), max_length=50,- unique=True)- description = models.TextField(_('Category field', 'description'),- blank=True)- parent = models.ForeignKey('self', null=True, related_name='children',- blank=True,- verbose_name=_('Category field', 'parent'))+ name = models.CharField(+ pgettext_lazy('Category field', 'name'), max_length=128)+ slug = models.SlugField(+ pgettext_lazy('Category field', 'slug'), max_length=50, unique=True)+ description = models.TextField(+ pgettext_lazy('Category field', 'description'), blank=True)+ parent = models.ForeignKey(+ 'self', null=True, related_name='children', blank=True,+ verbose_name=pgettext_lazy('Category field', 'parent'))def __unicode__(self):return self.name@@ -96,14 +97,17 @@ class Category(MPTTModel):class Product(models.Model, Item):- name = models.CharField(_('Product field', 'name'), max_length=128)- price = PriceField(_('Product field', 'price'), currency='USD',- max_digits=12, decimal_places=4)- category = models.ForeignKey(Category, related_name='products',- verbose_name=_('Product field', 'category'))- stock = models.DecimalField(_('Product item field', 'stock'),- max_digits=10, decimal_places=4,- default=Decimal(1))+ name = models.CharField(+ pgettext_lazy('Product field', 'name'), max_length=128)+ price = PriceField(+ pgettext_lazy('Product field', 'price'),+ currency='USD', max_digits=12, decimal_places=4)+ category = models.ForeignKey(+ Category, related_name='products',+ verbose_name=pgettext_lazy('Product field', 'category'))+ stock = models.DecimalField(+ pgettext_lazy('Product item field', 'stock'),+ max_digits=10, decimal_places=4, default=Decimal(1))def __unicode__(self):return self.namediff --git a/saleor/countries.py b/saleor/countries.pyindex ec558c9375..bcd4f27e22 100644--- a/saleor/countries.py+++ b/saleor/countries.py@@ -1,263 +1,264 @@#coding: utf-8-from django.utils.translation import ugettext_lazy as _+from django.utils.translation import ugettext_lazyfrom django.utils.importlib import import_modulefrom django.conf import settingsDEFAULT_COUNTRY_CHOICES = (- ('AF', _(u'Afghanistan')),- ('AX', _(u'Åland Islands')),- ('AL', _(u'Albania')),- ('DZ', _(u'Algeria')),- ('AS', _(u'American Samoa')),- ('AD', _(u'Andorra')),- ('AO', _(u'Angola')),- ('AI', _(u'Anguilla')),- ('AQ', _(u'Antarctica')),- ('AG', _(u'Antigua And Barbuda')),- ('AR', _(u'Argentina')),- ('AM', _(u'Armenia')),- ('AW', _(u'Aruba')),- ('AU', _(u'Australia')),- ('AT', _(u'Austria')),- ('AZ', _(u'Azerbaijan')),- ('BS', _(u'Bahamas')),- ('BH', _(u'Bahrain')),- ('BD', _(u'Bangladesh')),- ('BB', _(u'Barbados')),- ('BY', _(u'Belarus')),- ('BE', _(u'Belgium')),- ('BZ', _(u'Belize')),- ('BJ', _(u'Benin')),- ('BM', _(u'Bermuda')),- ('BT', _(u'Bhutan')),- ('BO', _(u'Bolivia')),- ('BQ', _(u'Bonaire, Saint Eustatius And Saba')),- ('BA', _(u'Bosnia And Herzegovina')),- ('BW', _(u'Botswana')),- ('BV', _(u'Bouvet Island')),- ('BR', _(u'Brazil')),- ('IO', _(u'British Indian Ocean Territory')),- ('BN', _(u'Brunei Darussalam')),- ('BG', _(u'Bulgaria')),- ('BF', _(u'Burkina Faso')),- ('BI', _(u'Burundi')),- ('KH', _(u'Cambodia')),- ('CM', _(u'Cameroon')),- ('CA', _(u'Canada')),- ('CV', _(u'Cape Verde')),- ('KY', _(u'Cayman Islands')),- ('CF', _(u'Central African Republic')),- ('TD', _(u'Chad')),- ('CL', _(u'Chile')),- ('CN', _(u'China')),- ('CX', _(u'Christmas Island')),- ('CC', _(u'Cocos (Keeling) Islands')),- ('CO', _(u'Colombia')),- ('KM', _(u'Comoros')),- ('CG', _(u'Congo')),- ('CD', _(u'Congo, The Democratic Republic of the')),- ('CK', _(u'Cook Islands')),- ('CR', _(u'Costa Rica')),- ('CI', _(u'Côte D\'Ivoire')),- ('HR', _(u'Croatia')),- ('CU', _(u'Cuba')),- ('CW', _(u'Curaço')),- ('CY', _(u'Cyprus')),- ('CZ', _(u'Czech Republic')),- ('DK', _(u'Denmark')),- ('DJ', _(u'Djibouti')),- ('DM', _(u'Dominica')),- ('DO', _(u'Dominican Republic')),- ('EC', _(u'Ecuador')),- ('EG', _(u'Egypt')),- ('SV', _(u'El Salvador')),- ('GQ', _(u'Equatorial Guinea')),- ('ER', _(u'Eritrea')),- ('EE', _(u'Estonia')),- ('ET', _(u'Ethiopia')),- ('FK', _(u'Falkland Islands (Malvinas)')),- ('FO', _(u'Faroe Islands')),- ('FJ', _(u'Fiji')),- ('FI', _(u'Finland')),- ('FR', _(u'France')),- ('GF', _(u'French Guiana')),- ('PF', _(u'French Polynesia')),- ('TF', _(u'French Southern Territories')),- ('GA', _(u'Gabon')),- ('GM', _(u'Gambia')),- ('GE', _(u'Georgia')),- ('DE', _(u'Germany')),- ('GH', _(u'Ghana')),- ('GI', _(u'Gibraltar')),- ('GR', _(u'Greece')),- ('GL', _(u'Greenland')),- ('GD', _(u'Grenada')),- ('GP', _(u'Guadeloupe')),- ('GU', _(u'Guam')),- ('GT', _(u'Guatemala')),- ('GG', _(u'Guernsey')),- ('GN', _(u'Guinea')),- ('GW', _(u'Guinea-Bissau')),- ('GY', _(u'Guyana')),- ('HT', _(u'Haiti')),- ('HM', _(u'Heard Island And Mcdonald Islands')),- ('VA', _(u'Holy See (Vatican City State)')),- ('HN', _(u'Honduras')),- ('HK', _(u'Hong Kong')),- ('HU', _(u'Hungary')),- ('IS', _(u'Iceland')),- ('IN', _(u'India')),- ('ID', _(u'Indonesia')),- ('IR', _(u'Iran, Islamic Republic of')),- ('IQ', _(u'Iraq')),- ('IE', _(u'Ireland')),- ('IM', _(u'Isle of Man')),- ('IL', _(u'Israel')),- ('IT', _(u'Italy')),- ('JM', _(u'Jamaica')),- ('JP', _(u'Japan')),- ('JE', _(u'Jersey')),- ('JO', _(u'Jordan')),- ('KZ', _(u'Kazakhstan')),- ('KE', _(u'Kenya')),- ('KI', _(u'Kiribati')),- ('KP', _(u'Korea, Democratic People\'s Republic of')),- ('KR', _(u'Korea, Republic of')),- ('KW', _(u'Kuwait')),- ('KG', _(u'Kyrgyzstan')),- ('LA', _(u'Lao People\'s Democratic Republic')),- ('LV', _(u'Latvia')),- ('LB', _(u'Lebanon')),- ('LS', _(u'Lesotho')),- ('LR', _(u'Liberia')),- ('LY', _(u'Libya')),- ('LI', _(u'Liechtenstein')),- ('LT', _(u'Lithuania')),- ('LU', _(u'Luxembourg')),- ('MO', _(u'Macao')),- ('MK', _(u'Macedonia, The Former Yugoslav Republic of')),- ('MG', _(u'Madagascar')),- ('MW', _(u'Malawi')),- ('MY', _(u'Malaysia')),- ('MV', _(u'Maldives')),- ('ML', _(u'Mali')),- ('MT', _(u'Malta')),- ('MH', _(u'Marshall Islands')),- ('MQ', _(u'Martinique')),- ('MR', _(u'Mauritania')),- ('MU', _(u'Mauritius')),- ('YT', _(u'Mayotte')),- ('MX', _(u'Mexico')),- ('FM', _(u'Micronesia, Federated States of')),- ('MD', _(u'Moldova, Republic of')),- ('MC', _(u'Monaco')),- ('MN', _(u'Mongolia')),- ('ME', _(u'Montenegro')),- ('MS', _(u'Montserrat')),- ('MA', _(u'Morocco')),- ('MZ', _(u'Mozambique')),- ('MM', _(u'Myanmar')),- ('NA', _(u'Namibia')),- ('NR', _(u'Nauru')),- ('NP', _(u'Nepal')),- ('NL', _(u'Netherlands')),- ('NC', _(u'New Caledonia')),- ('NZ', _(u'New Zealand')),- ('NI', _(u'Nicaragua')),- ('NE', _(u'Niger')),- ('NG', _(u'Nigeria')),- ('NU', _(u'Niue')),- ('NF', _(u'Norfolk Island')),- ('MP', _(u'Northern Mariana Islands')),- ('NO', _(u'Norway')),- ('OM', _(u'Oman')),- ('PK', _(u'Pakistan')),- ('PW', _(u'Palau')),- ('PS', _(u'Palestinian Territory, Occupied')),- ('PA', _(u'Panama')),- ('PG', _(u'Papua New Guinea')),- ('PY', _(u'Paraguay')),- ('PE', _(u'Peru')),- ('PH', _(u'Philippines')),- ('PN', _(u'Pitcairn')),- ('PL', _(u'Poland')),- ('PT', _(u'Portugal')),- ('PR', _(u'Puerto Rico')),- ('QA', _(u'Qatar')),- ('RE', _(u'Réunion')),- ('RO', _(u'Romania')),- ('RU', _(u'Russian Federation')),- ('RW', _(u'Rwanda')),- ('BL', _(u'Saint Barthélemy')),- ('SH', _(u'Saint Helena, Ascension And Tristan Da Cunha')),- ('KN', _(u'Saint Kitts And Nevis')),- ('LC', _(u'Saint Lucia')),- ('MF', _(u'Saint Martin (French Part)')),- ('PM', _(u'Saint Pierre And Miquelon')),- ('VC', _(u'Saint Vincent And the Grenadines')),- ('WS', _(u'Samoa')),- ('SM', _(u'San Marino')),- ('ST', _(u'Sao Tome And Principe')),- ('SA', _(u'Saudi Arabia')),- ('SN', _(u'Senegal')),- ('RS', _(u'Serbia')),- ('SC', _(u'Seychelles')),- ('SL', _(u'Sierra Leone')),- ('SG', _(u'Singapore')),- ('SX', _(u'Sint Maarten (Dutch Part)')),- ('SK', _(u'Slovakia')),- ('SI', _(u'Slovenia')),- ('SB', _(u'Solomon Islands')),- ('SO', _(u'Somalia')),- ('ZA', _(u'South Africa')),- ('GS', _(u'South Georgia and the South Sandwich Islands')),- ('ES', _(u'Spain')),- ('LK', _(u'Sri Lanka')),- ('SD', _(u'Sudan')),- ('SR', _(u'Suriname')),- ('SJ', _(u'Svalbard and Jan Mayen')),- ('SZ', _(u'Swaziland')),- ('SE', _(u'Sweden')),- ('CH', _(u'Switzerland')),- ('SY', _(u'Syria')),- ('TW', _(u'Taiwan')),- ('TJ', _(u'Tajikistan')),- ('TZ', _(u'Tanzania')),- ('TH', _(u'Thailand')),- ('TL', _(u'Timor-Leste')),- ('TG', _(u'Togo')),- ('TK', _(u'Tokelau')),- ('TO', _(u'Tonga')),- ('TT', _(u'Trinidad And Tobago')),- ('TN', _(u'Tunisia')),- ('TR', _(u'Turkey')),- ('TM', _(u'Turkmenistan')),- ('TC', _(u'Turks And Caicos Islands')),- ('TV', _(u'Tuvalu')),- ('UG', _(u'Uganda')),- ('UA', _(u'Ukraine')),- ('AE', _(u'United Arab Emirates')),- ('GB', _(u'United Kingdom')),- ('US', _(u'United States')),- ('UM', _(u'United States Minor Outlying Islands')),- ('UY', _(u'Uruguay')),- ('UZ', _(u'Uzbekistan')),- ('VU', _(u'Vanuatu')),- ('VE', _(u'Venezuela')),- ('VN', _(u'Viet Nam')),- ('VG', _(u'Virgin Islands, British')),- ('VI', _(u'Virgin Islands, U.S.')),- ('WF', _(u'Wallis And Futuna')),- ('EH', _(u'Western Sahara')),- ('YE', _(u'Yemen')),- ('ZM', _(u'Zambia')),- ('ZW', _(u'Zimbabwe')),+ ('AF', ugettext_lazy(u'Afghanistan')),+ ('AX', ugettext_lazy(u'Åland Islands')),+ ('AL', ugettext_lazy(u'Albania')),+ ('DZ', ugettext_lazy(u'Algeria')),+ ('AS', ugettext_lazy(u'American Samoa')),+ ('AD', ugettext_lazy(u'Andorra')),+ ('AO', ugettext_lazy(u'Angola')),+ ('AI', ugettext_lazy(u'Anguilla')),+ ('AQ', ugettext_lazy(u'Antarctica')),+ ('AG', ugettext_lazy(u'Antigua And Barbuda')),+ ('AR', ugettext_lazy(u'Argentina')),+ ('AM', ugettext_lazy(u'Armenia')),+ ('AW', ugettext_lazy(u'Aruba')),+ ('AU', ugettext_lazy(u'Australia')),+ ('AT', ugettext_lazy(u'Austria')),+ ('AZ', ugettext_lazy(u'Azerbaijan')),+ ('BS', ugettext_lazy(u'Bahamas')),+ ('BH', ugettext_lazy(u'Bahrain')),+ ('BD', ugettext_lazy(u'Bangladesh')),+ ('BB', ugettext_lazy(u'Barbados')),+ ('BY', ugettext_lazy(u'Belarus')),+ ('BE', ugettext_lazy(u'Belgium')),+ ('BZ', ugettext_lazy(u'Belize')),+ ('BJ', ugettext_lazy(u'Benin')),+ ('BM', ugettext_lazy(u'Bermuda')),+ ('BT', ugettext_lazy(u'Bhutan')),+ ('BO', ugettext_lazy(u'Bolivia')),+ ('BQ', ugettext_lazy(u'Bonaire, Saint Eustatius And Saba')),+ ('BA', ugettext_lazy(u'Bosnia And Herzegovina')),+ ('BW', ugettext_lazy(u'Botswana')),+ ('BV', ugettext_lazy(u'Bouvet Island')),+ ('BR', ugettext_lazy(u'Brazil')),+ ('IO', ugettext_lazy(u'British Indian Ocean Territory')),+ ('BN', ugettext_lazy(u'Brunei Darussalam')),+ ('BG', ugettext_lazy(u'Bulgaria')),+ ('BF', ugettext_lazy(u'Burkina Faso')),+ ('BI', ugettext_lazy(u'Burundi')),+ ('KH', ugettext_lazy(u'Cambodia')),+ ('CM', ugettext_lazy(u'Cameroon')),+ ('CA', ugettext_lazy(u'Canada')),+ ('CV', ugettext_lazy(u'Cape Verde')),+ ('KY', ugettext_lazy(u'Cayman Islands')),+ ('CF', ugettext_lazy(u'Central African Republic')),+ ('TD', ugettext_lazy(u'Chad')),+ ('CL', ugettext_lazy(u'Chile')),+ ('CN', ugettext_lazy(u'China')),+ ('CX', ugettext_lazy(u'Christmas Island')),+ ('CC', ugettext_lazy(u'Cocos (Keeling) Islands')),+ ('CO', ugettext_lazy(u'Colombia')),+ ('KM', ugettext_lazy(u'Comoros')),+ ('CG', ugettext_lazy(u'Congo')),+ ('CD', ugettext_lazy(u'Congo, The Democratic Republic of the')),+ ('CK', ugettext_lazy(u'Cook Islands')),+ ('CR', ugettext_lazy(u'Costa Rica')),+ ('CI', ugettext_lazy(u'Côte D\'Ivoire')),+ ('HR', ugettext_lazy(u'Croatia')),+ ('CU', ugettext_lazy(u'Cuba')),+ ('CW', ugettext_lazy(u'Curaço')),+ ('CY', ugettext_lazy(u'Cyprus')),+ ('CZ', ugettext_lazy(u'Czech Republic')),+ ('DK', ugettext_lazy(u'Denmark')),+ ('DJ', ugettext_lazy(u'Djibouti')),+ ('DM', ugettext_lazy(u'Dominica')),+ ('DO', ugettext_lazy(u'Dominican Republic')),+ ('EC', ugettext_lazy(u'Ecuador')),+ ('EG', ugettext_lazy(u'Egypt')),+ ('SV', ugettext_lazy(u'El Salvador')),+ ('GQ', ugettext_lazy(u'Equatorial Guinea')),+ ('ER', ugettext_lazy(u'Eritrea')),+ ('EE', ugettext_lazy(u'Estonia')),+ ('ET', ugettext_lazy(u'Ethiopia')),+ ('FK', ugettext_lazy(u'Falkland Islands (Malvinas)')),+ ('FO', ugettext_lazy(u'Faroe Islands')),+ ('FJ', ugettext_lazy(u'Fiji')),+ ('FI', ugettext_lazy(u'Finland')),+ ('FR', ugettext_lazy(u'France')),+ ('GF', ugettext_lazy(u'French Guiana')),+ ('PF', ugettext_lazy(u'French Polynesia')),+ ('TF', ugettext_lazy(u'French Southern Territories')),+ ('GA', ugettext_lazy(u'Gabon')),+ ('GM', ugettext_lazy(u'Gambia')),+ ('GE', ugettext_lazy(u'Georgia')),+ ('DE', ugettext_lazy(u'Germany')),+ ('GH', ugettext_lazy(u'Ghana')),+ ('GI', ugettext_lazy(u'Gibraltar')),+ ('GR', ugettext_lazy(u'Greece')),+ ('GL', ugettext_lazy(u'Greenland')),+ ('GD', ugettext_lazy(u'Grenada')),+ ('GP', ugettext_lazy(u'Guadeloupe')),+ ('GU', ugettext_lazy(u'Guam')),+ ('GT', ugettext_lazy(u'Guatemala')),+ ('GG', ugettext_lazy(u'Guernsey')),+ ('GN', ugettext_lazy(u'Guinea')),+ ('GW', ugettext_lazy(u'Guinea-Bissau')),+ ('GY', ugettext_lazy(u'Guyana')),+ ('HT', ugettext_lazy(u'Haiti')),+ ('HM', ugettext_lazy(u'Heard Island And Mcdonald Islands')),+ ('VA', ugettext_lazy(u'Holy See (Vatican City State)')),+ ('HN', ugettext_lazy(u'Honduras')),+ ('HK', ugettext_lazy(u'Hong Kong')),+ ('HU', ugettext_lazy(u'Hungary')),+ ('IS', ugettext_lazy(u'Iceland')),+ ('IN', ugettext_lazy(u'India')),+ ('ID', ugettext_lazy(u'Indonesia')),+ ('IR', ugettext_lazy(u'Iran, Islamic Republic of')),+ ('IQ', ugettext_lazy(u'Iraq')),+ ('IE', ugettext_lazy(u'Ireland')),+ ('IM', ugettext_lazy(u'Isle of Man')),+ ('IL', ugettext_lazy(u'Israel')),+ ('IT', ugettext_lazy(u'Italy')),+ ('JM', ugettext_lazy(u'Jamaica')),+ ('JP', ugettext_lazy(u'Japan')),+ ('JE', ugettext_lazy(u'Jersey')),+ ('JO', ugettext_lazy(u'Jordan')),+ ('KZ', ugettext_lazy(u'Kazakhstan')),+ ('KE', ugettext_lazy(u'Kenya')),+ ('KI', ugettext_lazy(u'Kiribati')),+ ('KP', ugettext_lazy(u'Korea, Democratic People\'s Republic of')),+ ('KR', ugettext_lazy(u'Korea, Republic of')),+ ('KW', ugettext_lazy(u'Kuwait')),+ ('KG', ugettext_lazy(u'Kyrgyzstan')),+ ('LA', ugettext_lazy(u'Lao People\'s Democratic Republic')),+ ('LV', ugettext_lazy(u'Latvia')),+ ('LB', ugettext_lazy(u'Lebanon')),+ ('LS', ugettext_lazy(u'Lesotho')),+ ('LR', ugettext_lazy(u'Liberia')),+ ('LY', ugettext_lazy(u'Libya')),+ ('LI', ugettext_lazy(u'Liechtenstein')),+ ('LT', ugettext_lazy(u'Lithuania')),+ ('LU', ugettext_lazy(u'Luxembourg')),+ ('MO', ugettext_lazy(u'Macao')),+ ('MK', ugettext_lazy(u'Macedonia, The Former Yugoslav Republic of')),+ ('MG', ugettext_lazy(u'Madagascar')),+ ('MW', ugettext_lazy(u'Malawi')),+ ('MY', ugettext_lazy(u'Malaysia')),+ ('MV', ugettext_lazy(u'Maldives')),+ ('ML', ugettext_lazy(u'Mali')),+ ('MT', ugettext_lazy(u'Malta')),+ ('MH', ugettext_lazy(u'Marshall Islands')),+ ('MQ', ugettext_lazy(u'Martinique')),+ ('MR', ugettext_lazy(u'Mauritania')),+ ('MU', ugettext_lazy(u'Mauritius')),+ ('YT', ugettext_lazy(u'Mayotte')),+ ('MX', ugettext_lazy(u'Mexico')),+ ('FM', ugettext_lazy(u'Micronesia, Federated States of')),+ ('MD', ugettext_lazy(u'Moldova, Republic of')),+ ('MC', ugettext_lazy(u'Monaco')),+ ('MN', ugettext_lazy(u'Mongolia')),+ ('ME', ugettext_lazy(u'Montenegro')),+ ('MS', ugettext_lazy(u'Montserrat')),+ ('MA', ugettext_lazy(u'Morocco')),+ ('MZ', ugettext_lazy(u'Mozambique')),+ ('MM', ugettext_lazy(u'Myanmar')),+ ('NA', ugettext_lazy(u'Namibia')),+ ('NR', ugettext_lazy(u'Nauru')),+ ('NP', ugettext_lazy(u'Nepal')),+ ('NL', ugettext_lazy(u'Netherlands')),+ ('NC', ugettext_lazy(u'New Caledonia')),+ ('NZ', ugettext_lazy(u'New Zealand')),+ ('NI', ugettext_lazy(u'Nicaragua')),+ ('NE', ugettext_lazy(u'Niger')),+ ('NG', ugettext_lazy(u'Nigeria')),+ ('NU', ugettext_lazy(u'Niue')),+ ('NF', ugettext_lazy(u'Norfolk Island')),+ ('MP', ugettext_lazy(u'Northern Mariana Islands')),+ ('NO', ugettext_lazy(u'Norway')),+ ('OM', ugettext_lazy(u'Oman')),+ ('PK', ugettext_lazy(u'Pakistan')),+ ('PW', ugettext_lazy(u'Palau')),+ ('PS', ugettext_lazy(u'Palestinian Territory, Occupied')),+ ('PA', ugettext_lazy(u'Panama')),+ ('PG', ugettext_lazy(u'Papua New Guinea')),+ ('PY', ugettext_lazy(u'Paraguay')),+ ('PE', ugettext_lazy(u'Peru')),+ ('PH', ugettext_lazy(u'Philippines')),+ ('PN', ugettext_lazy(u'Pitcairn')),+ ('PL', ugettext_lazy(u'Poland')),+ ('PT', ugettext_lazy(u'Portugal')),+ ('PR', ugettext_lazy(u'Puerto Rico')),+ ('QA', ugettext_lazy(u'Qatar')),+ ('RE', ugettext_lazy(u'Réunion')),+ ('RO', ugettext_lazy(u'Romania')),+ ('RU', ugettext_lazy(u'Russian Federation')),+ ('RW', ugettext_lazy(u'Rwanda')),+ ('BL', ugettext_lazy(u'Saint Barthélemy')),+ ('SH', ugettext_lazy(u'Saint Helena, Ascension And Tristan Da Cunha')),+ ('KN', ugettext_lazy(u'Saint Kitts And Nevis')),+ ('LC', ugettext_lazy(u'Saint Lucia')),+ ('MF', ugettext_lazy(u'Saint Martin (French Part)')),+ ('PM', ugettext_lazy(u'Saint Pierre And Miquelon')),+ ('VC', ugettext_lazy(u'Saint Vincent And the Grenadines')),+ ('WS', ugettext_lazy(u'Samoa')),+ ('SM', ugettext_lazy(u'San Marino')),+ ('ST', ugettext_lazy(u'Sao Tome And Principe')),+ ('SA', ugettext_lazy(u'Saudi Arabia')),+ ('SN', ugettext_lazy(u'Senegal')),+ ('RS', ugettext_lazy(u'Serbia')),+ ('SC', ugettext_lazy(u'Seychelles')),+ ('SL', ugettext_lazy(u'Sierra Leone')),+ ('SG', ugettext_lazy(u'Singapore')),+ ('SX', ugettext_lazy(u'Sint Maarten (Dutch Part)')),+ ('SK', ugettext_lazy(u'Slovakia')),+ ('SI', ugettext_lazy(u'Slovenia')),+ ('SB', ugettext_lazy(u'Solomon Islands')),+ ('SO', ugettext_lazy(u'Somalia')),+ ('ZA', ugettext_lazy(u'South Africa')),+ ('GS', ugettext_lazy(u'South Georgia and the South Sandwich Islands')),+ ('ES', ugettext_lazy(u'Spain')),+ ('LK', ugettext_lazy(u'Sri Lanka')),+ ('SD', ugettext_lazy(u'Sudan')),+ ('SR', ugettext_lazy(u'Suriname')),+ ('SJ', ugettext_lazy(u'Svalbard and Jan Mayen')),+ ('SZ', ugettext_lazy(u'Swaziland')),+ ('SE', ugettext_lazy(u'Sweden')),+ ('CH', ugettext_lazy(u'Switzerland')),+ ('SY', ugettext_lazy(u'Syria')),+ ('TW', ugettext_lazy(u'Taiwan')),+ ('TJ', ugettext_lazy(u'Tajikistan')),+ ('TZ', ugettext_lazy(u'Tanzania')),+ ('TH', ugettext_lazy(u'Thailand')),+ ('TL', ugettext_lazy(u'Timor-Leste')),+ ('TG', ugettext_lazy(u'Togo')),+ ('TK', ugettext_lazy(u'Tokelau')),+ ('TO', ugettext_lazy(u'Tonga')),+ ('TT', ugettext_lazy(u'Trinidad And Tobago')),+ ('TN', ugettext_lazy(u'Tunisia')),+ ('TR', ugettext_lazy(u'Turkey')),+ ('TM', ugettext_lazy(u'Turkmenistan')),+ ('TC', ugettext_lazy(u'Turks And Caicos Islands')),+ ('TV', ugettext_lazy(u'Tuvalu')),+ ('UG', ugettext_lazy(u'Uganda')),+ ('UA', ugettext_lazy(u'Ukraine')),+ ('AE', ugettext_lazy(u'United Arab Emirates')),+ ('GB', ugettext_lazy(u'United Kingdom')),+ ('US', ugettext_lazy(u'United States')),+ ('UM', ugettext_lazy(u'United States Minor Outlying Islands')),+ ('UY', ugettext_lazy(u'Uruguay')),+ ('UZ', ugettext_lazy(u'Uzbekistan')),+ ('VU', ugettext_lazy(u'Vanuatu')),+ ('VE', ugettext_lazy(u'Venezuela')),+ ('VN', ugettext_lazy(u'Viet Nam')),+ ('VG', ugettext_lazy(u'Virgin Islands, British')),+ ('VI', ugettext_lazy(u'Virgin Islands, U.S.')),+ ('WF', ugettext_lazy(u'Wallis And Futuna')),+ ('EH', ugettext_lazy(u'Western Sahara')),+ ('YE', ugettext_lazy(u'Yemen')),+ ('ZM', ugettext_lazy(u'Zambia')),+ ('ZW', ugettext_lazy(u'Zimbabwe')),)+def build_country_choices():- country_list = getattr(settings, 'SATCHLESS_COUNTRY_CHOICES',- DEFAULT_COUNTRY_CHOICES)+ country_list = getattr(+ settings, 'SATCHLESS_COUNTRY_CHOICES', DEFAULT_COUNTRY_CHOICES)if isinstance(country_list, str):mod_name, han_name = country_list.rsplit('.', 1)module = import_module(mod_name)diff --git a/userprofile/models.py b/userprofile/models.pyindex eaae50bbce..77a66b220b 100644--- a/userprofile/models.py+++ b/userprofile/models.py@@ -2,33 +2,36 @@ from django.contrib.auth.hashers import (check_password, make_password,is_password_usable)from django.contrib.auth.models import BaseUserManagerfrom django.db import models-from django.utils.translation import ugettext_lazy as _+from django.utils.translation import ugettext_lazyfrom django.utils import timezonefrom saleor.countries import COUNTRY_CHOICESclass Address(models.Model):user = models.ForeignKey('User', related_name='addressbook')- alias = models.CharField(_('short alias'), max_length=30,- default=_('Home'),- help_text=_('User-defined alias which identifies this address'))- first_name = models.CharField(_('first name'),- max_length=256, blank=True)- last_name = models.CharField(_('last name'),- max_length=256, blank=True)- company_name = models.CharField(_('company name'), max_length=256,- blank=True)- street_address_1 = models.CharField(_('street address 1'), max_length=256)- street_address_2 = models.CharField(_('street address 2'), max_length=256,- blank=True)- city = models.CharField(_('city'), max_length=256)- postal_code = models.CharField(_('postal code'), max_length=20)- country = models.CharField(_('country'), choices=COUNTRY_CHOICES,- max_length=2)- country_area = models.CharField(_('country administrative area'),- max_length=128)- phone = models.CharField(_('phone number'), max_length=30, blank=True)-+ alias = models.CharField(+ ugettext_lazy('short alias'),+ max_length=30, default=ugettext_lazy('Home'),+ help_text=ugettext_lazy(+ 'User-defined alias which identifies this address'))+ first_name = models.CharField(+ ugettext_lazy('first name'), max_length=256, blank=True)+ last_name = models.CharField(+ ugettext_lazy('last name'), max_length=256, blank=True)+ company_name = models.CharField(+ ugettext_lazy('company name'), max_length=256, blank=True)+ street_address_1 = models.CharField(+ ugettext_lazy('street address 1'), max_length=256)+ street_address_2 = models.CharField(+ ugettext_lazy('street address 2'), max_length=256, blank=True)+ city = models.CharField(ugettext_lazy('city'), max_length=256)+ postal_code = models.CharField(ugettext_lazy('postal code'), max_length=20)+ country = models.CharField(+ ugettext_lazy('country'), choices=COUNTRY_CHOICES, max_length=2)+ country_area = models.CharField(+ ugettext_lazy('country administrative area'), max_length=128)+ phone = models.CharField(+ ugettext_lazy('phone number'), max_length=30, blank=True)class Meta:unique_together = ('user', 'alias')@@ -60,17 +63,19 @@ class UserManager(BaseUserManager):class User(models.Model):email = models.EmailField(unique=True)- is_staff = models.BooleanField(_('staff status'), default=False)- is_active = models.BooleanField(_('active'), default=False)- password = models.CharField(_('password'), max_length=128, editable=False)- date_joined = models.DateTimeField(_('date joined'), default=timezone.now,- editable=False)- last_login = models.DateTimeField(_('last login'), default=timezone.now,- editable=False)- default_shipping_address = models.ForeignKey(Address, related_name='+',- null=True, blank=True)- default_billing_address = models.ForeignKey(Address, related_name='+',- null=True, blank=True)+ is_staff = models.BooleanField(+ ugettext_lazy('staff status'), default=False)+ is_active = models.BooleanField(ugettext_lazy('active'), default=False)+ password = models.CharField(+ ugettext_lazy('password'), max_length=128, editable=False)+ date_joined = models.DateTimeField(+ ugettext_lazy('date joined'), default=timezone.now, editable=False)+ last_login = models.DateTimeField(+ ugettext_lazy('last login'), default=timezone.now, editable=False)+ default_shipping_address = models.ForeignKey(+ Address, related_name='+', null=True, blank=True)+ default_billing_address = models.ForeignKey(+ Address, related_name='+', null=True, blank=True)USERNAME_FIELD = 'email'