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
This commit is contained in:
Rob Cresswell 2015-02-18 16:59:11 +00:00
parent 353f14b6eb
commit a85c999901
5 changed files with 37 additions and 84 deletions

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "You may update IKE Policy details here." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:vpn:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% block modal-body-right %}
<h3>{% trans "Description:" %}</h3>
<p>{% trans "You may update IKE Policy details here." %}</p>
{% endblock %}

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "You may update IPSec Policy details here." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:vpn:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% block modal-body-right %}
<h3>{% trans "Description:" %}</h3>
<p>{% trans "You may update IPSec Policy details here." %}</p>
{% endblock %}

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "You may update IPSec Site Connection details here." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:vpn:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% block modal-body-right %}
<h3>{% trans "Description:" %}</h3>
<p>{% trans "You may update IPSec Site Connection details here." %}</p>
{% endblock %}

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "You may update VPN Service details here." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:vpn:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% block modal-body-right %}
<h3>{% trans "Description:" %}</h3>
<p>{% trans "You may update VPN Service details here." %}</p>
{% endblock %}

View File

@ -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