diff --git a/openstack_dashboard/dashboards/project/volumes/forms.py b/openstack_dashboard/dashboards/project/volumes/forms.py index ad336a90f9..4efe2b1196 100644 --- a/openstack_dashboard/dashboards/project/volumes/forms.py +++ b/openstack_dashboard/dashboards/project/volumes/forms.py @@ -20,7 +20,6 @@ Views for managing volumes. from django.conf import settings from django.core.urlresolvers import reverse from django.forms import ValidationError -from django import http from django.template.defaultfilters import filesizeformat from django.utils.translation import pgettext_lazy from django.utils.translation import ugettext_lazy as _ @@ -549,6 +548,10 @@ class CreateSnapshotForm(forms.SelfHandlingForm): class CreateTransferForm(forms.SelfHandlingForm): name = forms.CharField(max_length=255, label=_("Transfer Name")) + def __init__(self, *args, **kwargs): + self.next_view = kwargs.pop('next_view', None) + super(CreateTransferForm, self).__init__(*args, **kwargs) + def clean_name(self): cleaned_name = self.cleaned_data['name'] if cleaned_name.isspace(): @@ -564,10 +567,12 @@ class CreateTransferForm(forms.SelfHandlingForm): msg = _('Created volume transfer: "%s".') % data['name'] messages.success(request, msg) - response = http.HttpResponseRedirect( - reverse("horizon:project:volumes:show_transfer", - args=(transfer.id, transfer.auth_key))) - return response + kwargs = { + 'transfer_id': transfer.id, + 'auth_key': transfer.auth_key + } + request.method = 'GET' + return self.next_view.as_view()(request, **kwargs) except Exception: redirect = reverse("horizon:project:volumes:index") exceptions.handle(request, _('Unable to create volume transfer.'), diff --git a/openstack_dashboard/dashboards/project/volumes/templates/volumes/_show_transfer.html b/openstack_dashboard/dashboards/project/volumes/templates/volumes/_show_transfer.html index 947f4be5a6..2a9a687177 100644 --- a/openstack_dashboard/dashboards/project/volumes/templates/volumes/_show_transfer.html +++ b/openstack_dashboard/dashboards/project/volumes/templates/volumes/_show_transfer.html @@ -1,6 +1,11 @@ {% extends "horizon/common/_modal_form.html" %} {% load i18n %} +{% block header %} + +{% endblock %} {% block modal-body-right %}

{% trans "Description:" %}

{% trans "The Transfer ID and the Authorization Key are needed by the recipient in order to accept the transfer. Please capture both the Transfer ID and the Authorization Key and provide them to your transfer recipient." %}

@@ -11,8 +16,5 @@ {{ download_label }} - - {{ cancel_label }} - + {{ cancel_label }} {% endblock %} diff --git a/openstack_dashboard/dashboards/project/volumes/tests.py b/openstack_dashboard/dashboards/project/volumes/tests.py index e8767ae5c3..bff5b9895d 100644 --- a/openstack_dashboard/dashboards/project/volumes/tests.py +++ b/openstack_dashboard/dashboards/project/volumes/tests.py @@ -1775,14 +1775,17 @@ class VolumeViewTests(test.ResetImageAPIVersionMixin, test.TestCase): search_opts=None) self.assertEqual(10, mock_limits.call_count) + @mock.patch.object(cinder, 'transfer_get') @mock.patch.object(cinder, 'transfer_create') - def test_create_transfer(self, mock_transfer): + def test_create_transfer(self, mock_transfer_create, mock_transfer_get): volumes = self.volumes.list() volToTransfer = [v for v in volumes if v.status == 'available'][0] formData = {'volume_id': volToTransfer.id, 'name': u'any transfer name'} - mock_transfer.return_value = self.cinder_volume_transfers.first() + transfer = self.cinder_volume_transfers.first() + mock_transfer_create.return_value = transfer + mock_transfer_get.return_value = transfer # Create a transfer for the first available volume url = reverse('horizon:project:volumes:create_transfer', @@ -1790,9 +1793,11 @@ class VolumeViewTests(test.ResetImageAPIVersionMixin, test.TestCase): res = self.client.post(url, formData) self.assertNoFormErrors(res) - mock_transfer.assert_called_once_with(test.IsHttpRequest(), - formData['volume_id'], - formData['name']) + mock_transfer_create.assert_called_once_with(test.IsHttpRequest(), + formData['volume_id'], + formData['name']) + mock_transfer_get.assert_called_once_with(test.IsHttpRequest(), + transfer.id) @mock.patch.object(api.nova, 'server_list') @mock.patch.object(cinder, 'volume_backup_supported') diff --git a/openstack_dashboard/dashboards/project/volumes/views.py b/openstack_dashboard/dashboards/project/volumes/views.py index f1f2c14be0..209447fb50 100644 --- a/openstack_dashboard/dashboards/project/volumes/views.py +++ b/openstack_dashboard/dashboards/project/volumes/views.py @@ -378,6 +378,11 @@ class CreateTransferView(forms.ModalFormView): def get_initial(self): return {'volume_id': self.kwargs["volume_id"]} + def get_form_kwargs(self): + kwargs = super(CreateTransferView, self).get_form_kwargs() + kwargs['next_view'] = ShowTransferView + return kwargs + class AcceptTransferView(forms.ModalFormView): form_class = volume_forms.AcceptTransferForm @@ -395,6 +400,7 @@ class ShowTransferView(forms.ModalFormView): template_name = 'project/volumes/show_transfer.html' success_url = reverse_lazy('horizon:project:volumes:index') modal_id = "show_volume_transfer_modal" + modal_header = _("Volume Transfer") submit_url = "horizon:project:volumes:show_transfer" cancel_label = _("Close") download_label = _("Download transfer credentials") @@ -416,8 +422,6 @@ class ShowTransferView(forms.ModalFormView): context = super(ShowTransferView, self).get_context_data(**kwargs) context['transfer_id'] = self.kwargs['transfer_id'] context['auth_key'] = self.kwargs['auth_key'] - context['submit_url'] = reverse(self.submit_url, args=[ - context['transfer_id'], context['auth_key']]) context['download_label'] = self.download_label context['download_url'] = reverse( 'horizon:project:volumes:download_transfer_creds', diff --git a/openstack_dashboard/static/dashboard/scss/components/_messages.scss b/openstack_dashboard/static/dashboard/scss/components/_messages.scss index 8ed42c2a4b..73a169838a 100644 --- a/openstack_dashboard/static/dashboard/scss/components/_messages.scss +++ b/openstack_dashboard/static/dashboard/scss/components/_messages.scss @@ -1,6 +1,6 @@ .messages { position: fixed; - z-index: $zindex-dropdown + 1; + z-index: $zindex-dropdown + 52; padding-top: $padding-small-vertical; right: $padding-large-horizontal; // TODO (hurgleburlger) RESPONSIVE