From a85c99990133b1e98291336c8ea1de2bec1a79a9 Mon Sep 17 00:00:00 2001 From: Rob Cresswell Date: Wed, 18 Feb 2015 16:59:11 +0000 Subject: [PATCH] Refactor modal forms for VPN Refactor of VPN modals Based on merged patch: https://review.openstack.org/#/c/123472/ Change-Id: I8e5b0cd1c0c461cae9ccd9b954de01596ab614d5 Partially-Implements: blueprint form-template-to-view --- .../vpn/templates/vpn/_update_ikepolicy.html | 24 +++--------------- .../templates/vpn/_update_ipsecpolicy.html | 24 +++--------------- .../vpn/_update_ipsecsiteconnection.html | 24 +++--------------- .../vpn/templates/vpn/_update_vpnservice.html | 24 +++--------------- .../dashboards/project/vpn/views.py | 25 +++++++++++++++++++ 5 files changed, 37 insertions(+), 84 deletions(-) diff --git a/openstack_dashboard/dashboards/project/vpn/templates/vpn/_update_ikepolicy.html b/openstack_dashboard/dashboards/project/vpn/templates/vpn/_update_ikepolicy.html index 2deef3cf2b..14c3bf2916 100644 --- a/openstack_dashboard/dashboards/project/vpn/templates/vpn/_update_ikepolicy.html +++ b/openstack_dashboard/dashboards/project/vpn/templates/vpn/_update_ikepolicy.html @@ -1,25 +1,7 @@ {% extends "horizon/common/_modal_form.html" %} {% load i18n %} -{% load url from future %} -{% block form_id %}update_ikepolicy_form{% endblock %} -{% block form_action %}{% url 'horizon:project:vpn:update_ikepolicy' ikepolicy_id %}{% endblock %} - -{% block modal-header %}{% trans "Edit IKE Policy" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "You may update IKE Policy details here." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} +{% block modal-body-right %} +

{% trans "Description:" %}

+

{% trans "You may update IKE Policy details here." %}

{% endblock %} diff --git a/openstack_dashboard/dashboards/project/vpn/templates/vpn/_update_ipsecpolicy.html b/openstack_dashboard/dashboards/project/vpn/templates/vpn/_update_ipsecpolicy.html index 5fdc35fa4a..848fe6a749 100644 --- a/openstack_dashboard/dashboards/project/vpn/templates/vpn/_update_ipsecpolicy.html +++ b/openstack_dashboard/dashboards/project/vpn/templates/vpn/_update_ipsecpolicy.html @@ -1,25 +1,7 @@ {% extends "horizon/common/_modal_form.html" %} {% load i18n %} -{% load url from future %} -{% block form_id %}update_ipsecpolicy_form{% endblock %} -{% block form_action %}{% url 'horizon:project:vpn:update_ipsecpolicy' ipsecpolicy_id %}{% endblock %} - -{% block modal-header %}{% trans "Edit IPSec Policy" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "You may update IPSec Policy details here." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} +{% block modal-body-right %} +

{% trans "Description:" %}

+

{% trans "You may update IPSec Policy details here." %}

{% endblock %} diff --git a/openstack_dashboard/dashboards/project/vpn/templates/vpn/_update_ipsecsiteconnection.html b/openstack_dashboard/dashboards/project/vpn/templates/vpn/_update_ipsecsiteconnection.html index 5a286511db..025c9c5740 100644 --- a/openstack_dashboard/dashboards/project/vpn/templates/vpn/_update_ipsecsiteconnection.html +++ b/openstack_dashboard/dashboards/project/vpn/templates/vpn/_update_ipsecsiteconnection.html @@ -1,25 +1,7 @@ {% extends "horizon/common/_modal_form.html" %} {% load i18n %} -{% load url from future %} -{% block form_id %}update_ipsecsiteconnection_form{% endblock %} -{% block form_action %}{% url 'horizon:project:vpn:update_ipsecsiteconnection' ipsecsiteconnection_id %}{% endblock %} - -{% block modal-header %}{% trans "Edit IPSec Site Connection" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "You may update IPSec Site Connection details here." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} +{% block modal-body-right %} +

{% trans "Description:" %}

+

{% trans "You may update IPSec Site Connection details here." %}

{% endblock %} diff --git a/openstack_dashboard/dashboards/project/vpn/templates/vpn/_update_vpnservice.html b/openstack_dashboard/dashboards/project/vpn/templates/vpn/_update_vpnservice.html index 69466199fb..225ad467be 100644 --- a/openstack_dashboard/dashboards/project/vpn/templates/vpn/_update_vpnservice.html +++ b/openstack_dashboard/dashboards/project/vpn/templates/vpn/_update_vpnservice.html @@ -1,25 +1,7 @@ {% extends "horizon/common/_modal_form.html" %} {% load i18n %} -{% load url from future %} -{% block form_id %}update_vpnservice_form{% endblock %} -{% block form_action %}{% url 'horizon:project:vpn:update_vpnservice' vpnservice_id %}{% endblock %} - -{% block modal-header %}{% trans "Edit VPN Service" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "You may update VPN Service details here." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} +{% block modal-body-right %} +

