def test_no_activate(self, mock_activate): """If lang is Falsy, do not call activate.""" activate('fr') eq_(get_language(), 'fr') with use_lang(None): eq_(get_language(), 'fr') eq_(get_language(), 'fr') ok_(not mock_activate.called)
def send_rejection_email(user_id): """ Send email to the video's creator telling them that their video has been rejected. """ user = get_object_or_none(User, id=user_id) if user: with use_lang(user.profile.locale): body = render_to_string('videos/2013/rejection_email.html', { 'user': user }) _send_mail(EMAIL_SUBJECT, body, [user.email])
def send_approval_email(video): """ Send email to the video's creator telling them that their video has been approved. """ profile = video.user.profile with use_lang(profile.locale if profile else settings.LANGUAGE_CODE): body = render_to_string('videos/2013/approval_email.html', { 'user': video.user, 'video': video }) _send_mail(EMAIL_SUBJECT, body, [video.user.email])
def send_rejection_email(user_id): """ Send email to the video's creator telling them that their video has been rejected. """ user = get_object_or_none(User, id=user_id) if user: with use_lang(user.profile.locale): text_body = render_to_string('videos/2013/rejection_email.ltxt', {'user': user}) html_body = render_to_string('videos/2013/rejection_email.html', {'user': user}) _send_mail(EMAIL_SUBJECT, text_body, html_body, [user.email])
def send_approval_email(video): """ Send email to the video's creator telling them that their video has been approved. """ profile = video.user.profile with use_lang(profile.locale if profile else settings.LANGUAGE_CODE): text_body = render_to_string('videos/2013/approval_email.ltxt', { 'user': video.user, 'video': video }) html_body = render_to_string('videos/2013/approval_email.html', { 'user': video.user, 'video': video }) _send_mail(EMAIL_SUBJECT, text_body, html_body, [video.user.email])
def test_basic(self): activate('fr') eq_(get_language(), 'fr') with use_lang('en-us'): eq_(get_language(), 'en-us') eq_(get_language(), 'fr')