diff --git a/gbpui/common/forms.py b/gbpui/common/forms.py
index 09473a5..e99874f 100644
--- a/gbpui/common/forms.py
+++ b/gbpui/common/forms.py
@@ -31,3 +31,10 @@ class ReversingModalFormView(forms.ModalFormView):
submit_params = self.get_submit_url_params(**kwargs)
submit_url = reverse(self.submit_url, kwargs=submit_params)
return submit_url
+
+
+class HelpTextModalMixin(object):
+ def get_context_data(self, **kwargs):
+ context = super(HelpTextModalMixin, self).get_context_data(**kwargs)
+ context["help_text"] = self.help_text
+ return context
diff --git a/gbpui/panels/application_policy/templates/application_policy/_add_policy_action.html b/gbpui/panels/application_policy/templates/application_policy/_add_policy_action.html
deleted file mode 100644
index f07ae3d..0000000
--- a/gbpui/panels/application_policy/templates/application_policy/_add_policy_action.html
+++ /dev/null
@@ -1,25 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}add_policy_action_form{% endblock %}
-{% block form_action %}{% url "horizon:project:application_policy:addpolicyaction" %}{% endblock %}
-
-{% block modal_id %}add_policy_action_modal{% endblock %}
-{% block modal-header %}{% trans "Create Policy Action" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description" %}:
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/application_policy/templates/application_policy/_add_policy_classifier.html b/gbpui/panels/application_policy/templates/application_policy/_add_policy_classifier.html
deleted file mode 100644
index feedad6..0000000
--- a/gbpui/panels/application_policy/templates/application_policy/_add_policy_classifier.html
+++ /dev/null
@@ -1,30 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}add_policy_classifier_form{% endblock %}
-{% block form_action %}{% url "horizon:project:application_policy:addpolicyclassifier" %}{% endblock %}
-
-{% block modal_id %}add_policy_classifier_modal{% endblock %}
-{% block modal-header %}{% trans "Create Policy Classifier" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description" %}:
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
-
-
-{% block modal-js %}
-
-{% endblock %}
diff --git a/gbpui/panels/application_policy/templates/application_policy/_policyaction_details.html b/gbpui/panels/application_policy/templates/application_policy/_policyaction_details.html
index da05417..e70d08f 100644
--- a/gbpui/panels/application_policy/templates/application_policy/_policyaction_details.html
+++ b/gbpui/panels/application_policy/templates/application_policy/_policyaction_details.html
@@ -16,7 +16,7 @@
{% trans "Project ID" %}
{{ policyaction.tenant_id }}
- {% trans "Action Value" %}
+ {% trans "Action Value" %}
{{ policyaction.action_value|default:_("-") }}
{% trans "Action Type" %}
diff --git a/gbpui/panels/application_policy/templates/application_policy/_update_policy_action.html b/gbpui/panels/application_policy/templates/application_policy/_update_policy_action.html
deleted file mode 100644
index ba299ef..0000000
--- a/gbpui/panels/application_policy/templates/application_policy/_update_policy_action.html
+++ /dev/null
@@ -1,25 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}update_policy_action_form{% endblock %}
-{% block form_action %}{% url "horizon:project:application_policy:updatepolicyaction" policyaction_id %}{% endblock %}
-
-{% block modal_id %}update_policy_action_modal{% endblock %}
-{% block modal-header %}{% trans "Edit Policy Action" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description" %}:
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/application_policy/templates/application_policy/_update_policy_classifier.html b/gbpui/panels/application_policy/templates/application_policy/_update_policy_classifier.html
deleted file mode 100644
index 8b6efad..0000000
--- a/gbpui/panels/application_policy/templates/application_policy/_update_policy_classifier.html
+++ /dev/null
@@ -1,29 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}update_policy_classifier_form{% endblock %}
-{% block form_action %}{% url "horizon:project:application_policy:updatepolicyclassifier" policyclassifier_id %}{% endblock %}
-
-{% block modal_id %}update_policy_classifier_modal{% endblock %}
-{% block modal-header %}{% trans "Edit Policy Classifier" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description" %}:
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
-
-{% block modal-js %}
-
-{% endblock %}
diff --git a/gbpui/panels/application_policy/templates/application_policy/_update_policy_rule.html b/gbpui/panels/application_policy/templates/application_policy/_update_policy_rule.html
deleted file mode 100644
index 4756a68..0000000
--- a/gbpui/panels/application_policy/templates/application_policy/_update_policy_rule.html
+++ /dev/null
@@ -1,25 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}update_policy_rule_form{% endblock %}
-{% block form_action %}{% url "horizon:project:application_policy:updatepolicyrule" policyrule_id %}{% endblock %}
-
-{% block modal_id %}update_policy_rule_modal{% endblock %}
-{% block modal-header %}{% trans "Edit Policy Rule" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description" %}:
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/application_policy/templates/application_policy/_update_policy_rule_set.html b/gbpui/panels/application_policy/templates/application_policy/_update_policy_rule_set.html
deleted file mode 100644
index 3a3e4cd..0000000
--- a/gbpui/panels/application_policy/templates/application_policy/_update_policy_rule_set.html
+++ /dev/null
@@ -1,26 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}update_policy_rule_set_form{% endblock %}
-{% block form_action %}{% url "horizon:project:application_policy:updatepolicy_rule_set" policy_rule_set_id %}{% endblock %}
-
-{% block modal_id %}update_policy_rule_set_modal{% endblock %}
-{% block modal-header %}{% trans "Edit Policy Rule Set" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description" %}:
-
{% trans "Select one or multiple rules by pressing Ctrl" %}
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/application_policy/templates/application_policy/addpolicy_rule_set.html b/gbpui/panels/application_policy/templates/application_policy/addpolicy_rule_set.html
deleted file mode 100644
index b25277a..0000000
--- a/gbpui/panels/application_policy/templates/application_policy/addpolicy_rule_set.html
+++ /dev/null
@@ -1,11 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n %}
-{% block title %}{% trans "Create Policy Rule Set" %}{% endblock %}
-
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=_("Create Policy Rule Set") %}
-{% endblock page_header %}
-
-{% block main %}
- {% include 'horizon/common/_workflow.html' %}
-{% endblock %}
diff --git a/gbpui/panels/application_policy/templates/application_policy/addpolicyaction.html b/gbpui/panels/application_policy/templates/application_policy/addpolicyaction.html
deleted file mode 100644
index 2834cc1..0000000
--- a/gbpui/panels/application_policy/templates/application_policy/addpolicyaction.html
+++ /dev/null
@@ -1,11 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n %}
-{% block title %}{% trans "Create New Action" %}{% endblock %}
-
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=_("Create New Action") %}
-{% endblock page_header %}
-
-{% block main %}
- {% include 'horizon/common/_workflow.html' %}
-{% endblock %}
diff --git a/gbpui/panels/application_policy/templates/application_policy/addpolicyclassifier.html b/gbpui/panels/application_policy/templates/application_policy/addpolicyclassifier.html
deleted file mode 100644
index 4e7492c..0000000
--- a/gbpui/panels/application_policy/templates/application_policy/addpolicyclassifier.html
+++ /dev/null
@@ -1,11 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n %}
-{% block title %}{% trans "Create New Classifier" %}{% endblock %}
-
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=_("Create New Classifier") %}
-{% endblock page_header %}
-
-{% block main %}
- {% include 'horizon/common/_workflow.html' %}
-{% endblock %}
diff --git a/gbpui/panels/application_policy/templates/application_policy/addpolicyrule.html b/gbpui/panels/application_policy/templates/application_policy/addpolicyrule.html
deleted file mode 100644
index 23148c2..0000000
--- a/gbpui/panels/application_policy/templates/application_policy/addpolicyrule.html
+++ /dev/null
@@ -1,11 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n %}
-{% block title %}{% trans "Create New Policy Rule Set" %}{% endblock %}
-
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=_("Create New Policy Rule Set") %}
-{% endblock page_header %}
-
-{% block main %}
- {% include 'horizon/common/_workflow.html' %}
-{% endblock %}
diff --git a/gbpui/panels/application_policy/templates/application_policy/details_tabs.html b/gbpui/panels/application_policy/templates/application_policy/details_tabs.html
deleted file mode 100644
index 32a19a5..0000000
--- a/gbpui/panels/application_policy/templates/application_policy/details_tabs.html
+++ /dev/null
@@ -1,15 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n %}
-{% block title %}{% trans "Application Policies" %}{% endblock %}
-
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=_("Application Policies") %}
-{% endblock page_header %}
-
-{% block main %}
-
-
- {{ tab_group.render }}
-
-
-{% endblock %}
diff --git a/gbpui/panels/application_policy/views.py b/gbpui/panels/application_policy/views.py
index 705de07..91f368d 100644
--- a/gbpui/panels/application_policy/views.py
+++ b/gbpui/panels/application_policy/views.py
@@ -11,7 +11,6 @@
# under the License.
from django.core.urlresolvers import reverse
-from horizon import forms
from horizon import tabs
from horizon import workflows
@@ -19,6 +18,9 @@ import forms as policy_rule_set_forms
import tabs as policy_rule_set_tabs
import workflows as policy_rule_set_workflows
+from django.utils.translation import ugettext_lazy as _
+from gbpui.common import forms as gbforms
+
PolicyRuleSetTabs = policy_rule_set_tabs.ApplicationPoliciesTabs
PolicyRuleSetDetailsTabs = policy_rule_set_tabs.PolicyRuleSetDetailsTabs
PolicyRuleDetailsTabs = policy_rule_set_tabs.PolicyRuleDetailsTabs
@@ -31,26 +33,26 @@ AddPolicyClassifier = policy_rule_set_workflows.AddPolicyClassifier
class IndexView(tabs.TabbedTableView):
tab_group_class = (PolicyRuleSetTabs)
- template_name = 'project/application_policy/details_tabs.html'
+ template_name = "gbpui/details_tabs.html"
+ page_title = _("Application Policies")
class AddPolicyRuleSetView(workflows.WorkflowView):
workflow_class = AddPolicyRuleSet
- template_name = "project/application_policy/addpolicy_rule_set.html"
-
- def get_object_id(self, policy_rule_set):
- return [policy_rule_set.id]
-class UpdatePolicyRuleSetView(forms.ModalFormView):
+class UpdatePolicyRuleSetView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = policy_rule_set_forms.UpdatePolicyRuleSetForm
- template_name = 'project/application_policy/update_policy_rule_set.html'
+ modal_header = _("Edit Policy Rule Set")
+ submit_label = _("Update Policy Rule Set")
+ submit_url = "horizon:project:application_policy:updatepolicy_rule_set"
+ template_name = "gbpui/form_with_description.html"
+ page_title = _("Update Rule Set")
+ help_text = _("Update Rule Set.")
- def get_context_data(self, **kwargs):
- context = super(
- UpdatePolicyRuleSetView, self).get_context_data(**kwargs)
- context['policy_rule_set_id'] = self.kwargs['policy_rule_set_id']
- return context
+ def get_submit_url_params(self, **kwargs):
+ return {"policy_rule_set_id": self.kwargs['policy_rule_set_id']}
def get_initial(self):
return {'policy_rule_set_id': self.kwargs['policy_rule_set_id']}
@@ -58,15 +60,17 @@ class UpdatePolicyRuleSetView(forms.ModalFormView):
class AddPolicyRuleView(workflows.WorkflowView):
workflow_class = AddPolicyRule
- template_name = "project/application_policy/addpolicyrule.html"
-
- def get_object_id(self, rule):
- return [rule.id]
-class AddPolicyClassifierView(forms.ModalFormView):
+class AddPolicyClassifierView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = policy_rule_set_forms.AddPolicyClassifierForm
- template_name = "project/application_policy/add_policy_classifier.html"
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:application_policy:addpolicyclassifier"
+ modal_header = _("Create Policy Classifier")
+ page_title = _("Create Policy Classifier")
+ help_text = _("Create Policy Classifier.")
+ submit_label = _("Save Changes")
def get_success_url(self):
return reverse('horizon:project:application_policy:index')
@@ -75,26 +79,32 @@ class AddPolicyClassifierView(forms.ModalFormView):
return [classifier.id]
-class AddPolicyActionView(forms.ModalFormView):
+class AddPolicyActionView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = policy_rule_set_forms.AddPolicyActionForm
- template_name = "project/application_policy/add_policy_action.html"
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:application_policy:addpolicyaction"
+ modal_header = _("Create Policy Action")
+ page_title = _("Create Policy Action")
+ submit_label = _("Create")
+ help_text = _("Create Policy Action.")
def get_success_url(self):
return reverse('horizon:project:application_policy:index')
- def get_object_id(self, policyaction):
- return [policyaction.id]
-
-class UpdatePolicyActionView(forms.ModalFormView):
+class UpdatePolicyActionView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = policy_rule_set_forms.UpdatePolicyActionForm
- template_name = "project/application_policy/update_policy_action.html"
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:application_policy:updatepolicyaction"
+ modal_header = _("Edit Policy Action")
+ page_title = _("Edit Policy Action")
+ submit_label = _("Save Changes")
+ help_text = _("Edit Policy Action.")
- def get_context_data(self, **kwargs):
- context = super(
- UpdatePolicyActionView, self).get_context_data(**kwargs)
- context['policyaction_id'] = self.kwargs['policyaction_id']
- return context
+ def get_submit_url_params(self, **kwargs):
+ return {"policyaction_id": self.kwargs['policyaction_id']}
def get_initial(self):
return {'policyaction_id': self.kwargs['policyaction_id']}
@@ -102,22 +112,29 @@ class UpdatePolicyActionView(forms.ModalFormView):
class PolicyRuleSetDetailsView(tabs.TabView):
tab_group_class = (PolicyRuleSetDetailsTabs)
- template_name = 'project/application_policy/details_tabs.html'
+ template_name = 'gbpui/details_tabs.html'
+ page_title = _("Policy Rule Set Details")
class PolicyRuleDetailsView(tabs.TabView):
tab_group_class = (PolicyRuleDetailsTabs)
- template_name = 'project/application_policy/details_tabs.html'
+ template_name = 'gbpui/details_tabs.html'
+ page_title = _("Policy Rule Details")
-class UpdatePolicyRuleView(forms.ModalFormView):
+class UpdatePolicyRuleView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = policy_rule_set_forms.UpdatePolicyRuleForm
- template_name = "project/application_policy/update_policy_rule.html"
- def get_context_data(self, **kwargs):
- context = super(UpdatePolicyRuleView, self).get_context_data(**kwargs)
- context['policyrule_id'] = self.kwargs['policyrule_id']
- return context
+ modal_header = _("Edit Policy Rule")
+ submit_label = _("Update Policy Rule")
+ submit_url = "horizon:project:application_policy:updatepolicyrule"
+ template_name = "gbpui/form_with_description.html"
+ page_title = _("Edit Policy Rule")
+ help_text = _("Edit Policy Rule.")
+
+ def get_submit_url_params(self, **kwargs):
+ return {"policyrule_id": self.kwargs['policyrule_id']}
def get_initial(self):
return {'policyrule_id': self.kwargs['policyrule_id']}
@@ -125,18 +142,22 @@ class UpdatePolicyRuleView(forms.ModalFormView):
class PolicyClassifierDetailsView(tabs.TabView):
tab_group_class = (PolicyClassifierDetailsTabs)
- template_name = 'project/application_policy/details_tabs.html'
+ template_name = "gbpui/details_tabs.html"
+ page_title = _("Policy Classifier Details")
-class UpdatePolicyClassifierView(forms.ModalFormView):
+class UpdatePolicyClassifierView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = policy_rule_set_forms.UpdatePolicyClassifierForm
- template_name = "project/application_policy/update_policy_classifier.html"
+ modal_header = _("Edit Policy Classifier")
+ submit_label = _("Update Policy Classifier")
+ submit_url = "horizon:project:application_policy:updatepolicyclassifier"
+ template_name = "gbpui/form_with_description.html"
+ page_title = _("Edit Policy Classifier")
+ help_text = _("Edit Policy Classifier.")
- def get_context_data(self, **kwargs):
- context = super(
- UpdatePolicyClassifierView, self).get_context_data(**kwargs)
- context['policyclassifier_id'] = self.kwargs['policyclassifier_id']
- return context
+ def get_submit_url_params(self, **kwargs):
+ return {"policyclassifier_id": self.kwargs['policyclassifier_id']}
def get_initial(self):
return {'policyclassifier_id': self.kwargs['policyclassifier_id']}
@@ -144,4 +165,5 @@ class UpdatePolicyClassifierView(forms.ModalFormView):
class PolicyActionDetailsView(tabs.TabView):
tab_group_class = (PolicyActionDetailsTabs)
- template_name = 'project/application_policy/details_tabs.html'
+ template_name = "gbpui/details_tabs.html"
+ page_title = _("Policy Action Details")
diff --git a/gbpui/panels/network_policy/templates/network_policy/_add_l2policy.html b/gbpui/panels/network_policy/templates/network_policy/_add_l2policy.html
deleted file mode 100644
index b678145..0000000
--- a/gbpui/panels/network_policy/templates/network_policy/_add_l2policy.html
+++ /dev/null
@@ -1,25 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}add_l2policy_form{% endblock %}
-{% block form_action %}{% url 'horizon:project:network_policy:addl2policy' %}{% endblock %}
-
-{% block modal-header %}{% trans "Add L2Policy" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description:" %}
-
{% trans "Add L2 Policy." %}
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_policy/templates/network_policy/_add_l3policy.html b/gbpui/panels/network_policy/templates/network_policy/_add_l3policy.html
deleted file mode 100644
index 7a08de4..0000000
--- a/gbpui/panels/network_policy/templates/network_policy/_add_l3policy.html
+++ /dev/null
@@ -1,45 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}add_l3policy_form{% endblock %}
-{% block form_action %}{% url 'horizon:project:network_policy:addl3policy' %}{% endblock %}
-
-{% block modal-header %}{% trans "Add L3Policy" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description:" %}
-
{% trans "Add L3 Policy." %}
-
-{% endblock %}
-
-
-{% block modal-js %}
-
-{% endblock %}
-
-
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_policy/templates/network_policy/_create_external_connectivity.html b/gbpui/panels/network_policy/templates/network_policy/_create_external_connectivity.html
deleted file mode 100644
index f36e8d7..0000000
--- a/gbpui/panels/network_policy/templates/network_policy/_create_external_connectivity.html
+++ /dev/null
@@ -1,24 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}create_external_connectivity{% endblock %}
-{% block form_action %}{% url 'horizon:project:network_policy:create_external_connectivity' %}{% endblock %}
-
-{% block modal-header %}{% trans "Create External Connectivity" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description:" %}
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_policy/templates/network_policy/_create_external_route_param.html b/gbpui/panels/network_policy/templates/network_policy/_create_external_route_param.html
deleted file mode 100644
index 5704638..0000000
--- a/gbpui/panels/network_policy/templates/network_policy/_create_external_route_param.html
+++ /dev/null
@@ -1,24 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}add_external_route_param_form{% endblock %}
-{% block form_action %}{% url 'horizon:project:network_policy:add_external_route_param' %}{% endblock %}
-
-{% block modal-header %}{% trans "Add External Route Parameter" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description:" %}
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_policy/templates/network_policy/_create_external_segment_param.html b/gbpui/panels/network_policy/templates/network_policy/_create_external_segment_param.html
deleted file mode 100644
index 695db2c..0000000
--- a/gbpui/panels/network_policy/templates/network_policy/_create_external_segment_param.html
+++ /dev/null
@@ -1,24 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}add_external_segment_param_form{% endblock %}
-{% block form_action %}{% url 'horizon:project:network_policy:add_external_segment_param' %}{% endblock %}
-
-{% block modal-header %}{% trans "Add External Segment Parameter" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description:" %}
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_policy/templates/network_policy/_create_nat_pool.html b/gbpui/panels/network_policy/templates/network_policy/_create_nat_pool.html
deleted file mode 100644
index 3087b2b..0000000
--- a/gbpui/panels/network_policy/templates/network_policy/_create_nat_pool.html
+++ /dev/null
@@ -1,24 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}create_nat_pool{% endblock %}
-{% block form_action %}{% url 'horizon:project:network_policy:create_nat_pool' %}{% endblock %}
-
-{% block modal-header %}{% trans "Create NAT Pool" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description:" %}
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_policy/templates/network_policy/_create_network_service_param.html b/gbpui/panels/network_policy/templates/network_policy/_create_network_service_param.html
deleted file mode 100644
index 72b0af7..0000000
--- a/gbpui/panels/network_policy/templates/network_policy/_create_network_service_param.html
+++ /dev/null
@@ -1,24 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}add_network_service_param_form{% endblock %}
-{% block form_action %}{% url 'horizon:project:network_policy:add_network_service_param' %}{% endblock %}
-
-{% block modal-header %}{% trans "Add Network Service Parameter" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description:" %}
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_policy/templates/network_policy/_create_service_policy.html b/gbpui/panels/network_policy/templates/network_policy/_create_service_policy.html
deleted file mode 100644
index 97dea73..0000000
--- a/gbpui/panels/network_policy/templates/network_policy/_create_service_policy.html
+++ /dev/null
@@ -1,25 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}create_service_policy_form{% endblock %}
-{% block form_action %}{% url 'horizon:project:network_policy:create_servicepolicy' %}{% endblock %}
-
-{% block modal-header %}{% trans "Create Service Policy" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description:" %}
-
{% trans "Create Service Policy." %}
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_policy/templates/network_policy/_update_external_connectivity.html b/gbpui/panels/network_policy/templates/network_policy/_update_external_connectivity.html
deleted file mode 100644
index cca6285..0000000
--- a/gbpui/panels/network_policy/templates/network_policy/_update_external_connectivity.html
+++ /dev/null
@@ -1,25 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}update_external_connectivity_form{% endblock %}
-{% block form_action %}{% url 'horizon:project:network_policy:update_externalconnectivity' external_connectivity_id %}{% endblock %}
-
-{% block modal-header %}{% trans "Update External Connectivity" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description:" %}
-
{% trans "Update Service Policy." %}
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_policy/templates/network_policy/_update_l2policy.html b/gbpui/panels/network_policy/templates/network_policy/_update_l2policy.html
deleted file mode 100644
index b25f862..0000000
--- a/gbpui/panels/network_policy/templates/network_policy/_update_l2policy.html
+++ /dev/null
@@ -1,25 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}update_l2policy_form{% endblock %}
-{% block form_action %}{% url 'horizon:project:network_policy:update_l2policy' l2policy_id %}{% endblock %}
-
-{% block modal-header %}{% trans "Update L2Policy" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description:" %}
-
{% trans "Update L2 Policy." %}
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_policy/templates/network_policy/_update_l3policy.html b/gbpui/panels/network_policy/templates/network_policy/_update_l3policy.html
deleted file mode 100644
index 927464c..0000000
--- a/gbpui/panels/network_policy/templates/network_policy/_update_l3policy.html
+++ /dev/null
@@ -1,44 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}update_l3policy_form{% endblock %}
-{% block form_action %}{% url 'horizon:project:network_policy:update_l3policy' l3policy_id %}{% endblock %}
-
-{% block modal-header %}{% trans "Update L3Policy" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description:" %}
-
{% trans "Update L3 Policy." %}
-
-{% endblock %}
-
-
-{% block modal-js %}
-
-{% endblock %}
-
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_policy/templates/network_policy/_update_nat_pool.html b/gbpui/panels/network_policy/templates/network_policy/_update_nat_pool.html
deleted file mode 100644
index d803ce6..0000000
--- a/gbpui/panels/network_policy/templates/network_policy/_update_nat_pool.html
+++ /dev/null
@@ -1,25 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}update_nat_pool_form{% endblock %}
-{% block form_action %}{% url 'horizon:project:network_policy:update_natpool' nat_pool_id %}{% endblock %}
-
-{% block modal-header %}{% trans "Update NAT Pool" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description:" %}
-
{% trans "Update NAT Pool." %}
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_policy/templates/network_policy/_update_service_policy.html b/gbpui/panels/network_policy/templates/network_policy/_update_service_policy.html
deleted file mode 100644
index 1156b27..0000000
--- a/gbpui/panels/network_policy/templates/network_policy/_update_service_policy.html
+++ /dev/null
@@ -1,25 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}update_service_policy_form{% endblock %}
-{% block form_action %}{% url 'horizon:project:network_policy:update_service_policy' service_policy_id %}{% endblock %}
-
-{% block modal-header %}{% trans "Update Service Policy" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description:" %}
-
{% trans "Update Service Policy." %}
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_policy/templates/network_policy/details_tabs.html b/gbpui/panels/network_policy/templates/network_policy/details_tabs.html
deleted file mode 100644
index db9d52c..0000000
--- a/gbpui/panels/network_policy/templates/network_policy/details_tabs.html
+++ /dev/null
@@ -1,15 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n %}
-{% block title %}{% trans "Network and Services' Policies" %}{% endblock %}
-
-{% block page_header %}
-{% include "horizon/common/_page_header.html" with title=_("Network and Services' Policies") %}
-{% endblock page_header %}
-
-{% block main %}
-
-
- {{ tab_group.render }}
-
-
-{% endblock %}
diff --git a/gbpui/panels/network_policy/views.py b/gbpui/panels/network_policy/views.py
index ef87c4a..14a7f66 100644
--- a/gbpui/panels/network_policy/views.py
+++ b/gbpui/panels/network_policy/views.py
@@ -13,11 +13,11 @@ from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
-from horizon import forms
from horizon import tables
from horizon import tabs
from gbpui import client
+from gbpui.common import forms as gbforms
import forms as np_forms
import tables as np_tables
@@ -26,29 +26,37 @@ import tabs as np_tabs
class IndexView(tabs.TabbedTableView):
tab_group_class = (np_tabs.L3PolicyTabs)
- template_name = 'project/network_policy/details_tabs.html'
+ template_name = "gbpui/details_tabs.html"
+ page_title = _("Network and Services' Policies")
-class AddL3policyView(forms.ModalFormView):
+class AddL3policyView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = np_forms.AddL3PolicyForm
- template_name = "project/network_policy/add_l3policy.html"
- def get_context_data(self, **kwargs):
- context = super(AddL3policyView, self).get_context_data(**kwargs)
- return context
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:network_policy:addl3policy"
+ modal_header = _("Add L3Policy")
+ submit_label = _("Create")
+ page_title = _("Add L3Policy")
+ help_text = _("Add L3 Policy.")
def get_initial(self):
return self.kwargs
-class L3PolicyUpdateView(forms.ModalFormView):
+class L3PolicyUpdateView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = np_forms.UpdateL3PolicyForm
- template_name = "project/network_policy/update_l3policy.html"
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:network_policy:update_l3policy"
+ modal_header = _("Update L3Policy")
+ submit_label = _("Save Changes")
+ page_title = _("Update L3Policy")
+ help_text = _("Update L3Policy.")
- def get_context_data(self, **kwargs):
- context = super(L3PolicyUpdateView, self).get_context_data(**kwargs)
- context['l3policy_id'] = self.kwargs['l3policy_id']
- return context
+ def get_submit_url_params(self, **kwargs):
+ return {"l3policy_id": self.kwargs["l3policy_id"]}
def get_initial(self):
return self.kwargs
@@ -76,26 +84,29 @@ class L3PolicyDetailsView(tables.MultiTableView):
return context
-class AddL2policyView(forms.ModalFormView):
+class AddL2policyView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = np_forms.AddL2PolicyForm
- template_name = "project/network_policy/add_l2policy.html"
-
- def get_context_data(self, **kwargs):
- context = super(AddL2policyView, self).get_context_data(**kwargs)
- return context
-
- def get_initial(self):
- return self.kwargs
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:network_policy:addl2policy"
+ modal_header = _("Add L2Policy")
+ submit_label = _("Save Changes")
+ page_title = _("Add L2Policy")
+ help_text = _("Add L2Policy.")
-class L2PolicyUpdateView(forms.ModalFormView):
+class L2PolicyUpdateView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = np_forms.UpdateL2PolicyForm
- template_name = "project/network_policy/update_l2policy.html"
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:network_policy:update_l2policy"
+ modal_header = _("Update L2Policy")
+ submit_label = _("Save Changes")
+ page_title = _("Update L2Policy")
+ help_text = _("Update L2Policy.")
- def get_context_data(self, **kwargs):
- context = super(L2PolicyUpdateView, self).get_context_data(**kwargs)
- context['l2policy_id'] = self.kwargs['l2policy_id']
- return context
+ def get_submit_url_params(self, **kwargs):
+ return {"l2policy_id": self.kwargs["l2policy_id"]}
def get_initial(self):
return self.kwargs
@@ -103,81 +114,112 @@ class L2PolicyUpdateView(forms.ModalFormView):
class L2PolicyDetailsView(tabs.TabView):
tab_group_class = (np_tabs.L2PolicyDetailsTabs)
- template_name = 'project/network_policy/details_tabs.html'
+ template_name = "gbpui/details_tabs.html"
+ page_title = _("L2 Policy Details")
-class CreateServicePolicyView(forms.ModalFormView):
+class CreateServicePolicyView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = np_forms.CreateServicePolicyForm
- template_name = "project/network_policy/create_service_policy.html"
- def get_context_data(self, **kwargs):
- context = super(
- CreateServicePolicyView, self).get_context_data(**kwargs)
- return context
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:network_policy:create_servicepolicy"
+ modal_header = _("Create Service Policy")
+ submit_label = _("Create")
+ page_title = _("Create Service Policy")
+ help_text = _("Create Service Policy.")
-class AddExternalSegmentParamView(forms.ModalFormView):
+class AddExternalSegmentParamView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = np_forms.CreateExternalSegmentParamForm
- template_name = "project/network_policy/create_external_segment_param.html"
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:network_policy:add_external_segment_param"
+ modal_header = _("Add External Segment Parameter")
+ submit_label = _("Create")
+ page_title = _("Add External Segment Parameter")
+ help_text = _("Add External Segment Parameter.")
def get_object_id(self, params):
return params.name
-class AddNetworkServiceParamView(forms.ModalFormView):
+class AddNetworkServiceParamView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = np_forms.CreateNetworkServiceParamForm
- template_name = "project/network_policy/create_network_service_param.html"
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:network_policy:add_network_service_param"
+ modal_header = _("Add Network Service Parameter")
+ submit_label = _("Create")
+ page_title = _("Add Network Service Parameter")
+ help_text = _("Add Network Service Parameter.")
def get_object_id(self, params):
return params.name
-class AddExternalRouteParamView(forms.ModalFormView):
+class AddExternalRouteParamView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = np_forms.CreateExternalRouteParamForm
- template_name = "project/network_policy/create_external_route_param.html"
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:network_policy:add_external_route_param"
+ modal_header = _("Add External Route Parameter")
+ submit_label = _("Create")
+ page_title = _("Add External Route Parameter")
+ help_text = _("Add External Route Parameter.")
def get_object_id(self, params):
return params.name
-class UpdateNATPoolView(forms.ModalFormView):
+class UpdateNATPoolView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = np_forms.UpdateNATPoolForm
- template_name = "project/network_policy/update_nat_pool.html"
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:network_policy:update_natpool"
+ modal_header = _("Update NAT Pool")
+ submit_label = _("Save Changes")
+ page_title = _("Update NAT Pool")
+ help_text = _("Update NAT Pool.")
- def get_context_data(self, **kwargs):
- context = super(
- UpdateNATPoolView, self).get_context_data(**kwargs)
- context['nat_pool_id'] = self.kwargs['nat_pool_id']
- return context
+ def get_submit_url_params(self, **kwargs):
+ return {"nat_pool_id": self.kwargs["nat_pool_id"]}
def get_initial(self):
return self.kwargs
-class UpdateExternalConnectivityView(forms.ModalFormView):
+class UpdateExternalConnectivityView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = np_forms.UpdateExternalConnectivityForm
- template_name = "project/network_policy/update_external_connectivity.html"
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:network_policy:update_externalconnectivity"
+ modal_header = _("Update External Connectivity")
+ submit_label = _("Save Changes")
+ page_title = _("Update External Connectivity")
+ help_text = _("Update External Connectivity.")
- def get_context_data(self, **kwargs):
- context = super(
- UpdateExternalConnectivityView, self).get_context_data(**kwargs)
- context['external_connectivity_id'] = \
- self.kwargs['external_connectivity_id']
- return context
+ def get_submit_url_params(self, **kwargs):
+ return {
+ "external_connectivity_id": self.kwargs["external_connectivity_id"]
+ }
def get_initial(self):
return self.kwargs
-class UpdateServicePolicyView(forms.ModalFormView):
+class UpdateServicePolicyView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = np_forms.UpdateServicePolicyForm
- template_name = "project/network_policy/update_service_policy.html"
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:network_policy:update_service_policy"
+ modal_header = _("Update Service Policy")
+ submit_label = _("Save Changes")
+ page_title = _("Update Service Policy")
+ help_text = _("Update Service Policy.")
- def get_context_data(self, **kwargs):
- context = super(
- UpdateServicePolicyView, self).get_context_data(**kwargs)
- context['service_policy_id'] = self.kwargs['service_policy_id']
- return context
+ def get_submit_url_params(self, **kwargs):
+ return {"service_policy_id": self.kwargs["service_policy_id"]}
def get_initial(self):
return self.kwargs
@@ -185,40 +227,45 @@ class UpdateServicePolicyView(forms.ModalFormView):
class ServicePolicyDetailsView(tabs.TabView):
tab_group_class = (np_tabs.ServicePolicyDetailsTabs)
- template_name = 'project/network_policy/details_tabs.html'
+ template_name = 'gbpui/details_tabs.html'
+ page_title = _("Service Policy Details")
-class CreateExternalConnectivityView(forms.ModalFormView):
+class CreateExternalConnectivityView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = np_forms.CreateExternalConnectivityForm
- template_name = "project/network_policy/create_external_connectivity.html"
-
- def get_context_data(self, **kwargs):
- context = super(
- CreateExternalConnectivityView, self).get_context_data(**kwargs)
- return context
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:network_policy:create_external_connectivity"
+ modal_header = _("Create External Connectivity")
+ submit_label = _("Save Changes")
+ page_title = _("Create External Connectivity")
+ help_text = _("Create External Connectivity.")
def get_success_url(self):
return reverse('horizon:project:network_policy:index')
- def get_object_id(self, external_segment):
- return [external_segment.id]
-
class ExternalConnectivityDetailsView(tabs.TabView):
tab_group_class = (np_tabs.ExternalConnectivityDetailsTabs)
- template_name = 'project/network_policy/details_tabs.html'
+ template_name = "gbpui/details_tabs.html"
+ page_title = _("External Connectivity Details")
-class CreateNATPoolView(forms.ModalFormView):
+class CreateNATPoolView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = np_forms.CreateNATPoolForm
- template_name = "project/network_policy/create_nat_pool.html"
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:network_policy:create_nat_pool"
+ modal_header = _("Create NAT Pool")
+ submit_label = _("Create")
+ page_title = _("Create NAT Pool")
+ help_text = _("Create NAT Pool.")
- def get_context_data(self, **kwargs):
- context = super(
- CreateNATPoolView, self).get_context_data(**kwargs)
- return context
+ def get_success_url(self):
+ return reverse('horizon:project:application_policy:index')
class NATPoolDetailsView(tabs.TabView):
tab_group_class = (np_tabs.NATPoolDetailsTabs)
- template_name = 'project/network_policy/details_tabs.html'
+ template_name = 'gbpui/details_tabs.html'
+ page_title = _("NAT Pool Details")
diff --git a/gbpui/panels/network_services/forms.py b/gbpui/panels/network_services/forms.py
index 67fb63d..69d4bf6 100644
--- a/gbpui/panels/network_services/forms.py
+++ b/gbpui/panels/network_services/forms.py
@@ -298,91 +298,3 @@ class UpdateServiceChainSpecForm(CreateServiceChainSpecForm, BaseUpdateForm):
msg = _("Failed to update Service Chain Spec. %s") % (str(e))
LOG.error(msg)
exceptions.handle(request, msg, redirect=shortcuts.redirect)
-
-
-class CreateServiceChainInstanceForm(forms.SelfHandlingForm):
- name = forms.CharField(max_length=80, label=_("Name"))
- description = forms.CharField(
- max_length=80, label=_("Description"), required=False)
- servicechain_spec = forms.ChoiceField(label=_("ServiceChain Spec"))
- provider_ptg = forms.ChoiceField(label=_("Provider PTG"))
- consumer_ptg = forms.ChoiceField(label=_("Consumer PTG"))
- classifier = forms.ChoiceField(label=_("Classifier"))
-
- def __init__(self, request, *args, **kwargs):
- super(CreateServiceChainInstanceForm, self).__init__(
- request, *args, **kwargs)
- try:
- sc_specs = client.servicechainspec_list(request,
- tenant_id=request.user.tenant_id)
- ptgs = client.policy_target_list(request,
- tenant_id=request.user.tenant_id)
- ptgs = [(item.id, item.name) for item in ptgs]
- classifiers = client.policyclassifier_list(request,
- tenant_id=request.user.tenant_id)
- self.fields['servicechain_spec'].choices = [
- (item.id, item.name) for item in sc_specs]
- self.fields['provider_ptg'].choices = ptgs
- self.fields['consumer_ptg'].choices = ptgs
- self.fields['classifier'].choices = [
- (item.id, item.name) for item in classifiers]
- except Exception:
- msg = _("Failed to retrive policy targets")
- LOG.error(msg)
-
- def handle(self, request, context):
- url = reverse("horizon:project:network_services:index")
- try:
- if context.get('name'):
- context['name'] = html.escape(context['name'])
- if context.get('description'):
- context['description'] = html.escape(context['description'])
- client.create_servicechain_instance(request, **context)
- msg = _("Service Chain Instance Created Successfully!")
- LOG.debug(msg)
- return http.HttpResponseRedirect(url)
- except Exception as e:
- msg = _("Failed to create Service Chain Instance. %s") % (str(e))
- LOG.error(msg)
- exceptions.handle(request, msg, redirect=shortcuts.redirect)
-
-
-class UpdateServiceChainInstanceForm(forms.SelfHandlingForm):
- name = forms.CharField(max_length=80, label=_("Name"))
- description = forms.CharField(
- max_length=80, label=_("Description"), required=False)
- servicechain_spec = forms.ChoiceField(label=_("ServiceChain Spec"))
-
- def __init__(self, request, *args, **kwargs):
- super(UpdateServiceChainInstanceForm, self).__init__(
- request, *args, **kwargs)
- try:
- scinstance_id = self.initial['scinstance_id']
- sc_specs = client.servicechainspec_list(request,
- tenant_id=request.user.tenant_id)
- self.fields['servicechain_spec'].choices = [
- (item.id, item.name) for item in sc_specs]
- scinstance = client.get_servicechain_instance(
- request, scinstance_id)
- for attr in ['name', 'description', 'servicechain_spec']:
- self.fields[attr].initial = getattr(scinstance, attr)
- except Exception:
- pass
-
- def handle(self, request, context):
- url = reverse("horizon:project:network_services:index")
- try:
- scinstance_id = self.initial['scinstance_id']
- if context.get('name'):
- context['name'] = html.escape(context['name'])
- if context.get('description'):
- context['description'] = html.escape(context['description'])
- client.update_servicechain_instance(
- request, scinstance_id, **context)
- msg = _("Service Chain Instance Created Successfully!")
- LOG.debug(msg)
- return http.HttpResponseRedirect(url)
- except Exception as e:
- msg = _("Failed to create Service Chain Instance. %s") % (str(e))
- LOG.error(msg)
- exceptions.handle(request, msg, redirect=shortcuts.redirect)
diff --git a/gbpui/panels/network_services/templates/network_services/_create_service_chain_instance.html b/gbpui/panels/network_services/templates/network_services/_create_service_chain_instance.html
deleted file mode 100644
index c4c3c71..0000000
--- a/gbpui/panels/network_services/templates/network_services/_create_service_chain_instance.html
+++ /dev/null
@@ -1,25 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}create_service_chain_instance{% endblock %}
-{% block form_action %}{% url 'horizon:project:network_services:create_sc_instance' %}{% endblock %}
-
-{% block modal-header %}{% trans "Create Service Chain Instance" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description:" %}
-
{% trans "Create Service Chain Instance." %}
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_services/templates/network_services/_create_service_chain_node.html b/gbpui/panels/network_services/templates/network_services/_create_service_chain_node.html
deleted file mode 100644
index 866f00f..0000000
--- a/gbpui/panels/network_services/templates/network_services/_create_service_chain_node.html
+++ /dev/null
@@ -1,26 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}create_service_chain_node{% endblock %}
-{% block form_action %}{% url 'horizon:project:network_services:create_sc_node' %}{% endblock %}
-{% block form_attrs %}enctype="multipart/form-data"{% endblock %}
-
-{% block modal-header %}{% trans "Create Service Chain Node" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description:" %}
-
{% trans "Create Service Chain Node." %}
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_services/templates/network_services/_create_service_profile.html b/gbpui/panels/network_services/templates/network_services/_create_service_profile.html
deleted file mode 100644
index ee3c24e..0000000
--- a/gbpui/panels/network_services/templates/network_services/_create_service_profile.html
+++ /dev/null
@@ -1,26 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}create_service_profile_form{% endblock %}
-{% block form_action %}{% url "horizon:project:network_services:create_service_profile" %}{% endblock %}
-
-{% block modal_id %}create_service_profile_modal{% endblock %}
-{% block modal-header %}{% trans "Create Service Profile" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description" %}:
-
{% trans "Create Service Profile." %}
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_services/templates/network_services/_scspec_details.html b/gbpui/panels/network_services/templates/network_services/_scspec_details.html
index d96a5aa..14cb7ad 100644
--- a/gbpui/panels/network_services/templates/network_services/_scspec_details.html
+++ b/gbpui/panels/network_services/templates/network_services/_scspec_details.html
@@ -4,7 +4,7 @@
- - {% trans "Name" %}
+ - {% trans "Name" %}
- {{ scspec.name|default:_("-") }}
- {% trans "Description" %}
@@ -16,35 +16,35 @@
- {% trans "Shared" %}
- {{ scspec.shared }}
- {% if scspec.nodes %}
-
- {% endif %}
+ {% if scspec.nodes %}
+
+ {% endif %}
diff --git a/gbpui/panels/network_services/templates/network_services/_service_chain_spec_details.html b/gbpui/panels/network_services/templates/network_services/_service_chain_spec_details.html
deleted file mode 100644
index e69de29..0000000
diff --git a/gbpui/panels/network_services/templates/network_services/_update_service_chain_instance.html b/gbpui/panels/network_services/templates/network_services/_update_service_chain_instance.html
deleted file mode 100644
index 5e42f55..0000000
--- a/gbpui/panels/network_services/templates/network_services/_update_service_chain_instance.html
+++ /dev/null
@@ -1,25 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}update_service_chain_instance{% endblock %}
-{% block form_action %}{% url 'horizon:project:network_services:update_sc_instance' scinstance_id %}{% endblock %}
-
-{% block modal-header %}{% trans "Update Service Chain Instance" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description:" %}
-
{% trans "Update Service Chain Instance." %}
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_services/templates/network_services/_update_service_chain_node.html b/gbpui/panels/network_services/templates/network_services/_update_service_chain_node.html
deleted file mode 100644
index 65431d4..0000000
--- a/gbpui/panels/network_services/templates/network_services/_update_service_chain_node.html
+++ /dev/null
@@ -1,25 +0,0 @@
-{% extends "horizon/common/_modal_form.html" %}
-{% load i18n %}
-{% load url from future %}
-
-{% block form_id %}update_service_chain_node{% endblock %}
-{% block form_action %}{% url 'horizon:project:network_services:update_sc_node' scnode_id %}{% endblock %}
-
-{% block modal-header %}{% trans "Update Service Chain Node" %}{% endblock %}
-
-{% block modal-body %}
-
-
-
-
-
{% trans "Description:" %}
-
{% trans "Update Service Chain Node." %}
-
-{% endblock %}
-
-{% block modal-footer %}
-
- {% trans "Cancel" %}
-{% endblock %}
diff --git a/gbpui/panels/network_services/templates/network_services/details_tabs.html b/gbpui/panels/network_services/templates/network_services/details_tabs.html
deleted file mode 100644
index e8124c3..0000000
--- a/gbpui/panels/network_services/templates/network_services/details_tabs.html
+++ /dev/null
@@ -1,15 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n %}
-{% block title %}{% trans "Network Services" %}{% endblock %}
-
-{% block page_header %}
-{% include "horizon/common/_page_header.html" with title=_("Network Services") %}
-{% endblock page_header %}
-
-{% block main %}
-
-
- {{ tab_group.render }}
-
-
-{% endblock %}
diff --git a/gbpui/panels/network_services/templates/network_services/index.html b/gbpui/panels/network_services/templates/network_services/index.html
deleted file mode 100644
index e69de29..0000000
diff --git a/gbpui/panels/network_services/urls.py b/gbpui/panels/network_services/urls.py
index f0a5d35..377bfd0 100644
--- a/gbpui/panels/network_services/urls.py
+++ b/gbpui/panels/network_services/urls.py
@@ -10,7 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-
from django.conf.urls import url # noqa
import views
@@ -41,12 +40,6 @@ urlpatterns = [
url(r'^sc_spec/(?P[^/]+)/$',
views.ServiceChainSpecDetailsView.as_view(),
name='sc_spec_details'),
- url(r'^create_sc_instance$',
- views.CreateServiceChainInstanceView.as_view(),
- name='create_sc_instance'),
- url(r'^update_sc_instance/(?P[^/]+)/$',
- views.UpdateServiceChainInstanceView.as_view(),
- name='update_sc_instance'),
url(r'^sc_instance/(?P[^/]+)/$',
views.ServiceChainInstanceDetailsView.as_view(),
name='sc_instance_details'),
diff --git a/gbpui/panels/network_services/views.py b/gbpui/panels/network_services/views.py
index 714354d..eb6b991 100644
--- a/gbpui/panels/network_services/views.py
+++ b/gbpui/panels/network_services/views.py
@@ -15,46 +15,56 @@ from horizon import tabs
import forms as ns_forms
import tabs as ns_tabs
+from django.utils.translation import ugettext_lazy as _
+from gbpui.common import forms as gbforms
+
class IndexView(tabs.TabbedTableView):
tab_group_class = (ns_tabs.ServiceChainTabs)
- template_name = 'project/network_services/details_tabs.html'
+ template_name = 'gbpui/details_tabs.html'
+ page_title = _("Network Services")
class ServiceProfileDetailsView(tabs.TabView):
tab_group_class = (ns_tabs.ServiceProfileDetailsTabGroup)
- template_name = 'project/network_services/details_tabs.html'
+ template_name = 'gbpui/details_tabs.html'
+ page_title = _("Service Profile Details")
-class CreateServiceProfileView(forms.ModalFormView):
+class CreateServiceProfileView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = ns_forms.CreateServiceProfileForm
- template_name = "project/network_services/create_service_profile.html"
-
- def get_context_data(self, **kwargs):
- context = super(
- CreateServiceProfileView, self).get_context_data(**kwargs)
- return context
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:network_services:create_service_profile"
+ modal_header = _("Create Service Profile")
+ submit_label = _("Create")
+ page_title = _("Create Service Profile")
+ help_text = _("Create Service Profile.")
-class CreateServiceChainNodeView(forms.ModalFormView):
+class CreateServiceChainNodeView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = ns_forms.CreateServiceChainNodeForm
- template_name = "project/network_services/create_service_chain_node.html"
-
- def get_context_data(self, **kwargs):
- context = super(
- CreateServiceChainNodeView, self).get_context_data(**kwargs)
- return context
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:network_services:create_sc_node"
+ modal_header = _("Create Service Chain Node")
+ submit_label = _("Create")
+ page_title = _("Create Service Chain Node")
+ help_text = _("Create Service Chain Node.")
-class UpdateServiceChainNodeView(forms.ModalFormView):
+class UpdateServiceChainNodeView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = ns_forms.UpdateServiceChainNodeForm
- template_name = "project/network_services/update_service_chain_node.html"
+ template_name = "gbpui/form_with_description.html"
+ submit_url = "horizon:project:network_services:update_sc_node"
+ modal_header = _("Update Service Chain Node")
+ submit_label = _("Save Changes")
+ page_title = _("Update Service Chain Node")
+ help_text = _("Update Service Chain Node.")
- def get_context_data(self, **kwargs):
- context = super(
- UpdateServiceChainNodeView, self).get_context_data(**kwargs)
- context['scnode_id'] = self.kwargs['scnode_id']
- return context
+ def get_submit_url_params(self, **kwargs):
+ return {"scnode_id": self.kwargs['scnode_id']}
def get_initial(self):
return self.kwargs
@@ -62,7 +72,8 @@ class UpdateServiceChainNodeView(forms.ModalFormView):
class ServiceChainNodeDetailsView(tabs.TabView):
tab_group_class = (ns_tabs.SCNodeDetailsTabGroup)
- template_name = 'project/network_services/details_tabs.html'
+ template_name = 'gbpui/details_tabs.html'
+ page_title = _("Service Chain Node Details")
class CreateServiceChainSpecView(forms.ModalFormView):
@@ -91,35 +102,11 @@ class UpdateServiceChainSpecView(forms.ModalFormView):
class ServiceChainSpecDetailsView(tabs.TabView):
tab_group_class = (ns_tabs.SCSpecDetailsTabGroup)
- template_name = 'project/network_services/details_tabs.html'
-
-
-class CreateServiceChainInstanceView(forms.ModalFormView):
- form_class = ns_forms.CreateServiceChainInstanceForm
- template_name = "project/network_services/" \
- "create_service_chain_instance.html"
-
- def get_context_data(self, **kwargs):
- context = super(
- CreateServiceChainInstanceView, self).get_context_data(**kwargs)
- return context
-
-
-class UpdateServiceChainInstanceView(forms.ModalFormView):
- form_class = ns_forms.UpdateServiceChainInstanceForm
- template_name = "project/network_services/" \
- "update_service_chain_instance.html"
-
- def get_context_data(self, **kwargs):
- context = super(
- UpdateServiceChainInstanceView, self).get_context_data(**kwargs)
- context['scinstance_id'] = self.kwargs['scinstance_id']
- return context
-
- def get_initial(self):
- return self.kwargs
+ template_name = 'gbpui/details_tabs.html'
+ page_title = _("Service Chain Spec Details")
class ServiceChainInstanceDetailsView(tabs.TabView):
tab_group_class = (ns_tabs.SCInstanceDetailsTabGroup)
- template_name = 'project/network_services/details_tabs.html'
+ template_name = 'gbpui/details_tabs.html'
+ page_title = _("Service Chain Instance Details")
diff --git a/gbpui/panels/policytargets/templates/policytargets/group_details.html b/gbpui/panels/policytargets/templates/policytargets/group_details.html
deleted file mode 100644
index c7ae02a..0000000
--- a/gbpui/panels/policytargets/templates/policytargets/group_details.html
+++ /dev/null
@@ -1,11 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n %}
-{% block title %}{% trans "Groups Details" %}{% endblock %}
-
-{% block main %}
-
-
- {{ tab_group.render }}
-
-
-{% endblock %}
diff --git a/gbpui/panels/policytargets/views.py b/gbpui/panels/policytargets/views.py
index 1a161d5..608ad75 100644
--- a/gbpui/panels/policytargets/views.py
+++ b/gbpui/panels/policytargets/views.py
@@ -12,13 +12,11 @@
import json
-from django.core.urlresolvers import reverse
from django.core.urlresolvers import reverse_lazy
from django.http import HttpResponse # noqa
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
-from horizon import forms
from horizon import tabs
from horizon.utils import memoized
from horizon import workflows
@@ -45,7 +43,7 @@ AddExternalPTG = policy_target_workflows.AddExternalPTG
class IndexView(tabs.TabbedTableView):
tab_group_class = (PTGTabs)
- template_name = 'project/policytargets/details_tabs.html'
+ template_name = 'gbpui/details_tabs.html'
page_title = _("Groups")
@@ -59,7 +57,7 @@ class AddExternalPTGView(workflows.WorkflowView):
class PTGDetailsView(tabs.TabbedTableView):
tab_group_class = (policy_target_tabs.PTGMemberTabs)
- template_name = 'project/policytargets/group_details.html'
+ template_name = 'gbpui/details_tabs.html'
page_title = _("Group: {{ policy_target.name }}")
def get_context_data(self, **kwargs):
@@ -75,7 +73,7 @@ class PTGDetailsView(tabs.TabbedTableView):
class ExternalPTGDetailsView(tabs.TabbedTableView):
tab_group_class = (policy_target_tabs.ExternalPTGMemberTabs)
- template_name = 'project/policytargets/group_details.html'
+ template_name = 'gbpui/details_tabs.html'
page_title = _("Group: {{ policy_target.name }}")
def get_context_data(self, **kwargs):
@@ -92,7 +90,6 @@ class ExternalPTGDetailsView(tabs.TabbedTableView):
class LaunchVMView(workflows.WorkflowView):
workflow_class = policy_target_workflows.LaunchInstance
- template_name = "project/policytargets/add_vm.html"
def get_initial(self):
initial = super(LaunchVMView, self).get_initial()
@@ -101,7 +98,8 @@ class LaunchVMView(workflows.WorkflowView):
return initial
-class UpdatePTGView(forms.ModalFormView):
+class UpdatePTGView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = policy_target_forms.UpdatePolicyTargetForm
form_id = "update_policy_target_form"
modal_header = _("Edit Group")
@@ -113,16 +111,10 @@ class UpdatePTGView(forms.ModalFormView):
page_title = _("Edit Group")
help_text = _("You may update group details here.")
- def get_context_data(self, **kwargs):
- context = super(UpdatePTGView, self).get_context_data(**kwargs)
- obj_id = self.kwargs['policy_target_id']
- context["policy_target_id"] = obj_id
- obj = self._get_object()
- if obj:
- context['name'] = obj.name
- context["submit_url"] = reverse(self.submit_url, args=(obj_id,))
- context["help_text"] = self.help_text
- return context
+ def get_submit_url_params(self, **kwargs):
+ return {
+ "policy_target_id": self.kwargs["policy_target_id"]
+ }
@memoized.memoized_method
def _get_object(self, *args, **kwargs):
@@ -141,7 +133,8 @@ class UpdatePTGView(forms.ModalFormView):
return self.kwargs
-class UpdateExternalPTGView(forms.ModalFormView):
+class UpdateExternalPTGView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = policy_target_forms.UpdateExternalPolicyTargetForm
form_id = "update_policy_target_form"
modal_header = _("Edit Group")
@@ -153,16 +146,10 @@ class UpdateExternalPTGView(forms.ModalFormView):
page_title = _("Edit Group")
help_text = _("You may update external policy details here.")
- def get_context_data(self, **kwargs):
- context = super(UpdateExternalPTGView, self).get_context_data(**kwargs)
- obj_id = self.kwargs['ext_policy_target_id']
- context["ext_policy_target_id"] = obj_id
- obj = self._get_object()
- if obj:
- context['name'] = obj.name
- context["submit_url"] = reverse(self.submit_url, args=(obj_id,))
- context["help_text"] = self.help_text
- return context
+ def get_submit_url_params(self, **kwargs):
+ return {
+ "ext_policy_target_id": self.kwargs["ext_policy_target_id"]
+ }
@memoized.memoized_method
def _get_object(self, *args, **kwargs):
@@ -181,7 +168,8 @@ class UpdateExternalPTGView(forms.ModalFormView):
return self.kwargs
-class ExtAddProvidedPRSView(gbforms.ReversingModalFormView):
+class ExtAddProvidedPRSView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = policy_target_forms.ExtAddProvidedPRSForm
form_id = "ext_add_provided_form"
modal_header = _("Add Provided PRS")
@@ -202,7 +190,8 @@ class ExtAddProvidedPRSView(gbforms.ReversingModalFormView):
return self.kwargs
-class ExtRemoveProvidedPRSView(gbforms.ReversingModalFormView):
+class ExtRemoveProvidedPRSView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = policy_target_forms.ExtRemoveProvidedPRSForm
form_id = "ext_remove_provided_form"
modal_header = _("Remove Provided PRS")
@@ -223,7 +212,8 @@ class ExtRemoveProvidedPRSView(gbforms.ReversingModalFormView):
return self.kwargs
-class AddProvidedPRSView(gbforms.ReversingModalFormView):
+class AddProvidedPRSView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = policy_target_forms.AddProvidedPRSForm
form_id = "add_provided_form"
modal_header = _("Add Provided PRS")
@@ -244,7 +234,8 @@ class AddProvidedPRSView(gbforms.ReversingModalFormView):
return self.kwargs
-class RemoveProvidedPRSView(gbforms.ReversingModalFormView):
+class RemoveProvidedPRSView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = policy_target_forms.RemoveProvidedPRSForm
form_id = "remove_provided_form"
modal_header = _("Remove Provided PRS")
@@ -265,7 +256,8 @@ class RemoveProvidedPRSView(gbforms.ReversingModalFormView):
return self.kwargs
-class ExtAddConsumedPRSView(gbforms.ReversingModalFormView):
+class ExtAddConsumedPRSView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = policy_target_forms.ExtAddConsumedPRSForm
form_id = "ext_add_consumed_form"
modal_header = _("Add Policy Rule Set")
@@ -286,7 +278,8 @@ class ExtAddConsumedPRSView(gbforms.ReversingModalFormView):
return self.kwargs
-class ExtRemoveConsumedPRSView(gbforms.ReversingModalFormView):
+class ExtRemoveConsumedPRSView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = policy_target_forms.ExtRemoveConsumedPRSForm
form_id = "remove_contract_form"
modal_header = _("Remove Policy Rule Set")
@@ -307,7 +300,8 @@ class ExtRemoveConsumedPRSView(gbforms.ReversingModalFormView):
return self.kwargs
-class AddConsumedPRSView(gbforms.ReversingModalFormView):
+class AddConsumedPRSView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = policy_target_forms.AddConsumedPRSForm
form_id = "add_consumed_form"
modal_header = _("Add ")
@@ -328,7 +322,8 @@ class AddConsumedPRSView(gbforms.ReversingModalFormView):
return self.kwargs
-class RemoveConsumedPRSView(gbforms.ReversingModalFormView):
+class RemoveConsumedPRSView(gbforms.HelpTextModalMixin,
+ gbforms.ReversingModalFormView):
form_class = policy_target_forms.RemoveConsumedPRSForm
form_id = "remove_contract_form"
modal_header = _("Remove Policy Rule Set")
diff --git a/gbpui/panels/policytargets/templates/policytargets/details_tabs.html b/gbpui/templates/gbpui/details_tabs.html
similarity index 75%
rename from gbpui/panels/policytargets/templates/policytargets/details_tabs.html
rename to gbpui/templates/gbpui/details_tabs.html
index 552d681..b24b36a 100644
--- a/gbpui/panels/policytargets/templates/policytargets/details_tabs.html
+++ b/gbpui/templates/gbpui/details_tabs.html
@@ -1,6 +1,6 @@
{% extends 'base.html' %}
{% load i18n %}
-{% block title %}{% trans "Groups" %}{% endblock %}
+{% block title %}{{ page_title }}{% endblock %}
{% block main %}