policies: sort groups in groupmembership policy and binding

closes #595

# Conflicts:
#	authentik/policies/group_membership/forms.py
This commit is contained in:
Jens Langhammer 2021-02-27 13:19:38 +01:00
parent e81d3dad3e
commit a4d5815e1b
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
@ -19,6 +20,9 @@ class PolicyBindingForm(forms.ModelForm):
policy = GroupedModelChoiceField(
queryset=Policy.objects.all().select_subclasses(),
)
group = forms.ModelChoiceField(
queryset=Group.objects.all().order_by("name"), required=False
)
def __init__(self, *args, **kwargs):
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 GENERAL_FIELDS
from authentik.policies.group_membership.models import GroupMembershipPolicy
@ -9,6 +10,8 @@ from authentik.policies.group_membership.models import GroupMembershipPolicy
class GroupMembershipPolicyForm(forms.ModelForm):
"""GroupMembershipPolicy Form"""
group = forms.ModelChoiceField(queryset=Group.objects.all().order_by("name"))
class Meta:
model = GroupMembershipPolicy