Пример #1
0
def notify_admins_new_user(user):
    admins = User.query.filter_by(is_admin=True).all()
    msg = Message(
        "New Poisk user registered: %s" % user.nick,
        sender=current_app.config['ADMIN_EMAILS'][0],
        recipients=[a.email for a in admins],
    )
    msg.body = textwrap.dedent("""
                           %s registered at Poisk.
                           See: %s
                           """ % (user, url_for('admin.users', _external=True))
                           )
    try:
        mail.send(msg)
    except Exception:
        current_app.logger.exception("error sending mail")
Пример #2
0
def notify_key_given(user, key, giver):
    if not user.email:
        return

    msg = Message(
        "Poisk: %s gave you %s" % (giver.nick, key.name),
        sender=current_app.config['ADMIN_EMAILS'][0],
        recipients=[user.email],
    )
    msg.body = textwrap.dedent("""
                           Congratulations, you are now the keyholder of %s.
                           Please blame %s.
                           """ % (key.name, giver)
                           )

    try:
        mail.send(msg)
    except Exception:
        current_app.logger.exception("error sending mail")
Пример #3
0
def notify_stale_keyholder(user, key, doit=False):
    if not user.email:
        return

    msg = Message(
        "Poisk: please return %s" % (key.name),
        sender=current_app.config['ADMIN_EMAILS'][0],
        recipients=[user.email],
    )
    msg.body = textwrap.dedent("""
                           You were last seen %s ago.
                           Please return the key!
                           """ % (key.last_activity_str)
                           )

    try:
        if doit:
            mail.send(msg)
        else:
            print '>' * 30
            print msg
    except Exception:
        current_app.logger.exception("error sending mail")