app_extras.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:RPKI-toolkit 作者: pavel-odintsov 项目源码 文件源码
def alert_count(conf):
    import types
    # convert string handle to Conf object automatically
    if isinstance(conf, types.UnicodeType):
        conf = Conf.objects.get(handle=conf)
    qs = conf.alerts.filter(seen=False)
    unread = len(qs)
    if unread:
        severity = max([x.severity for x in qs])
        css = {
            0: 'badge-info',
            1: 'badge-warning',
            2: 'badge-important'
        }
        css_class = css.get(severity)
    else:
        css_class = 'badge-default'
    return u'<span class="badge %s">%d</span>' % (css_class, unread)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号