From af0d4dab7810e410560b1854ebf8db1188dab2e6 Mon Sep 17 00:00:00 2001 From: Gregory Hooks Date: Sat, 16 Apr 2016 01:34:13 +0000 Subject: 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 --- openstack_dashboard/dashboards/identity/users/tables.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'openstack_dashboard') 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'), -- cgit v1.2.1