diff --git a/openstack_dashboard/dashboards/admin/users/forms.py b/openstack_dashboard/dashboards/admin/users/forms.py index 6edeabb2207..596acde58a7 100644 --- a/openstack_dashboard/dashboards/admin/users/forms.py +++ b/openstack_dashboard/dashboards/admin/users/forms.py @@ -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. @@ -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):