def get_allowed_instances(cls, user): """ returns all instances in which the given user has permission to send a message to all users """ if has('global.message'): return Instance.all() else: return [m.instance for m in user.memberships if (m.instance is not None and m.instance.is_authenticated and 'instance.message' in m.group.permissions)]
def _get_allowed_instances(cls, user): """ returns all instances in which the given user has permission to send a message to all users """ if has('global.message'): return Instance.all() else: perm = Permission.find('instance.message') instances = [m.instance for m in user.memberships if (m.instance is not None and m.instance.is_authenticated and perm in m.group.permissions)] return sorted(instances, key=lambda i: i.label)
def _get_allowed_instances(cls, user): """ returns all instances in which the given user has permission to send a message to all users """ if has('global.message'): return Instance.all() else: perm = Permission.find('instance.message') return [ m.instance for m in user.memberships if (m.instance is not None and m.instance.is_authenticated and perm in m.group.permissions) ]
def _get_allowed_instances(cls, user): """ returns all instances in which the given user has permission to send a message to all users """ if has('global.message'): return Instance.all(include_hidden=True) else: perm = Permission.find('instance.message') instances = [ m.instance for m in user.memberships if (m.instance is not None and m.instance.is_authenticated and perm in m.group.permissions) ] return sorted(instances, key=lambda i: i.label)