From e306291c614e6f8b85bbc252a3f6279cca68a23f Mon Sep 17 00:00:00 2001 From: Tatiana Ovchinnikova Date: Fri, 1 Jul 2016 12:00:47 +0300 Subject: [PATCH] Some tweaks for modal forms The clean up for the recent blueprint changes. Adds some missing attributes for View classes and replaces some redundant get_success_url methods with proper success urls. Change-Id: I724f8c02afe7108ea06b0b8c1cfa1168159fcb00 Implements: blueprint form-templates --- manila_ui/dashboards/admin/share_types/views.py | 6 ++---- .../admin/shares/templates/shares/_manage_share.html | 1 - .../shares/templates/shares/_unmanage_share.html | 1 - manila_ui/dashboards/admin/shares/views.py | 12 ++++++------ .../dashboards/project/security_services/views.py | 10 ++-------- manila_ui/dashboards/project/share_networks/views.py | 7 ++----- 6 files changed, 12 insertions(+), 25 deletions(-) diff --git a/manila_ui/dashboards/admin/share_types/views.py b/manila_ui/dashboards/admin/share_types/views.py index 93370df8..39d0a66d 100644 --- a/manila_ui/dashboards/admin/share_types/views.py +++ b/manila_ui/dashboards/admin/share_types/views.py @@ -57,14 +57,12 @@ class CreateShareTypeView(forms.ModalFormView): form_id = "create_share_type" template_name = 'admin/share_types/create.html' modal_header = _("Create Share Type") + modal_id = "create_share_type_modal" submit_label = _("Create") submit_url = reverse_lazy("horizon:admin:share_types:create_type") - success_url = 'horizon:admin:share_types:index' + success_url = reverse_lazy('horizon:admin:share_types:index') page_title = _("Create Share Type") - def get_success_url(self): - return reverse(self.success_url) - class ManageShareTypeAccessView(workflows.WorkflowView): workflow_class = st_workflows.ManageShareTypeAccessWorkflow diff --git a/manila_ui/dashboards/admin/shares/templates/shares/_manage_share.html b/manila_ui/dashboards/admin/shares/templates/shares/_manage_share.html index f6018243..866913d2 100644 --- a/manila_ui/dashboards/admin/shares/templates/shares/_manage_share.html +++ b/manila_ui/dashboards/admin/shares/templates/shares/_manage_share.html @@ -1,6 +1,5 @@ {% extends "horizon/common/_modal_form.html" %} {% load i18n %} - {% block modal-body-right %}

{% trans "Description:" %}

{% blocktrans %} diff --git a/manila_ui/dashboards/admin/shares/templates/shares/_unmanage_share.html b/manila_ui/dashboards/admin/shares/templates/shares/_unmanage_share.html index 430816b1..e4bc090e 100644 --- a/manila_ui/dashboards/admin/shares/templates/shares/_unmanage_share.html +++ b/manila_ui/dashboards/admin/shares/templates/shares/_unmanage_share.html @@ -1,6 +1,5 @@ {% extends "horizon/common/_modal_form.html" %} {% load i18n %} - {% block modal-body-right %}

{% trans "Description:" %}

{% blocktrans %} diff --git a/manila_ui/dashboards/admin/shares/views.py b/manila_ui/dashboards/admin/shares/views.py index c2004910..289450fc 100644 --- a/manila_ui/dashboards/admin/shares/views.py +++ b/manila_ui/dashboards/admin/shares/views.py @@ -78,14 +78,14 @@ class DetailView(share_views.DetailView): class ManageShareView(forms.ModalFormView): form_class = project_forms.ManageShare + form_id = "manage_share" template_name = 'admin/shares/manage_share.html' modal_header = _("Manage Share") - form_id = "manage_share_modal" + modal_id = "manage_share_modal" submit_label = _("Manage") success_url = reverse_lazy('horizon:admin:shares:index') submit_url = reverse_lazy('horizon:admin:shares:manage') - cancel_url = reverse_lazy('horizon:admin:shares:index') - page_title = _("Manage a Share") + page_title = _("Manage Share") def get_context_data(self, **kwargs): context = super(ManageShareView, self).get_context_data(**kwargs) @@ -243,14 +243,14 @@ class MigrationGetProgressView(forms.ModalFormView): class UnmanageShareView(forms.ModalFormView): form_class = project_forms.UnmanageShare + form_id = "unmanage_share" template_name = 'admin/shares/unmanage_share.html' modal_header = _("Confirm Unmanage Share") - form_id = "unmanage_share_modal" + modal_id = "unmanage_share_modal" submit_label = _("Unmanage") success_url = reverse_lazy('horizon:admin:shares:index') submit_url = 'horizon:admin:shares:unmanage' - cancel_url = reverse_lazy('horizon:admin:shares:index') - page_title = _("Unmanage a Share") + page_title = _("Unmanage Share") def get_context_data(self, **kwargs): context = super(UnmanageShareView, self).get_context_data(**kwargs) diff --git a/manila_ui/dashboards/project/security_services/views.py b/manila_ui/dashboards/project/security_services/views.py index 5ee9aaf5..f1267f84 100644 --- a/manila_ui/dashboards/project/security_services/views.py +++ b/manila_ui/dashboards/project/security_services/views.py @@ -56,12 +56,9 @@ class UpdateView(forms.ModalFormView): modal_id = "update_security_service_modal" submit_label = _("Edit") submit_url = "horizon:project:security_services:security_service_update" - success_url = 'horizon:project:security_services:index' + success_url = reverse_lazy("horizon:project:security_services:index") page_title = _('Edit Security Service') - def get_success_url(self): - return reverse(self.success_url) - def get_object(self): if not hasattr(self, "_object"): sec_service_id = self.kwargs['sec_service_id'] @@ -95,12 +92,9 @@ class CreateView(forms.ModalFormView): submit_label = _("Create") submit_url = reverse_lazy( "horizon:project:security_services:security_service_create") - success_url = 'horizon:project:security_services:index' + success_url = reverse_lazy("horizon:project:security_services:index") page_title = _('Create Security Service') - def get_success_url(self): - return reverse(self.success_url) - class AddSecurityServiceView(forms.ModalFormView): form_class = sn_forms.AddSecurityServiceForm diff --git a/manila_ui/dashboards/project/share_networks/views.py b/manila_ui/dashboards/project/share_networks/views.py index ad00d7c8..01a9fe1f 100644 --- a/manila_ui/dashboards/project/share_networks/views.py +++ b/manila_ui/dashboards/project/share_networks/views.py @@ -12,7 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse_lazy from django.utils.translation import ugettext_lazy as _ from horizon import exceptions @@ -82,15 +81,13 @@ class Create(forms.ModalFormView): form_id = "create_share_network" template_name = 'project/share_networks/create.html' modal_header = _("Create Share Network") + modal_id = "create_share_network_modal" submit_label = _("Create") submit_url = reverse_lazy( "horizon:project:share_networks:share_network_create") - success_url = 'horizon:project:share_networks:index' + success_url = reverse_lazy("horizon:project:share_networks:index") page_title = _('Create Share Network') - def get_success_url(self): - return reverse(self.success_url) - class Detail(tabs.TabView): tab_group_class = sn_tabs.ShareNetworkDetailTabs