def prepare_group_application_message_notification(user, messages): first_message = messages[0] conversation = first_message.conversation application = conversation.target language = user.language if not translation.check_for_language(language): language = 'en' with translation.override(language): reply_to_name = application.user.display_name conversation_name = _( 'New message in application of %(user_name)s to %(group_name)s' ) % { 'user_name': application.user.display_name, 'group_name': application.group.name, } if application.user == user: conversation_name = _( 'New message in your application to %(group_name)s') % { 'group_name': application.group.name } from_text = author_names(messages) local_part = make_local_part(conversation, user) reply_to = formataddr( (reply_to_name, '{}@{}'.format(local_part, settings.SPARKPOST_RELAY_DOMAIN))) from_email = formataddr((from_text, settings.DEFAULT_FROM_EMAIL)) return prepare_email(template='conversation_message_notification', from_email=from_email, user=user, reply_to=[reply_to], context={ 'messages': messages, 'conversation_name': conversation_name, 'conversation_url': group_application_url(application), 'mute_url': group_application_mute_url( application, conversation), })
def prepare_group_application_message_notification(user, message): application = message.conversation.target language = user.language if not translation.check_for_language(language): language = 'en' with translation.override(language): reply_to_name = application.user.display_name conversation_name = _( 'New message in %(user_name)s\'s application') % { 'user_name': application.user.display_name, } local_part = make_local_part(message.conversation, user) reply_to = formataddr( (reply_to_name, '{}@{}'.format(local_part, settings.SPARKPOST_RELAY_DOMAIN))) from_email = formataddr( (message.author.display_name, settings.DEFAULT_FROM_EMAIL)) return prepare_email('conversation_message_notification', from_email=from_email, user=user, reply_to=[reply_to], context={ 'conversation_name': conversation_name, 'author': message.author, 'message_content': message.content_rendered(), 'conversation_url': group_application_url(application), 'mute_url': group_application_mute_url( application, message.conversation), })
def prepare_new_application_notification_email(user, application): applicant = application.user conversation = Conversation.objects.get_for_target(application) reply_to_name = applicant.display_name local_part = make_local_part(conversation, user) reply_to = formataddr( (reply_to_name, '{}@{}'.format(local_part, settings.SPARKPOST_RELAY_DOMAIN))) from_email = formataddr( (applicant.display_name, settings.DEFAULT_FROM_EMAIL)) return prepare_email(template='new_application', from_email=from_email, user=user, reply_to=[reply_to], context={ 'applicant': applicant, 'group': application.group, 'questions': application.questions_rendered(), 'answers': application.answers_rendered(), 'conversation_url': group_application_url(application), 'mute_url': group_application_mute_url( application, conversation), 'settings_url': group_settings_url(application.group), 'group_applications_url': group_applications_url(application.group), 'group_edit_url': group_edit_url(application.group), })