From bde2e5a57704ab64e2734514eefc4738f5a246a2 Mon Sep 17 00:00:00 2001 From: "yingya.shu@easystack.cn" Date: Wed, 26 Oct 2016 16:09:34 +0800 Subject: [PATCH] fix error redirecting of image-register After submitting the "image-register" form in cluster-guide page, page redirects to the index page other than staying in cluster-guide page. This patch fixes related issue. Now it will return to cluster-guide page after registering image. Closes-Bug: 1636880 Change-Id: I6a74e621a688f1021e14f888b1150a46119874a7 --- .../clusters/image_registry/views.py | 2 ++ .../templates/cluster_wizard/cluster_guide.html | 2 +- .../templates/image_registry/_register_image.html | 2 +- .../content/data_processing/clusters/urls.py | 3 +++ .../data_processing/clusters/wizard/views.py | 13 +++++++++++++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/sahara_dashboard/content/data_processing/clusters/image_registry/views.py b/sahara_dashboard/content/data_processing/clusters/image_registry/views.py index c912dc7c..622406a4 100644 --- a/sahara_dashboard/content/data_processing/clusters/image_registry/views.py +++ b/sahara_dashboard/content/data_processing/clusters/image_registry/views.py @@ -95,6 +95,8 @@ class RegisterImageView(forms.ModalFormView): def get_context_data(self, **kwargs): context = super(RegisterImageView, self).get_context_data(**kwargs) + context['action_url'] = ('horizon:project' + ':data_processing.clusters:register') update_context_with_plugin_tags(self.request, context) return context diff --git a/sahara_dashboard/content/data_processing/clusters/templates/cluster_wizard/cluster_guide.html b/sahara_dashboard/content/data_processing/clusters/templates/cluster_wizard/cluster_guide.html index c24de429..a4a5c035 100644 --- a/sahara_dashboard/content/data_processing/clusters/templates/cluster_wizard/cluster_guide.html +++ b/sahara_dashboard/content/data_processing/clusters/templates/cluster_wizard/cluster_guide.html @@ -47,7 +47,7 @@
+ href="{% url 'horizon:project:data_processing.clusters:image_register'%}"> {% trans "Register Image" %}
diff --git a/sahara_dashboard/content/data_processing/clusters/templates/image_registry/_register_image.html b/sahara_dashboard/content/data_processing/clusters/templates/image_registry/_register_image.html index 725d8f03..ae10a257 100644 --- a/sahara_dashboard/content/data_processing/clusters/templates/image_registry/_register_image.html +++ b/sahara_dashboard/content/data_processing/clusters/templates/image_registry/_register_image.html @@ -4,7 +4,7 @@ {% load i18n %} {% block form_id %}register_image_form{% endblock %} -{% block form_action %}{% url 'horizon:project:data_processing.clusters:register' %}{% endblock %} +{% block form_action %}{% url action_url %}{% endblock %} {% block modal-header %}{% trans "Register Image" %}{% endblock %} diff --git a/sahara_dashboard/content/data_processing/clusters/urls.py b/sahara_dashboard/content/data_processing/clusters/urls.py index 6ca36840..1e10860f 100644 --- a/sahara_dashboard/content/data_processing/clusters/urls.py +++ b/sahara_dashboard/content/data_processing/clusters/urls.py @@ -91,6 +91,9 @@ urlpatterns = [url(r'^$', views.IndexView.as_view(), name='index'), url(r'^cluster_guide/(?P[^/]+)/$', cluster_guide_views.ResetClusterGuideView.as_view(), name='reset_cluster_guide'), + url(r'^image_register/$', + cluster_guide_views.ImageRegisterView.as_view(), + name='image_register'), url(r'^plugin_select$', cluster_guide_views.PluginSelectView.as_view(), name='plugin_select'), diff --git a/sahara_dashboard/content/data_processing/clusters/wizard/views.py b/sahara_dashboard/content/data_processing/clusters/wizard/views.py index 22cda3f9..84ab6a1d 100644 --- a/sahara_dashboard/content/data_processing/clusters/wizard/views.py +++ b/sahara_dashboard/content/data_processing/clusters/wizard/views.py @@ -22,6 +22,8 @@ from horizon import views as horizon_views from sahara_dashboard.api import sahara as saharaclient from sahara_dashboard.content.data_processing.utils \ import helpers +import sahara_dashboard.content. \ + data_processing.clusters.image_registry.views as imgviews import sahara_dashboard.content.data_processing.clusters.wizard \ .forms as wizforms @@ -54,6 +56,17 @@ class ResetClusterGuideView(generic.RedirectView): return http.HttpResponseRedirect(reverse_lazy(self.pattern_name)) +class ImageRegisterView(imgviews.RegisterImageView): + success_url = reverse_lazy( + 'horizon:project:data_processing.clusters:cluster_guide') + + def get_context_data(self, **kwargs): + context = super(ImageRegisterView, self).get_context_data(**kwargs) + context['action_url'] = ('horizon:project' + ':data_processing.clusters:image_register') + return context + + class PluginSelectView(forms.ModalFormView): form_class = wizforms.ChoosePluginForm success_url = reverse_lazy(