예제 #1
0
    def apply(self, query: Query, value: Any) -> Query:
        if security_manager.is_admin():
            return query

        filter_set_ids_by_dashboard_owners = (  # pylint: disable=C0103
            query.from_self(FilterSet.id).join(
                dashboard_user,
                FilterSet.owner_id == dashboard_user.c.dashboard_id).filter(
                    and_(
                        FilterSet.owner_type == DASHBOARD_OWNER_TYPE,
                        dashboard_user.c.user_id == get_user_id(),
                    )))

        return query.filter(
            or_(
                and_(
                    FilterSet.owner_type == USER_OWNER_TYPE,
                    FilterSet.owner_id == get_user_id(),
                ),
                FilterSet.id.in_(filter_set_ids_by_dashboard_owners),
            ))
예제 #2
0
파일: meta.py 프로젝트: clld/clld
 def from_self(self, *ent):
     # override from_self() to automatically apply
     # the criterion too.   this works with count() and
     # others.
     return Query.from_self(self.private(), *ent)
예제 #3
0
파일: model.py 프로젝트: magne4000/festival
 def from_self(self, *ent):
     # override from_self() to automatically apply
     # the criterion too.   this works with count() and
     # others.
     return Query.from_self(self.typed(), *ent)
 def from_self(self, *ent):
     # override from_self() to automatically apply
     # the criterion too. This works with count() and
     # others.
     return Query.from_self(self.check_deleted(), *ent)