Beispiel #1
0
 def by_authz(cls, authz, types=None, prefix=None):
     ids = authz.collections(authz.READ)
     q = cls.by_type(types)
     q = q.filter(cls.collection_id.in_(ids))
     if prefix is not None:
         q = q.filter(query_like(cls.label, prefix))
     return q
Beispiel #2
0
    def by_prefix(cls, prefix, exclude=[]):
        """Load a list of roles matching a name, email address, or foreign_id.

        :param str pattern: Pattern to match.
        """
        q = cls.all_users()
        if len(exclude):
            q = q.filter(not_(Role.id.in_(exclude)))
        q = q.filter(
            or_(
                func.lower(cls.email) == prefix.lower(),
                query_like(cls.name, prefix)))
        q = q.order_by(Role.id.asc())
        return q