From 5c652c1f79d2e2b2f2b109519069532cd3e4a890 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 27 Feb 2021 13:19:38 +0100 Subject: [PATCH] policies: sort groups in groupmembership policy and binding closes #595 --- authentik/policies/forms.py | 4 ++++ authentik/policies/group_membership/forms.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/authentik/policies/forms.py b/authentik/policies/forms.py index 36f7d183f..f6c63b080 100644 --- a/authentik/policies/forms.py +++ b/authentik/policies/forms.py @@ -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) diff --git a/authentik/policies/group_membership/forms.py b/authentik/policies/group_membership/forms.py index 6fa3e8761..bccc7b6b3 100644 --- a/authentik/policies/group_membership/forms.py +++ b/authentik/policies/group_membership/forms.py @@ -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