policies: fix incorrect bound_to count

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-05-31 10:16:09 +02:00
parent d9172cb296
commit b4d528a789
1 changed files with 1 additions and 3 deletions

View File

@ -48,9 +48,7 @@ class PolicySerializer(ModelSerializer, MetaNameSerializer):
def get_bound_to(self, obj: Policy) -> int: def get_bound_to(self, obj: Policy) -> int:
"""Return objects policy is bound to""" """Return objects policy is bound to"""
if not obj.bindings.exists() and not obj.promptstage_set.exists(): return obj.bindings.count() + obj.promptstage_set.count()
return 0
return obj.bindings.count()
def to_representation(self, instance: Policy): def to_representation(self, instance: Policy):
# pyright: reportGeneralTypeIssues=false # pyright: reportGeneralTypeIssues=false