Correct error messages on update network form

The name is not required, so data["name"] may be empty.
When data["name"] is empty, get the id value.
This patch correct error messages on update network form

Change-Id: Icc1b0ad7077dedfea77d6c0225dc2747d7efc1b5
This commit is contained in:
pengyuesheng 2019-05-06 17:06:18 +08:00
parent 4ab7f806b8
commit 9f4c9d19db
2 changed files with 4 additions and 2 deletions

View File

@ -351,6 +351,7 @@ class UpdateNetwork(forms.SelfHandlingForm):
except Exception as e:
LOG.info('Failed to update network %(id)s: %(exc)s',
{'id': self.initial['network_id'], 'exc': e})
msg = _('Failed to update network %s') % data['name']
name_or_id = data['name'] or self.initial['network_id']
msg = _('Failed to update network %s') % name_or_id
redirect = reverse(self.failure_url)
exceptions.handle(request, msg, redirect=redirect)

View File

@ -64,6 +64,7 @@ class UpdateNetwork(forms.SelfHandlingForm):
except Exception as e:
LOG.info('Failed to update network %(id)s: %(exc)s',
{'id': self.initial['network_id'], 'exc': e})
msg = _('Failed to update network %s') % data['name']
name_or_id = data['name'] or self.initial['network_id']
msg = _('Failed to update network %s') % name_or_id
redirect = reverse(self.failure_url)
exceptions.handle(request, msg, redirect=redirect)