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.EMAIL_REPLY_DOMAIN))) from_email = formataddr( (applicant.display_name, settings.DEFAULT_FROM_EMAIL)) unsubscribe_url = new_application_unsubscribe_url(user, application) return prepare_email( template='new_application', from_email=from_email, user=user, tz=application.group.timezone, reply_to=[reply_to], unsubscribe_url=unsubscribe_url, context={ 'applicant': applicant, 'group': application.group, 'questions': application.questions_rendered(), 'answers': application.answers_rendered(), 'conversation_url': application_url(application), 'mute_url': unsubscribe_url, 'new_application_unsubscribe_url': unsubscribe_url, 'applications_url': applications_url(application.group), 'group_edit_url': group_edit_url(application.group), }, stats_category='new_application', )
def prepare_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)) unsubscribe_url = conversation_unsubscribe_url( user, group=application.group, conversation=conversation) return prepare_email( template='conversation_message_notification', from_email=from_email, user=user, tz=application.group.timezone, reply_to=[reply_to], unsubscribe_url=unsubscribe_url, context={ 'messages': messages, 'conversation_name': conversation_name, 'conversation_url': application_url(application), 'mute_url': unsubscribe_url, }, stats_category='application_message', )
def prepare_application_message_notification(user, messages): application = target_from_messages(messages) with translation.override(language_for_user(user)): reply_to_name = application.user.display_name if application.user == user: conversation_name = _('New message in your application to %(group_name)s') % { 'group_name': application.group.name } else: 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, } return prepare_message_notification( user, messages, reply_to_name=reply_to_name, group=application.group, conversation_name=conversation_name, conversation_url=application_url(application), stats_category='application_message' )