{% trans "Description:" %}

+

{% trans "You may update VPN Service details here." %}

{% endblock %} diff --git a/openstack_dashboard/dashboards/project/vpn/views.py b/openstack_dashboard/dashboards/project/vpn/views.py index 1db12bc8dc..e3c72f12ee 100644 --- a/openstack_dashboard/dashboards/project/vpn/views.py +++ b/openstack_dashboard/dashboards/project/vpn/views.py @@ -12,6 +12,7 @@ # 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 _ @@ -264,13 +265,19 @@ class IPSecSiteConnectionDetailsView(tabs.TabView): class UpdateVPNServiceView(forms.ModalFormView): form_class = vpn_forms.UpdateVPNService + form_id = "update_vpnservice_form" + modal_header = _("Edit VPN Service") template_name = "project/vpn/update_vpnservice.html" context_object_name = 'vpnservice' + submit_label = _("Save Changes") + submit_url = "horizon:project:vpn:update_vpnservice" success_url = reverse_lazy("horizon:project:vpn:index") def get_context_data(self, **kwargs): context = super(UpdateVPNServiceView, self).get_context_data(**kwargs) context["vpnservice_id"] = self.kwargs['vpnservice_id'] + args = (self.kwargs['vpnservice_id'],) + context['submit_url'] = reverse(self.submit_url, args=args) return context @memoized.memoized_method @@ -293,13 +300,19 @@ class UpdateVPNServiceView(forms.ModalFormView): class UpdateIKEPolicyView(forms.ModalFormView): form_class = vpn_forms.UpdateIKEPolicy + form_id = "update_ikepolicy_form" + modal_header = _("Edit IKE Policy") template_name = "project/vpn/update_ikepolicy.html" context_object_name = 'ikepolicy' + submit_label = _("Save Changes") + submit_url = "horizon:project:vpn:update_ikepolicy" success_url = reverse_lazy("horizon:project:vpn:index") def get_context_data(self, **kwargs): context = super(UpdateIKEPolicyView, self).get_context_data(**kwargs) context["ikepolicy_id"] = self.kwargs['ikepolicy_id'] + args = (self.kwargs['ikepolicy_id'],) + context['submit_url'] = reverse(self.submit_url, args=args) return context @memoized.memoized_method @@ -329,13 +342,19 @@ class UpdateIKEPolicyView(forms.ModalFormView): class UpdateIPSecPolicyView(forms.ModalFormView): form_class = vpn_forms.UpdateIPSecPolicy + form_id = "update_ipsecpolicy_form" + modal_header = _("Edit IPSec Policy") template_name = "project/vpn/update_ipsecpolicy.html" context_object_name = 'ipsecpolicy' + submit_label = _("Save Changes") + submit_url = "horizon:project:vpn:update_ipsecpolicy" success_url = reverse_lazy("horizon:project:vpn:index") def get_context_data(self, **kwargs): context = super(UpdateIPSecPolicyView, self).get_context_data(**kwargs) context["ipsecpolicy_id"] = self.kwargs['ipsecpolicy_id'] + args = (self.kwargs['ipsecpolicy_id'],) + context['submit_url'] = reverse(self.submit_url, args=args) return context @memoized.memoized_method @@ -364,8 +383,12 @@ class UpdateIPSecPolicyView(forms.ModalFormView): class UpdateIPSecSiteConnectionView(forms.ModalFormView): form_class = vpn_forms.UpdateIPSecSiteConnection + form_id = "update_ipsecsiteconnection_form" + modal_header = _("Edit IPSec Site Connection") template_name = "project/vpn/update_ipsecsiteconnection.html" context_object_name = 'ipsecsiteconnection' + submit_label = _("Save Changes") + submit_url = "horizon:project:vpn:update_ipsecsiteconnection" success_url = reverse_lazy("horizon:project:vpn:index") def get_context_data(self, **kwargs): @@ -373,6 +396,8 @@ class UpdateIPSecSiteConnectionView(forms.ModalFormView): UpdateIPSecSiteConnectionView, self).get_context_data(**kwargs) context["ipsecsiteconnection_id"] = self.kwargs[ 'ipsecsiteconnection_id'] + args = (self.kwargs['ipsecsiteconnection_id'],) + context['submit_url'] = reverse(self.submit_url, args=args) return context @memoized.memoized_method