policies: sort groups in groupmembership policy and binding

closes #595
This commit is contained in:
Jens Langhammer 2021-02-27 13:19:38 +01:00
parent 085589bcec
commit 5c652c1f79
2 changed files with 7 additions and 0 deletions

View file

@ -2,6 +2,7 @@
from django import forms
from authentik.core.models import Group
from authentik.lib.widgets import GroupedModelChoiceField
from authentik.policies.models import Policy, PolicyBinding, PolicyBindingModel
@ -16,6 +17,9 @@ class PolicyBindingForm(forms.ModelForm):
policy = GroupedModelChoiceField(
queryset=Policy.objects.all().select_subclasses(), required=False
)
group = forms.ModelChoiceField(
queryset=Group.objects.all().order_by("name"), required=False
)
def __init__(self, *args, **kwargs): # pragma: no cover
super().__init__(*args, **kwargs)

View file

@ -2,6 +2,7 @@
from django import forms
from authentik.core.models import Group
from authentik.policies.forms import PolicyForm
from authentik.policies.group_membership.models import GroupMembershipPolicy
@ -9,6 +10,8 @@ from authentik.policies.group_membership.models import GroupMembershipPolicy
class GroupMembershipPolicyForm(PolicyForm):
"""GroupMembershipPolicy Form"""
group = forms.ModelChoiceField(queryset=Group.objects.all().order_by("name"))
class Meta:
model = GroupMembershipPolicy