def send_account_confirmation(commcare_user): from corehq.apps.hqwebapp.tasks import send_html_email_async from corehq.apps.users.views.mobile import CommCareUserConfirmAccountView url = absolute_reverse(CommCareUserConfirmAccountView.urlname, args=[commcare_user.domain, commcare_user.get_id]) template_params = { 'domain': commcare_user.domain, 'username': commcare_user.raw_username, 'url': url, 'url_prefix': get_static_url_prefix(), 'hq_name': commcare_hq_names()['commcare_hq_names']['COMMCARE_HQ_NAME'] } lang = guess_domain_language(commcare_user.domain) with override(lang): text_content = render_to_string( "registration/email/mobile_worker_confirm_account.txt", template_params) html_content = render_to_string( "registration/email/mobile_worker_confirm_account.html", template_params) subject = _( f'Confirm your CommCare account for {commcare_user.domain}') send_html_email_async.delay(subject, commcare_user.email, html_content, text_content=text_content, email_from=settings.DEFAULT_FROM_EMAIL)
def test_guess_domain_language(self): for i, lang in enumerate(['en', 'fra', 'fra']): app = Application.new_app(domain=self.domain_name, name='app{}'.format(i + 1), lang=lang) app.save() lang = guess_domain_language(self.domain_name) self.assertEqual('fra', lang)
def test_guess_domain_language_no_apps(self): lang = guess_domain_language(self.domain_name) self.assertEqual('en', lang)
def test_guess_domain_language(self): for i, lang in enumerate(['en', 'fra', 'fra']): app = Application.new_app(domain=self.domain_name, name='app{}'.format(i + 1), lang=lang) app.save() lang = guess_domain_language(self.domain_name) self.assertEqual('fra', lang)