Skip to content

Commit

Permalink
pre-select if theres just one project
Browse files Browse the repository at this point in the history
Change-Id: I4c1d25efe2b6b3d982f90670fa701c6aad6aeefe
Closes-bug: #1252741
  • Loading branch information
mrunge committed Nov 26, 2013
1 parent e543879 commit feaa960
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion openstack_dashboard/dashboards/admin/users/forms.py
Expand Up @@ -40,7 +40,7 @@ def __init__(self, request, *args, **kwargs):
super(BaseUserForm, self).__init__(request, *args, **kwargs)

# Populate project choices
project_choices = [('', _("Select a project"))]
project_choices = []

# If the user is already set (update action), list only projects which
# the user has access to.
Expand All @@ -52,6 +52,10 @@ def __init__(self, request, *args, **kwargs):
for project in projects:
if project.enabled:
project_choices.append((project.id, project.name))
if not project_choices:
project_choices.insert(0, ('', _("No available projects")))
elif len(project_choices) > 1:
project_choices.insert(0, ('', _("Select a project")))
self.fields['project'].choices = project_choices

def clean(self):
Expand Down

0 comments on commit feaa960

Please sign in to comment.