Added domain: support to ?scope parameter

plugins-v3
Agate 2020-06-05 11:37:12 +02:00
rodzic d43eed805b
commit 7e76fa0bae
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6B501DFD73514E14
2 zmienionych plików z 4 dodań i 0 usunięć

Wyświetl plik

@ -202,6 +202,9 @@ class ActorScopeFilter(filters.CharFilter):
return queryset.none()
return queryset.filter(**{self.actor_field: actor})
elif value.lower().startswith("domain:"):
domain = value.split("domain:", 1)[1]
return queryset.filter(**{"{}__domain_id".format(self.actor_field): domain})
else:
return queryset.none()

Wyświetl plik

@ -52,6 +52,7 @@ def test_mutation_filter_is_approved(value, expected, factories):
("noop", 2, []),
("actor:actor1@domain.test", 0, [0]),
("actor:actor2@domain.test", 0, [1]),
("domain:domain.test", 0, [0, 1]),
],
)
def test_actor_scope_filter(