def send_purchase_receipt(contrib_id, **kw): """ Sends an email to the purchaser of the app. """ contrib = Contribution.objects.get(pk=contrib_id) with contrib.user.activate_lang(): addon = contrib.addon version = addon.current_version or addon.latest_version # L10n: {0} is the app name. subject = _('Receipt for {0}').format(contrib.addon.name) data = { 'app_name': addon.name, 'developer_name': version.developer_name if version else '', 'price': contrib.get_amount_locale(get_locale_from_lang( contrib.source_locale)), 'date': jingo.helpers.datetime(contrib.created.date()), 'purchaser_email': contrib.user.email, # 'purchaser_phone': '', # TODO: See bug 894614. # 'purchaser_last_four': '', 'transaction_id': contrib.uuid, 'purchases_url': absolutify('/purchases'), 'support_url': addon.support_url, 'terms_of_service_url': absolutify('/terms-of-use'), } log.info('Sending email about purchase: %s' % contrib_id) text_template = 'purchase/receipt.ltxt' html_template = 'purchase/receipt.html' send_html_mail_jinja(subject, html_template, text_template, data, recipient_list=[contrib.user.email])
def send_purchase_receipt(contrib_id, **kw): """ Sends an email to the purchaser of the app. """ contrib = Contribution.objects.get(pk=contrib_id) with contrib.user.activate_lang(): addon = contrib.addon version = addon.current_version or addon.latest_version # L10n: {0} is the app name. subject = _('Receipt for {0}').format(contrib.addon.name) data = { 'app_name': addon.name, 'developer_name': version.developer_name if version else '', 'price': contrib.get_amount_locale(get_locale_from_lang( contrib.source_locale)), 'date': jingo.helpers.datetime(contrib.created.date()), 'purchaser_email': contrib.user.email, #'purchaser_phone': '', # TODO: See bug 894614. #'purchaser_last_four': '', 'transaction_id': contrib.uuid, 'purchases_url': absolutify('/purchases'), 'support_url': addon.support_url, 'terms_of_service_url': absolutify('/terms-of-use'), } log.info('Sending email about purchase: %s' % contrib_id) text_template = 'purchase/receipt.ltxt' html_template = 'purchase/receipt.html' send_html_mail_jinja(subject, html_template, text_template, data, recipient_list=[contrib.user.email])
def get_amount_locale(self, locale=None): """Localise the amount paid into the current locale.""" if not locale: lang = translation.get_language() locale = get_locale_from_lang(lang) return numbers.format_currency(self.amount or 0, self.currency or 'USD', locale=locale)
def price_locale(price, currency): lang = translation.get_language() locale = get_locale_from_lang(lang) pricestr = numbers.format_currency(price, currency, locale=locale) if currency == 'EUR': # See bug 865358. EU style guide # (http://publications.europa.eu/code/en/en-370303.htm#position) # disagrees with Unicode CLDR on placement of Euro symbol. bare = pricestr.strip(u'\xa0\u20ac') if lang.startswith(('en', 'ga', 'lv', 'mt')): return u'\u20ac' + bare else: return bare + u'\xa0\u20ac' return pricestr
def _get_format(): lang = translation.get_language() return Format(get_locale_from_lang(lang))
def price_locale(price, currency): lang = translation.get_language() locale = get_locale_from_lang(lang) return numbers.format_currency(price, currency, locale=locale)