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