예제 #1
0
파일: entityset.py 프로젝트: rmallof/aleph
 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
예제 #2
0
파일: role.py 프로젝트: sunu/aleph
    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