Fixed price localiztion for receipts
This commit is contained in:
Родитель
d3d9abc2e4
Коммит
a6393aaf71
|
@ -26,9 +26,9 @@ from django.core import paginator
|
|||
from django.core.cache import cache
|
||||
from django.core.files.storage import (FileSystemStorage,
|
||||
default_storage as storage)
|
||||
from django.core.serializers import json
|
||||
from django.core.validators import ValidationError, validate_slug
|
||||
from django.core.mail import EmailMessage, EmailMultiAlternatives
|
||||
from django.core.serializers import json
|
||||
from django.core.validators import validate_slug, ValidationError
|
||||
from django.forms.fields import Field
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context, loader
|
||||
|
@ -38,14 +38,14 @@ from django.utils.functional import Promise
|
|||
from django.utils.http import urlquote
|
||||
|
||||
import bleach
|
||||
from cef import log_cef as _log_cef
|
||||
from django_statsd.clients import statsd
|
||||
import elasticutils.contrib.django as elasticutils
|
||||
import html5lib
|
||||
import jinja2
|
||||
import pyes.exceptions as pyes
|
||||
import pytz
|
||||
from babel import Locale
|
||||
from cef import log_cef as _log_cef
|
||||
from django_statsd.clients import statsd
|
||||
from easy_thumbnails import processors
|
||||
from html5lib.serializer.htmlserializer import HTMLSerializer
|
||||
from jingo import env
|
||||
|
@ -240,7 +240,8 @@ def send_mail(subject, message, from_email=None, recipient_list=None,
|
|||
'perm_setting': perm_setting.label,
|
||||
'SITE_URL': settings.SITE_URL,
|
||||
'mandatory': perm_setting.mandatory,
|
||||
# Hide "Unsubscribe" links in Marketplace emails (bug 802379).
|
||||
# Hide "Unsubscribe" links in Marketplace emails
|
||||
# (bug 802379).
|
||||
'show_unsubscribe': not settings.MARKETPLACE
|
||||
}
|
||||
# Render this template in the default locale until
|
||||
|
@ -591,7 +592,7 @@ def get_locale_from_lang(lang):
|
|||
"""Pass in a language (u'en-US') get back a Locale object courtesy of
|
||||
Babel. Use this to figure out currencies, bidi, names, etc."""
|
||||
# Special fake language can just act like English for formatting and such
|
||||
if lang == 'dbg':
|
||||
if not lang or lang == 'dbg':
|
||||
lang = 'en'
|
||||
return Locale(translation.to_locale(lang))
|
||||
|
||||
|
|
|
@ -5,18 +5,18 @@ from django.db import models
|
|||
from django.template import Context, loader
|
||||
from django.utils import translation
|
||||
|
||||
from babel import Locale, numbers
|
||||
import caching.base
|
||||
import tower
|
||||
from babel import Locale, numbers
|
||||
from jingo import env
|
||||
from jinja2.filters import do_dictsort
|
||||
import tower
|
||||
from tower import ugettext as _
|
||||
|
||||
import amo
|
||||
from amo.helpers import absolutify, urlparams
|
||||
from amo.models import SearchMixin
|
||||
from amo.fields import DecimalCharField
|
||||
from amo.utils import send_mail, send_mail_jinja
|
||||
from amo.utils import get_locale_from_lang, send_mail, send_mail_jinja
|
||||
from zadmin.models import DownloadSource
|
||||
|
||||
from .db import StatsDictField
|
||||
|
@ -355,7 +355,7 @@ class Contribution(amo.models.ModelBase):
|
|||
"""Localise the amount paid into the current locale."""
|
||||
if not locale:
|
||||
lang = translation.get_language()
|
||||
locale = Locale(translation.to_locale(lang))
|
||||
locale = get_locale_from_lang(lang)
|
||||
return numbers.format_currency(self.amount or 0,
|
||||
self.currency or 'USD',
|
||||
locale=locale)
|
||||
|
|
|
@ -73,7 +73,8 @@ class TestReceiptEmail(PurchaseTest):
|
|||
amount=self.price.price,
|
||||
uuid=str(uuid.uuid4()),
|
||||
type=amo.CONTRIB_PURCHASE,
|
||||
user=self.user)
|
||||
user=self.user,
|
||||
source_locale='en-us')
|
||||
|
||||
def test_send(self):
|
||||
tasks.send_purchase_receipt(self.contrib.pk)
|
||||
|
@ -97,6 +98,5 @@ class TestReceiptEmail(PurchaseTest):
|
|||
eq_(args[1]['recipient_list'], [self.user.email])
|
||||
eq_(data['app_name'], self.addon.name)
|
||||
eq_(data['developer_name'], self.addon.current_version.developer_name)
|
||||
eq_(data['price'],
|
||||
self.contrib.get_amount_locale(self.contrib.source_locale))
|
||||
eq_(data['price'], self.contrib.get_amount_locale('en_US'))
|
||||
ok_(data['purchases_url'].startswith('http://f.com'))
|
||||
|
|
|
@ -8,7 +8,7 @@ import amo
|
|||
from amo.decorators import write
|
||||
from amo.helpers import absolutify
|
||||
from amo.urlresolvers import reverse
|
||||
from amo.utils import send_html_mail_jinja
|
||||
from amo.utils import get_locale_from_lang, send_html_mail_jinja
|
||||
from mkt.inapp_pay.models import InappConfig
|
||||
from mkt.inapp_pay.utils import send_pay_notice
|
||||
from stats.models import Contribution
|
||||
|
@ -74,7 +74,8 @@ def send_purchase_receipt(contrib_id, **kw):
|
|||
data = {
|
||||
'app_name': addon.name,
|
||||
'developer_name': version.developer_name if version else '',
|
||||
'price': contrib.get_amount_locale(contrib.source_locale),
|
||||
'price': contrib.get_amount_locale(get_locale_from_lang(
|
||||
contrib.source_locale)),
|
||||
'date': datetime(contrib.created.date()),
|
||||
'purchaser_email': contrib.user.email,
|
||||
#'purchaser_phone': '', # TODO: See bug 894614.
|
||||
|
|
Загрузка…
Ссылка в новой задаче