Error handling patterns are consistent in volumes forms
Fixed in handle-function after exception(for that would have the same behavior). Now, after error -- the form will close(If this not form-validation error) Closes-Bug: #1353194 Change-Id: I4ced2c249712f42be56471af418cff6793e48db1
This commit is contained in:
parent
c412502ede
commit
5aca62f8b2
@ -11,6 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
@ -44,6 +45,7 @@ class UpdateStatus(forms.SelfHandlingForm):
|
||||
' status: "%s".') % choice)
|
||||
return True
|
||||
except Exception:
|
||||
redirect = reverse("horizon:admin:volumes:index")
|
||||
exceptions.handle(request,
|
||||
_('Unable to update volume snapshot status.'))
|
||||
return False
|
||||
_('Unable to update volume snapshot status.'),
|
||||
redirect=redirect)
|
||||
|
@ -10,6 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from openstack_dashboard import api
|
||||
@ -33,8 +34,10 @@ class CreateExtraSpec(forms.SelfHandlingForm):
|
||||
messages.success(request, msg)
|
||||
return True
|
||||
except Exception:
|
||||
redirect = reverse("horizon:admin:volumes:index")
|
||||
exceptions.handle(request,
|
||||
_("Unable to create volume type extra spec."))
|
||||
_("Unable to create volume type extra spec."),
|
||||
redirect=redirect)
|
||||
|
||||
|
||||
class EditExtraSpec(forms.SelfHandlingForm):
|
||||
@ -51,5 +54,7 @@ class EditExtraSpec(forms.SelfHandlingForm):
|
||||
messages.success(request, msg)
|
||||
return True
|
||||
except Exception:
|
||||
redirect = reverse("horizon:admin:volumes:index")
|
||||
exceptions.handle(request,
|
||||
_("Unable to edit volume type extra spec."))
|
||||
_("Unable to edit volume type extra spec."),
|
||||
redirect=redirect)
|
||||
|
@ -11,6 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
@ -52,9 +53,10 @@ class CreateVolumeTypeEncryption(forms.SelfHandlingForm):
|
||||
'volume type: %s') % data['name'])
|
||||
return volume_type
|
||||
except Exception:
|
||||
redirect = reverse("horizon:admin:volumes:index")
|
||||
exceptions.handle(request,
|
||||
_('Unable to create encrypted volume type.'))
|
||||
return False
|
||||
_('Unable to create encrypted volume type.'),
|
||||
redirect=redirect)
|
||||
|
||||
|
||||
class ManageQosSpecAssociation(forms.SelfHandlingForm):
|
||||
@ -140,9 +142,10 @@ class ManageQosSpecAssociation(forms.SelfHandlingForm):
|
||||
_('Successfully updated QoS Spec association.'))
|
||||
return True
|
||||
except Exception:
|
||||
redirect = reverse("horizon:admin:volumes:index")
|
||||
exceptions.handle(request,
|
||||
_('Error updating QoS Spec association.'))
|
||||
return False
|
||||
_('Error updating QoS Spec association.'),
|
||||
redirect=redirect)
|
||||
|
||||
|
||||
class EditQosSpecConsumer(forms.SelfHandlingForm):
|
||||
@ -182,5 +185,6 @@ class EditQosSpecConsumer(forms.SelfHandlingForm):
|
||||
_('Successfully modified QoS Spec consumer.'))
|
||||
return True
|
||||
except Exception:
|
||||
exceptions.handle(request, _('Error editing QoS Spec consumer.'))
|
||||
return False
|
||||
redirect = reverse("horizon:admin:volumes:index")
|
||||
exceptions.handle(request, _('Error editing QoS Spec consumer.'),
|
||||
redirect=redirect)
|
||||
|
@ -10,6 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
@ -38,9 +39,10 @@ class CreateKeyValuePair(forms.SelfHandlingForm):
|
||||
messages.success(request, msg)
|
||||
return True
|
||||
except Exception:
|
||||
redirect = reverse("horizon:admin:volumes:index")
|
||||
exceptions.handle(request,
|
||||
_("Unable to create spec."))
|
||||
return False
|
||||
_("Unable to create spec."),
|
||||
redirect=redirect)
|
||||
|
||||
|
||||
class EditKeyValuePair(forms.SelfHandlingForm):
|
||||
@ -65,6 +67,7 @@ class EditKeyValuePair(forms.SelfHandlingForm):
|
||||
messages.success(request, msg)
|
||||
return True
|
||||
except Exception:
|
||||
redirect = reverse("horizon:admin:volumes:index")
|
||||
exceptions.handle(request,
|
||||
_("Unable to edit spec."))
|
||||
return False
|
||||
_("Unable to edit spec."),
|
||||
redirect=redirect)
|
||||
|
@ -16,6 +16,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.forms import ValidationError # noqa
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
@ -128,8 +129,9 @@ class ManageVolume(forms.SelfHandlingForm):
|
||||
% volume_name)
|
||||
return True
|
||||
except Exception:
|
||||
exceptions.handle(request, _("Unable to manage volume."))
|
||||
return False
|
||||
redirect = reverse("horizon:admin:volumes:index")
|
||||
exceptions.handle(request, _("Unable to manage volume."),
|
||||
redirect=redirect)
|
||||
|
||||
|
||||
class UnmanageVolume(forms.SelfHandlingForm):
|
||||
@ -158,8 +160,9 @@ class UnmanageVolume(forms.SelfHandlingForm):
|
||||
% data['name'])
|
||||
return True
|
||||
except Exception:
|
||||
exceptions.handle(request, _("Unable to unmanage volume."))
|
||||
return False
|
||||
redirect = reverse("horizon:admin:volumes:index")
|
||||
exceptions.handle(request, _("Unable to unmanage volume."),
|
||||
redirect=redirect)
|
||||
|
||||
|
||||
class CreateVolumeType(forms.SelfHandlingForm):
|
||||
@ -174,9 +177,10 @@ class CreateVolumeType(forms.SelfHandlingForm):
|
||||
% data['name'])
|
||||
return volume_type
|
||||
except Exception:
|
||||
redirect = reverse("horizon:admin:volumes:index")
|
||||
exceptions.handle(request,
|
||||
_('Unable to create volume type.'))
|
||||
return False
|
||||
_('Unable to create volume type.'),
|
||||
redirect=redirect)
|
||||
|
||||
|
||||
class UpdateStatus(forms.SelfHandlingForm):
|
||||
@ -215,10 +219,10 @@ class UpdateStatus(forms.SelfHandlingForm):
|
||||
new_status)
|
||||
return True
|
||||
except Exception:
|
||||
redirect = reverse("horizon:admin:volumes:index")
|
||||
exceptions.handle(request,
|
||||
_('Unable to update volume status to "%s".') %
|
||||
new_status)
|
||||
return False
|
||||
new_status, redirect=redirect)
|
||||
|
||||
|
||||
class CreateQosSpec(forms.SelfHandlingForm):
|
||||
@ -236,6 +240,7 @@ class CreateQosSpec(forms.SelfHandlingForm):
|
||||
% data['name'])
|
||||
return qos_spec
|
||||
except Exception:
|
||||
redirect = reverse("horizon:admin:volumes:index")
|
||||
exceptions.handle(request,
|
||||
_('Unable to create QoS Spec.'))
|
||||
return False
|
||||
_('Unable to create QoS Spec.'),
|
||||
redirect=redirect)
|
||||
|
@ -62,7 +62,6 @@ class CreateBackupForm(forms.SelfHandlingForm):
|
||||
exceptions.handle(request,
|
||||
_('Unable to create volume backup.'),
|
||||
redirect=redirect)
|
||||
return False
|
||||
|
||||
|
||||
class RestoreBackupForm(forms.SelfHandlingForm):
|
||||
@ -106,5 +105,5 @@ class RestoreBackupForm(forms.SelfHandlingForm):
|
||||
return restore
|
||||
except Exception:
|
||||
msg = _('Unable to restore backup.')
|
||||
exceptions.handle(request, msg)
|
||||
return False
|
||||
redirect = reverse('horizon:project:volumes:index')
|
||||
exceptions.handle(request, msg, redirect=redirect)
|
||||
|
@ -394,9 +394,10 @@ class CreateForm(forms.SelfHandlingForm):
|
||||
self.api_error(e.messages[0])
|
||||
return False
|
||||
except Exception:
|
||||
exceptions.handle(request, ignore=True)
|
||||
self.api_error(_("Unable to create volume."))
|
||||
return False
|
||||
redirect = reverse("horizon:project:volumes:index")
|
||||
exceptions.handle(request,
|
||||
_("Unable to create volume."),
|
||||
redirect=redirect)
|
||||
|
||||
@memoized
|
||||
def get_snapshot(self, request, id):
|
||||
@ -544,7 +545,9 @@ class CreateTransferForm(forms.SelfHandlingForm):
|
||||
args=(transfer.id, transfer.auth_key)))
|
||||
return response
|
||||
except Exception:
|
||||
exceptions.handle(request, _('Unable to create volume transfer.'))
|
||||
redirect = reverse("horizon:project:volumes:index")
|
||||
exceptions.handle(request, _('Unable to create volume transfer.'),
|
||||
redirect=redirect)
|
||||
|
||||
|
||||
class AcceptTransferForm(forms.SelfHandlingForm):
|
||||
@ -563,7 +566,9 @@ class AcceptTransferForm(forms.SelfHandlingForm):
|
||||
messages.success(request, msg)
|
||||
return transfer
|
||||
except Exception:
|
||||
exceptions.handle(request, _('Unable to accept volume transfer.'))
|
||||
redirect = reverse("horizon:project:volumes:index")
|
||||
exceptions.handle(request, _('Unable to accept volume transfer.'),
|
||||
redirect=redirect)
|
||||
|
||||
|
||||
class ShowTransferForm(forms.SelfHandlingForm):
|
||||
@ -675,12 +680,11 @@ class UploadToImageForm(forms.SelfHandlingForm):
|
||||
|
||||
return True
|
||||
except Exception:
|
||||
redirect = reverse("horizon:project:volumes:index")
|
||||
error_message = _(
|
||||
'Unable to upload volume to image for volume: "%s"') \
|
||||
% data['name']
|
||||
exceptions.handle(request, error_message)
|
||||
|
||||
return False
|
||||
exceptions.handle(request, error_message, redirect=redirect)
|
||||
|
||||
|
||||
class ExtendForm(forms.SelfHandlingForm):
|
||||
@ -789,9 +793,8 @@ class RetypeForm(forms.SelfHandlingForm):
|
||||
|
||||
return True
|
||||
except Exception:
|
||||
redirect = reverse("horizon:project:volumes:index")
|
||||
error_message = _(
|
||||
'Unable to change the volume type for volume: "%s"') \
|
||||
% data['name']
|
||||
exceptions.handle(request, error_message)
|
||||
|
||||
return False
|
||||
exceptions.handle(request, error_message, redirect=redirect)
|
||||
|
Loading…
Reference in New Issue
Block a user