2019-10-07 15:33:48 +01:00
|
|
|
"""General fields"""
|
2020-07-03 23:16:16 +01:00
|
|
|
|
2020-05-16 18:55:59 +01:00
|
|
|
from django import forms
|
|
|
|
|
2020-07-03 23:16:16 +01:00
|
|
|
from passbook.lib.widgets import GroupedModelChoiceField
|
|
|
|
from passbook.policies.models import Policy, PolicyBinding, PolicyBindingModel
|
2019-10-07 15:33:48 +01:00
|
|
|
|
2020-05-28 20:45:54 +01:00
|
|
|
GENERAL_FIELDS = ["name"]
|
|
|
|
GENERAL_SERIALIZER_FIELDS = ["pk", "name"]
|
2020-05-16 18:55:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
class PolicyBindingForm(forms.ModelForm):
|
|
|
|
"""Form to edit Policy to PolicyBindingModel Binding"""
|
|
|
|
|
2020-07-03 23:16:16 +01:00
|
|
|
target = GroupedModelChoiceField(
|
2020-05-20 08:17:06 +01:00
|
|
|
queryset=PolicyBindingModel.objects.all().select_subclasses(),
|
|
|
|
to_field_name="pbm_uuid",
|
2020-05-16 18:55:59 +01:00
|
|
|
)
|
2020-07-03 23:16:16 +01:00
|
|
|
policy = GroupedModelChoiceField(queryset=Policy.objects.all().select_subclasses(),)
|
2020-05-16 18:55:59 +01:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = PolicyBinding
|
2020-05-28 20:45:54 +01:00
|
|
|
fields = ["enabled", "policy", "target", "order", "timeout"]
|