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
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
def edit_form(self, obj=None): form = super(WatchLiveTaskAdmin, self).edit_form(obj) cids = Channels.all_channels_ids() channels = Channels.get_list(cids) form.channels.choices = [(c.sign, c.channels_name) for c in channels] vids = VersionConfig.all_version_ids() version = VersionConfig.get_list(vids) form.version_code_mix.choices = [(v.version_code, v.version_name) for v in version] form.version_code_max.choices = [(v.version_code, v.version_name) for v in version] pids = Province.all_province_ids() province = Province.get_list(pids) form.province.choices = [(p.code, ''.join((p.name, p.operators))) for p in province] form.group.choices = Group.groups_for_admin() return form
def edit_form(self, obj=None): form = super(UserGroupAdmin, self).edit_form(obj) form.group.choices = Group.groups_for_admin() return form