<s> import logging <EOL> from django . conf import settings <EOL> from django . contrib . sites . models import Site <EOL> from django . core . urlresolvers import reverse <EOL> from django . utils . translation import ugettext as _ <EOL> from celery import task <EOL> from kitsune . messages . models import InboxMessage <EOL> from kitsune . sumo . decorators import timeit <EOL> from kitsune . sumo . email_utils import make_mail , safe_translation , send_messages <EOL> log = logging . getLogger ( '<STR_LIT>' ) <EOL> @ task ( ) <EOL> @ timeit <EOL> def email_private_message ( inbox_message_id ) : <EOL> """<STR_LIT>""" <EOL> inbox_message = InboxMessage . objects . get ( id = inbox_message_id ) <EOL> log . debug ( '<STR_LIT>' % ( inbox_message . to , ) ) <EOL> user = inbox_message . to <EOL> @ safe_translation <EOL> def _send_mail ( locale ) : <EOL> from kitsune . users . templatetags . jinja_helpers import display_name <EOL> subject = _ ( u'<STR_LIT>' ) <EOL> subject = subject . format ( <EOL> sender = display_name ( inbox_message . sender ) ) <EOL> msg_url = reverse ( '<STR_LIT>' , kwargs = { '<STR_LIT>' : inbox_message . id } ) <EOL> settings_url = reverse ( '<STR_LIT>' ) <EOL> from kitsune . sumo . templatetags . jinja_helpers import add_utm <EOL> context = { <EOL> '<STR_LIT>' : inbox_message . sender , <EOL> '<STR_LIT:message>' : inbox_message . message , <EOL> '<STR_LIT>' : inbox_message . content_parsed , <EOL> '<STR_LIT>' : add_utm ( msg_url , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : add_utm ( settings_url , '<STR_LIT>' ) , <EOL> '<STR_LIT:host>' : Site . objects . get_current ( ) . domain } <EOL> mail = make_mail ( subject = subject , <EOL> text_template = '<STR_LIT>' , <EOL> html_template = '<STR_LIT>' , <EOL> context_vars = context , <EOL> from_email = settings . TIDINGS_FROM_ADDRESS , <EOL> to_email = inbox_message . to . email ) <EOL> send_messages ( [ mail ] ) <EOL> if hasattr ( user , '<STR_LIT>' ) : <EOL> locale = user . profile . locale <EOL> else : <EOL> locale = settings . WIKI_DEFAULT_LANGUAGE <EOL> _send_mail ( locale ) </s>
