diff options
author | Gregory Hooks <gregoryhooksjr@gmail.com> | 2016-04-16 01:34:13 +0000 |
---|---|---|
committer | Gregory Hooks <gregoryhooksjr@gmail.com> | 2016-04-16 04:03:50 +0000 |
commit | af0d4dab7810e410560b1854ebf8db1188dab2e6 (patch) | |
tree | b788b12a43ff12fec4a9cb217c51cd39fef4f861 /openstack_dashboard | |
parent | fbfc638de66c506b622088065c9226ab518c806f (diff) | |
download | horizon-af0d4dab7810e410560b1854ebf8db1188dab2e6.tar.gz |
Added a warning message if User Name is empty
Adding required=False to the user name form allows it to call
update_cell when it has been left empty. I added logic to update_cell
to check if the form is empty or contains only whitespace and issue a
warning if true and only if the form in question is called 'name'.
Change-Id: Ieccb3f6d7be1acb4b7734e68d467a40cfc7eb99c
Closes-Bug: 1567398
Diffstat (limited to 'openstack_dashboard')
-rw-r--r-- | openstack_dashboard/dashboards/identity/users/tables.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/openstack_dashboard/dashboards/identity/users/tables.py b/openstack_dashboard/dashboards/identity/users/tables.py index 3d2dabd95..4353f1b19 100644 --- a/openstack_dashboard/dashboards/identity/users/tables.py +++ b/openstack_dashboard/dashboards/identity/users/tables.py @@ -195,6 +195,11 @@ class UpdateCell(tables.UpdateAction): try: user_obj = datum setattr(user_obj, cell_name, new_cell_value) + if ((not new_cell_value) or new_cell_value.isspace()) and \ + (cell_name == 'name'): + message = _("The User Name field cannot be empty.") + messages.warning(request, message) + raise django_exceptions.ValidationError(message) kwargs = {} attr_to_keyword_map = { 'name': 'name', @@ -228,7 +233,7 @@ class UsersTable(tables.DataTable): name = tables.Column('name', link="horizon:identity:users:detail", verbose_name=_('User Name'), - form_field=forms.CharField(), + form_field=forms.CharField(required=False), update_action=UpdateCell) description = tables.Column(lambda obj: getattr(obj, 'description', None), verbose_name=_('Description'), |