Ejemplo n.º 1
0
    def filter(self, user, operation, resource, iterable):
        query = shield.filter(*self.permissions[operation],
                              bearer=user,
                              target=resource.meta.model,
                              query=iterable)

        return query.distinct()
Ejemplo n.º 2
0
    def test_filter(self):
        self.register_membership()

        user = self.users[0]

        team_ids = {x.id for x in user.teams}

        query = shield.filter('member', bearer=user, target=models.Team)

        assert {x.id for x in query} == team_ids
Ejemplo n.º 3
0
    def test_deferred_target_style(self):
        self.register_membership()

        shield.deferred_rule(attributes=('team', ),
                             bearer=models.User,
                             target=models.Box)

        result = shield.filter('member',
                               bearer=self.users[0],
                               target=models.Box)

        assert result.count() == 5
Ejemplo n.º 4
0
    def filter(self, user, operation, resource, iterable):
        query = shield.filter(*self.permissions[operation], bearer=user, target=resource.meta.model, query=iterable)

        return query.distinct()
Ejemplo n.º 5
0
    def filter(self, user, operation, resource, iterable):
        clause = shield.filter(
            *self.permissions[operation],
            bearer=user, target=resource.meta.model)

        return resource.filter(clause, iterable)