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)
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'))
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)
def index(): require(request.authz.logged_in) query = Notification.by_role(request.authz.role) result = DatabaseQueryResult(request, query, schema=NotificationSchema) return jsonify(result)
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)