Пример #1
0
def send_coverage_request_email(user, message, item):
    """
    Forms and sends coverage request email
    :param user: User that makes the request
    :param message: Request message
    :param item: agenda item that request is made against
    :return:
    """

    general_settings = get_settings_collection().find_one(
        GENERAL_SETTINGS_LOOKUP)
    if not general_settings:
        return

    recipients = general_settings.get('values').get(
        'coverage_request_recipients').split(',')
    assert recipients
    assert isinstance(recipients, list)
    url = url_for_agenda({'_id': item['_id']}, _external=True)
    name = '{} {}'.format(user.get('first_name'), user.get('last_name'))
    email = user.get('email')

    item_name = item.get('name') or item.get('slugline')
    subject = gettext('Coverage inquiry: {}'.format(item_name))
    user_company = get_user_company(user)
    if user_company:
        user_company = user_company.get('name')

    text_body = render_template('coverage_request_email.txt',
                                name=name,
                                email=email,
                                message=message,
                                url=url,
                                company=user_company,
                                recipients=recipients,
                                subject=subject,
                                item_name=item_name)
    html_body = render_template('coverage_request_email.html',
                                name=name,
                                email=email,
                                message=message,
                                url=url,
                                company=user_company,
                                recipients=recipients,
                                subject=subject,
                                item_name=item_name)

    send_email(to=recipients,
               subject=subject,
               text_body=text_body,
               html_body=html_body)
Пример #2
0
def _send_history_match_agenda_notification_email(user, item):
    app_name = current_app.config['SITE_NAME']
    url = url_for_agenda(item, _external=True)
    recipients = [user['email']]
    subject = gettext(
        'New update for your previously accessed agenda: {}'.format(
            item['name']))
    text_body = render_template('new_item_notification.txt',
                                app_name=app_name,
                                is_topic=False,
                                name=user.get('first_name'),
                                item=item,
                                url=url,
                                type='agenda',
                                dateString=get_agenda_dates(item),
                                location=get_location_string(item),
                                contacts=get_public_contacts(item),
                                links=get_links(item),
                                is_admin=is_admin_or_internal(user),
                                section='agenda')

    send_email(to=recipients, subject=subject, text_body=text_body)
Пример #3
0
def _send_new_agenda_notification_email(user, topic_name, item):
    url = url_for_agenda(item, _external=True)
    recipients = [user['email']]
    subject = gettext('New update for followed agenda: {}'.format(topic_name))
    kwargs = dict(app_name=current_app.config['SITE_NAME'],
                  is_topic=True,
                  topic_name=topic_name,
                  name=user.get('first_name'),
                  item=item,
                  url=url,
                  type='agenda',
                  dateString=get_agenda_dates(item),
                  location=get_location_string(item),
                  contacts=get_public_contacts(item),
                  links=get_links(item),
                  is_admin=is_admin_or_internal(user),
                  section='agenda')
    text_body = render_template('new_item_notification.txt', **kwargs)
    html_body = render_template('new_item_notification.html', **kwargs)
    send_email(to=recipients,
               subject=subject,
               text_body=text_body,
               html_body=html_body)