コード例 #1
0
ファイル: dashboard.py プロジェクト: dimagi/WBNigeria
def alerts(context, request, count=None):
    """
    Renders the user's notifications and alerts.

    If count is given, a maximum of count notifications are returned. All
    alerts will always be returned.
    """
    gens = get_alert_generators('alert', request=request, context=context)
    alerts = list(itertools.chain(*(g for g in gens if g is not None)))
    notifs = Notification.objects.filter(is_open=True, visible_to__user=request.user).order_by('-created_on')
    total = len(alerts) + len(notifs)

    if count:
        notifs = notifs[:count]

    return {
        'alerts': alerts,
        'notifs': notifs,
        'total': total,
        'count': count,
        'program': context.get('program', None),
    }
コード例 #2
0
ファイル: alerts_tags.py プロジェクト: caktus/rapidsms-alerts
def alerts(request):


    alerts = itertools.chain(*(g for g in get_alert_generators('alert', request) if g is not None))
    return render_to_string("alerts/partials/alerts.html",
                            {"alerts": alerts})
コード例 #3
0
def alerts(context):
    request = context['request']
    alerts = itertools.chain(*(g for g in get_alert_generators('alert', request=request, context=context) if g is not None))
    return {"alerts": alerts}