示例#1
0
 def user_in_group(cls, gid, uid):
     group = Group.get_one(gid)
     # 用户组不存在直接返回True
     if group is None:
         return True
     _is_in_group = UserGroup.user_in_group(gid, uid)
     if group.gtype == const.WHITELIST_GROUP:
         return _is_in_group
     else:
         return not _is_in_group
示例#2
0
def format_group(view, context, model, name):
    model = model if isinstance(model, dict) else model_to_dict(model)
    _value = model.get(name, None)
    obj = Group.get_one(str(_value), check_online=False)
    if obj:
        _value = '%s (%s)' % (obj.name, _value)
        html = u'<a href="/admin/groupview/?flt1_0=%s">%s</a>' % (str(
            obj._id), _value)
        _value = widgets.HTMLString(html)
    else:
        _value = u'分组不存在'
    return _value