def index():
    require(request.authz.logged_in)
    role = Role.by_id(request.authz.id)
    require(role is not None)
    query = Notification.by_role(role)
    result = DatabaseQueryResult(request, query, schema=NotificationSchema)
    return jsonify(result)
示例#2
0
def generate_role_digest(role):
    """Generate notification digest emails for the given user."""
    # TODO: get and use the role's locale preference.
    since = datetime.utcnow() - timedelta(hours=25)
    q = Notification.by_role(role, since=since)
    total_count = q.count()
    if total_count == 0:
        return
    notifications = []
    for notification in q.limit(25):
        notifications.append(render_notification(notification))

    subject = '%s notifications' % total_count
    notify_role(role, subject,
                'email/notifications.html',
                total_count=total_count,
                notifications=notifications,
                manage_url=ui_url('notifications'))
示例#3
0
def generate_role_digest(role):
    """Generate notification digest emails for the given user."""
    # TODO: get and use the role's locale preference.
    since = datetime.utcnow() - timedelta(hours=25)
    q = Notification.by_role(role, since=since)
    total_count = q.count()
    if total_count == 0:
        return
    notifications = [render_notification(role, n) for n in q.limit(30)]
    notifications = [n for n in notifications if n is not None]
    params = dict(notifications=notifications,
                  role=role,
                  total_count=total_count,
                  manage_url=ui_url('notifications'),
                  ui_url=settings.APP_UI_URL,
                  app_title=settings.APP_TITLE)
    plain = render_template('email/notifications.txt', **params)
    html = render_template('email/notifications.html', **params)
    log.info("Notification: %s", plain)
    subject = '%s notifications' % total_count
    email_role(role, subject, html=html, plain=plain)
示例#4
0
def index():
    require(request.authz.logged_in)
    query = Notification.by_role(request.authz.role)
    result = DatabaseQueryResult(request, query, schema=NotificationSchema)
    return jsonify(result)
示例#5
0
def index():
    require(request.authz.logged_in)
    role = Role.by_id(request.authz.id)
    query = Notification.by_role(role)
    result = DatabaseQueryResult(request, query)
    return NotificationSerializer.jsonify_result(result)