flows/transfer: fix missing unique fields for PolicyBinding

This commit is contained in:
Jens Langhammer 2020-09-07 11:25:59 +02:00
parent bb9ae28be8
commit 28893b9695
4 changed files with 8 additions and 3 deletions

View File

@ -52,7 +52,7 @@ class FlowExporter:
yield FlowBundleEntry.from_model(policy)
bindings = PolicyBinding.objects.filter(target__in=pbm_uuids).select_related()
for binding in bindings:
yield FlowBundleEntry.from_model(binding)
yield FlowBundleEntry.from_model(binding, "policy", "target", "order")
def walk_stage_prompts(self) -> Iterator[FlowBundleEntry]:
"""Walk over all prompts associated with any PromptStages"""

View File

@ -12,7 +12,7 @@ class PolicyBindingSerializer(ModelSerializer):
class Meta:
model = PolicyBinding
fields = ["policy", "target", "enabled", "order", "timeout"]
fields = ["pk", "policy", "target", "enabled", "order", "timeout"]
class PolicyBindingViewSet(ModelViewSet):

View File

@ -44,7 +44,7 @@ class PolicyBinding(SerializerModel):
enabled = models.BooleanField(default=True)
policy = InheritanceForeignKey("Policy", on_delete=models.CASCADE, related_name="+")
target = models.ForeignKey(
target = InheritanceForeignKey(
PolicyBindingModel, on_delete=models.CASCADE, related_name="+"
)
negate = models.BooleanField(

View File

@ -6243,6 +6243,11 @@ definitions:
- order
type: object
properties:
pk:
title: Policy binding uuid
type: string
format: uuid
readOnly: true
policy:
title: Policy
type: string