diff --git a/openstack_dashboard/dashboards/admin/volumes/snapshots/forms.py b/openstack_dashboard/dashboards/admin/volumes/snapshots/forms.py index e860b8c3b7..7205cfe6ba 100644 --- a/openstack_dashboard/dashboards/admin/volumes/snapshots/forms.py +++ b/openstack_dashboard/dashboards/admin/volumes/snapshots/forms.py @@ -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) diff --git a/openstack_dashboard/dashboards/admin/volumes/volume_types/extras/forms.py b/openstack_dashboard/dashboards/admin/volumes/volume_types/extras/forms.py index c253b8cf8f..f3d9ef3c99 100644 --- a/openstack_dashboard/dashboards/admin/volumes/volume_types/extras/forms.py +++ b/openstack_dashboard/dashboards/admin/volumes/volume_types/extras/forms.py @@ -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) diff --git a/openstack_dashboard/dashboards/admin/volumes/volume_types/forms.py b/openstack_dashboard/dashboards/admin/volumes/volume_types/forms.py index 94f683e8b0..d5e4865fd1 100644 --- a/openstack_dashboard/dashboards/admin/volumes/volume_types/forms.py +++ b/openstack_dashboard/dashboards/admin/volumes/volume_types/forms.py @@ -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) diff --git a/openstack_dashboard/dashboards/admin/volumes/volume_types/qos_specs/forms.py b/openstack_dashboard/dashboards/admin/volumes/volume_types/qos_specs/forms.py index b2e5a7c662..acc4492ec5 100644 --- a/openstack_dashboard/dashboards/admin/volumes/volume_types/qos_specs/forms.py +++ b/openstack_dashboard/dashboards/admin/volumes/volume_types/qos_specs/forms.py @@ -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) diff --git a/openstack_dashboard/dashboards/admin/volumes/volumes/forms.py b/openstack_dashboard/dashboards/admin/volumes/volumes/forms.py index 49993e6bcc..aa2f752e29 100644 --- a/openstack_dashboard/dashboards/admin/volumes/volumes/forms.py +++ b/openstack_dashboard/dashboards/admin/volumes/volumes/forms.py @@ -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) diff --git a/openstack_dashboard/dashboards/project/volumes/backups/forms.py b/openstack_dashboard/dashboards/project/volumes/backups/forms.py index eed156deec..e703dec1d5 100644 --- a/openstack_dashboard/dashboards/project/volumes/backups/forms.py +++ b/openstack_dashboard/dashboards/project/volumes/backups/forms.py @@ -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) diff --git a/openstack_dashboard/dashboards/project/volumes/volumes/forms.py b/openstack_dashboard/dashboards/project/volumes/volumes/forms.py index 2d281153e6..74fd1e1432 100644 --- a/openstack_dashboard/dashboards/project/volumes/volumes/forms.py +++ b/openstack_dashboard/dashboards/project/volumes/volumes/forms.py @@ -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)