Orders the projects and roles in user creation combos
Sorts the available project and role names in the Primary Project and Roles combos respectively when creating a new user through the identity dashboard/create user dialog. Change-Id: Ia488d598727dfc11ec4b8bc7f8f2fd3f6aa7fde6 Closes-Bug: 1713497 Co-Authored-By: Ales Krivak <ales.krivak@ultimum.io>
This commit is contained in:
parent
c39891170a
commit
8840fdbdd3
|
@ -78,7 +78,7 @@ class BaseUserForm(forms.SelfHandlingForm):
|
|||
projects, has_more = api.keystone.tenant_list(
|
||||
request, user=user_id)
|
||||
|
||||
for project in projects:
|
||||
for project in sorted(projects, key=lambda p: p.name.lower()):
|
||||
if project.enabled:
|
||||
project_choices.append((project.id, project.name))
|
||||
if not project_choices:
|
||||
|
@ -144,7 +144,10 @@ class CreateUserForm(PasswordMixin, BaseUserForm, AddExtraColumnMixIn):
|
|||
self.add_extra_fields(ordering)
|
||||
self.fields = collections.OrderedDict(
|
||||
(key, self.fields[key]) for key in ordering)
|
||||
role_choices = [(role.id, role.name) for role in roles]
|
||||
role_choices = [
|
||||
(role.id, role.name) for role in
|
||||
sorted(roles, key=lambda r: r.name.lower())
|
||||
]
|
||||
self.fields['role_id'].choices = role_choices
|
||||
|
||||
# For keystone V3, display the two fields in read-only
|
||||
|
|
Loading…
Reference in New Issue