From 268ae1259ab50b77e89e54a11392bcd2a2249e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20K=C5=99iv=C3=A1k?= Date: Mon, 14 Aug 2017 19:06:51 +0200 Subject: [PATCH] Update templates in policytargets section. Templates used throughout GBP UI were not properly updated for several OpenStack releases. This update removes unused templates and reduces unnecessary complexity. Additionally, this fixes problems with missing non-ajax version of templates, that breaks standalone rendering of forms and workflows (e. g. when opened in new tab or after re-login when session expires during while working with forms). This commit fixes ony policytargets section. Partial-Bug: #1710852 Co-Authored-By: Marek Lycka Change-Id: I4f8f6cef04fd514eccb428e8a89cc030ae99cb2a --- gbpui/common/__init__.py | 0 gbpui/common/forms.py | 33 ++++++ gbpui/panels/policytargets/tabs.py | 2 +- .../policytargets/_add_consumed.html | 25 ----- .../policytargets/_add_consumed_prs.html | 25 ----- .../policytargets/_add_contract.html | 25 ----- .../policytargets/_add_l3policy.html | 25 ----- .../policytargets/_add_policy_rule_set.html | 25 ----- .../policytargets/_add_provided_prs.html | 25 ----- .../templates/policytargets/_add_vm.html | 25 ----- .../templates/policytargets/_del_vm.html | 25 ----- .../policytargets/_ext_add_consumed_prs.html | 25 ----- .../policytargets/_ext_add_provided_prs.html | 25 ----- .../_ext_remove_consumed_prs.html | 25 ----- .../_ext_remove_provided_prs.html | 25 ----- .../policytargets/_l3_policy_details.html | 17 --- .../policytargets/_remove_consumed.html | 25 ----- .../policytargets/_remove_consumed_prs.html | 25 ----- .../policytargets/_remove_contract.html | 25 ----- .../policytargets/_remove_provided_prs.html | 25 ----- .../_update_external_policy_target.html | 25 ----- .../policytargets/_update_l3policy.html | 25 ----- .../policytargets/_update_policy_target.html | 25 ----- .../templates/policytargets/_updateepg.html | 25 ----- .../templates/policytargets/addepg.html | 11 -- .../templates/policytargets/details_tabs.html | 4 - .../policytargets/group_details.html | 4 - .../templates/policytargets/updateepg.html | 11 -- gbpui/panels/policytargets/views.py | 106 +++++++++--------- .../gbpui/_form_with_description.html | 7 ++ .../gbpui/form_with_description.html | 7 ++ 31 files changed, 101 insertions(+), 601 deletions(-) create mode 100644 gbpui/common/__init__.py create mode 100644 gbpui/common/forms.py delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_add_consumed.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_add_consumed_prs.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_add_contract.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_add_l3policy.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_add_policy_rule_set.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_add_provided_prs.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_add_vm.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_del_vm.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_ext_add_consumed_prs.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_ext_add_provided_prs.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_ext_remove_consumed_prs.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_ext_remove_provided_prs.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_l3_policy_details.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_remove_consumed.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_remove_consumed_prs.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_remove_contract.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_remove_provided_prs.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_update_external_policy_target.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_update_l3policy.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_update_policy_target.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/_updateepg.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/addepg.html delete mode 100644 gbpui/panels/policytargets/templates/policytargets/updateepg.html create mode 100644 gbpui/templates/gbpui/_form_with_description.html create mode 100644 gbpui/templates/gbpui/form_with_description.html diff --git a/gbpui/common/__init__.py b/gbpui/common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gbpui/common/forms.py b/gbpui/common/forms.py new file mode 100644 index 0000000..09473a5 --- /dev/null +++ b/gbpui/common/forms.py @@ -0,0 +1,33 @@ +# Copyright 2012 Nebula, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from horizon import forms + +from django.core.urlresolvers import reverse + + +class ReversingModalFormView(forms.ModalFormView): + def get_context_data(self, **kwargs): + context = super(ReversingModalFormView, self).get_context_data( + **kwargs) + context['submit_url'] = self.get_submit_url(**kwargs) + return context + + def get_submit_url_params(self, **kwargs): + return {} + + def get_submit_url(self, **kwargs): + submit_params = self.get_submit_url_params(**kwargs) + submit_url = reverse(self.submit_url, kwargs=submit_params) + return submit_url diff --git a/gbpui/panels/policytargets/tabs.py b/gbpui/panels/policytargets/tabs.py index bb21e4b..c191a18 100644 --- a/gbpui/panels/policytargets/tabs.py +++ b/gbpui/panels/policytargets/tabs.py @@ -84,7 +84,7 @@ class PTGDetailsTab(tabs.Tab): name = _("Group Details") slug = "policy_targetdetails" template_name = "project/policytargets/_policy_target_details.html" - failure_url = reverse_lazy('horizon:project:policy_target_group:index') + failure_url = reverse_lazy('horizon:project:policytargets:index') def get_context_data(self, request): policy_targetid = self.tab_group.kwargs['policy_target_id'] diff --git a/gbpui/panels/policytargets/templates/policytargets/_add_consumed.html b/gbpui/panels/policytargets/templates/policytargets/_add_consumed.html deleted file mode 100644 index 1e793ae..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_add_consumed.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}add_consumed_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:add_consumed' policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Add " %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Add Consumed Policy Rule Set. Press Ctrl to select multiple items." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_add_consumed_prs.html b/gbpui/panels/policytargets/templates/policytargets/_add_consumed_prs.html deleted file mode 100644 index 9728072..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_add_consumed_prs.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}add_consumed_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:add_consumed_prs' policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Add " %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Add Consumed Policy Rule Set. Press Ctrl to select multiple items." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_add_contract.html b/gbpui/panels/policytargets/templates/policytargets/_add_contract.html deleted file mode 100644 index b8cfd15..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_add_contract.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}add_contract_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:add_contract' policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Add Policy Rule Set" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Add Policy Rule Set. Press Ctrl to select multiple items." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_add_l3policy.html b/gbpui/panels/policytargets/templates/policytargets/_add_l3policy.html deleted file mode 100644 index 163e822..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_add_l3policy.html +++ /dev/null @@ -1,25 +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:policytargets:addl3policy' %}{% endblock %} - -{% block modal-header %}{% trans "Add L3Policy" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Add L3 Policy." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_add_policy_rule_set.html b/gbpui/panels/policytargets/templates/policytargets/_add_policy_rule_set.html deleted file mode 100644 index a656f07..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_add_policy_rule_set.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}add_contract_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:add_policy_rule_set' policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Add Policy Rule Set" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Add Policy Rule Set. Press Ctrl to select multiple items." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_add_provided_prs.html b/gbpui/panels/policytargets/templates/policytargets/_add_provided_prs.html deleted file mode 100644 index 0acc511..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_add_provided_prs.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}add_consumed_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:add_provided_prs' policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Add Provided PRS" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Add Provided Policy Rule Set. Press Ctrl to select multiple items." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_add_vm.html b/gbpui/panels/policytargets/templates/policytargets/_add_vm.html deleted file mode 100644 index fa5cbb0..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_add_vm.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}add_vm_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:addvm' policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Launch Instance" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Launch instance here." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_del_vm.html b/gbpui/panels/policytargets/templates/policytargets/_del_vm.html deleted file mode 100644 index fa5cbb0..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_del_vm.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}add_vm_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:addvm' policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Launch Instance" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Launch instance here." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_ext_add_consumed_prs.html b/gbpui/panels/policytargets/templates/policytargets/_ext_add_consumed_prs.html deleted file mode 100644 index 14aa82f..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_ext_add_consumed_prs.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}add_consumed_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:ext_add_consumed_prs' ext_policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Add " %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Add Consumed Policy Rule Set. Press Ctrl to select multiple items." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_ext_add_provided_prs.html b/gbpui/panels/policytargets/templates/policytargets/_ext_add_provided_prs.html deleted file mode 100644 index 2686d72..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_ext_add_provided_prs.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}ext_add_provider_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:ext_add_provided_prs' ext_policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Add Provided PRS" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Add Consumed Policy Rule Set. Press Ctrl to select multiple items." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_ext_remove_consumed_prs.html b/gbpui/panels/policytargets/templates/policytargets/_ext_remove_consumed_prs.html deleted file mode 100644 index 1f78cfd..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_ext_remove_consumed_prs.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}remove_contract_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:ext_remove_consumed_prs' ext_policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Remove Policy Rule Set" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Remove Consumed Policy Rule Set. Press Ctrl to select multiple items." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_ext_remove_provided_prs.html b/gbpui/panels/policytargets/templates/policytargets/_ext_remove_provided_prs.html deleted file mode 100644 index 84ab3ea..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_ext_remove_provided_prs.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}add_consumed_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:ext_remove_provided_prs' ext_policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Remove Provided PRS" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Remove Consumed Policy Rule Set. Press Ctrl to select multiple items." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_l3_policy_details.html b/gbpui/panels/policytargets/templates/policytargets/_l3_policy_details.html deleted file mode 100644 index 2d122d7..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_l3_policy_details.html +++ /dev/null @@ -1,17 +0,0 @@ -{% load i18n sizeformat parse_date %} -{% load url from future %} - -
-
-
-
{% trans "Name" %}
-
{{ l3policy.name|default:_("-") }}
- -
{% trans "Description" %}
-
{{ l3policy.description|default:_("-") }}
- -
{% trans "ID" %}
-
{{ l3policy.id }}
-
-
- diff --git a/gbpui/panels/policytargets/templates/policytargets/_remove_consumed.html b/gbpui/panels/policytargets/templates/policytargets/_remove_consumed.html deleted file mode 100644 index 65a074e..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_remove_consumed.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}remove_contract_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:remove_consumed' policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Remove Policy Rule Set" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Remove Consumed Policy Rule Set. Press Ctrl to select multiple items." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_remove_consumed_prs.html b/gbpui/panels/policytargets/templates/policytargets/_remove_consumed_prs.html deleted file mode 100644 index f62d1bd..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_remove_consumed_prs.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}remove_contract_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:remove_consumed_prs' policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Remove Policy Rule Set" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Remove Consumed Policy Rule Set. Press Ctrl to select multiple items." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_remove_contract.html b/gbpui/panels/policytargets/templates/policytargets/_remove_contract.html deleted file mode 100644 index ebb29fb..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_remove_contract.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}remove_contract_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:remove_contract' policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Remove Policy Rule Set" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Remove Policy Rule Set. Press Ctrl to select multiple items." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_remove_provided_prs.html b/gbpui/panels/policytargets/templates/policytargets/_remove_provided_prs.html deleted file mode 100644 index 01bbe70..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_remove_provided_prs.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}add_consumed_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:remove_provided_prs' policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Remove Provided PRS" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Remove Consumed Policy Rule Set. Press Ctrl to select multiple items." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_update_external_policy_target.html b/gbpui/panels/policytargets/templates/policytargets/_update_external_policy_target.html deleted file mode 100644 index 1a7623b..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_update_external_policy_target.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}update_external_policy_target_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:update_ext_policy_target' ext_policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Edit Group" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "You may update external group details here." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_update_l3policy.html b/gbpui/panels/policytargets/templates/policytargets/_update_l3policy.html deleted file mode 100644 index 4e79dd1..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_update_l3policy.html +++ /dev/null @@ -1,25 +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:policytargets:update_l3policy' l3policy_id %}{% endblock %} - -{% block modal-header %}{% trans "Update L3Policy" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Update L3 Policy." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_update_policy_target.html b/gbpui/panels/policytargets/templates/policytargets/_update_policy_target.html deleted file mode 100644 index 8ce2dc0..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_update_policy_target.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}update_policy_target_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:updatepolicy_target' policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Edit Group" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "You may update group details here." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/_updateepg.html b/gbpui/panels/policytargets/templates/policytargets/_updateepg.html deleted file mode 100644 index e17cf3c..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/_updateepg.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}update_policy_target_form{% endblock %} -{% block form_action %}{% url 'horizon:project:policytargets:updatepolicy_target' policy_target_id %}{% endblock %} - -{% block modal-header %}{% trans "Edit Group" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "You may update policy_target details here." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% trans "Cancel" %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/addepg.html b/gbpui/panels/policytargets/templates/policytargets/addepg.html deleted file mode 100644 index c7d705f..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/addepg.html +++ /dev/null @@ -1,11 +0,0 @@ -{% extends 'base.html' %} -{% load i18n %} -{% block title %}{% trans "Create New Group" %}{% endblock %} - -{% block page_header %} - {% include "horizon/common/_page_header.html" with title=_("Create New Group") %} -{% endblock page_header %} - -{% block main %} - {% include 'horizon/common/_workflow.html' %} -{% endblock %} diff --git a/gbpui/panels/policytargets/templates/policytargets/details_tabs.html b/gbpui/panels/policytargets/templates/policytargets/details_tabs.html index 5a1011d..552d681 100644 --- a/gbpui/panels/policytargets/templates/policytargets/details_tabs.html +++ b/gbpui/panels/policytargets/templates/policytargets/details_tabs.html @@ -2,10 +2,6 @@ {% load i18n %} {% block title %}{% trans "Groups" %}{% endblock %} -{% block page_header %} -{% include "horizon/common/_page_header.html" with title=_("Groups") %} -{% endblock page_header %} - {% block main %}
diff --git a/gbpui/panels/policytargets/templates/policytargets/group_details.html b/gbpui/panels/policytargets/templates/policytargets/group_details.html index bb0b140..c7ae02a 100644 --- a/gbpui/panels/policytargets/templates/policytargets/group_details.html +++ b/gbpui/panels/policytargets/templates/policytargets/group_details.html @@ -2,10 +2,6 @@ {% load i18n %} {% block title %}{% trans "Groups Details" %}{% endblock %} -{% block page_header %} -{% include "horizon/common/_page_header.html" with title=_("Group : ")|add:policy_target.name %} -{% endblock page_header %} - {% block main %}
diff --git a/gbpui/panels/policytargets/templates/policytargets/updateepg.html b/gbpui/panels/policytargets/templates/policytargets/updateepg.html deleted file mode 100644 index b49e42f..0000000 --- a/gbpui/panels/policytargets/templates/policytargets/updateepg.html +++ /dev/null @@ -1,11 +0,0 @@ -{% extends 'base.html' %} -{% load i18n %} -{% block title %}{% trans "Edit Endpoint Group" %}{% endblock %} - -{% block page_header %} - {% include "horizon/common/_page_header.html" with title=_("Edit Group ")|add:name %} -{% endblock page_header %} - -{% block main %} - {% include 'project/policy_target_groups/_updatepolicy_target.html' %} -{% endblock %} diff --git a/gbpui/panels/policytargets/views.py b/gbpui/panels/policytargets/views.py index ca9ae3a..1a161d5 100644 --- a/gbpui/panels/policytargets/views.py +++ b/gbpui/panels/policytargets/views.py @@ -24,6 +24,8 @@ from horizon.utils import memoized from horizon import workflows from gbpui import client +from gbpui.common import forms as gbforms + import forms as policy_target_forms import tabs as policy_target_tabs @@ -103,13 +105,13 @@ class UpdatePTGView(forms.ModalFormView): form_class = policy_target_forms.UpdatePolicyTargetForm form_id = "update_policy_target_form" modal_header = _("Edit Group") - template_name = "project/policytargets/update_policy_target.html" + template_name = "gbpui/form_with_description.html" context_object_name = 'policy_target' submit_label = _("Save Changes") submit_url = "horizon:project:policytargets:updatepolicy_target" success_url = reverse_lazy("horizon:project:policytargets:index") page_title = _("Edit Group") - help_text = _("You may update policy details here.") + help_text = _("You may update group details here.") def get_context_data(self, **kwargs): context = super(UpdatePTGView, self).get_context_data(**kwargs) @@ -143,7 +145,7 @@ class UpdateExternalPTGView(forms.ModalFormView): form_class = policy_target_forms.UpdateExternalPolicyTargetForm form_id = "update_policy_target_form" modal_header = _("Edit Group") - template_name = "project/policytargets/update_external_policy_target.html" + template_name = "gbpui/form_with_description.html" context_object_name = 'external_policy_target' submit_label = _("Save Changes") submit_url = "horizon:project:policytargets:update_ext_policy_target" @@ -179,11 +181,11 @@ class UpdateExternalPTGView(forms.ModalFormView): return self.kwargs -class ExtAddProvidedPRSView(forms.ModalFormView): +class ExtAddProvidedPRSView(gbforms.ReversingModalFormView): form_class = policy_target_forms.ExtAddProvidedPRSForm form_id = "ext_add_provided_form" modal_header = _("Add Provided PRS") - template_name = "project/policytargets/ext_add_provided_prs.html" + template_name = "gbpui/form_with_description.html" submit_label = _("Save Changes") submit_url = "horizon:project:policytargets:ext_add_provided_prs" page_title = _("Add Provided PRS") @@ -191,20 +193,20 @@ class ExtAddProvidedPRSView(forms.ModalFormView): "Add provided policy rule set. Press Ctrl to select multiple items." ) - def get_context_data(self, **kwargs): - context = super(ExtAddProvidedPRSView, self).get_context_data(**kwargs) - context["ext_policy_target_id"] = self.kwargs['ext_policy_target_id'] - return context + def get_submit_url_params(self, **kwargs): + return { + 'ext_policy_target_id': self.kwargs['ext_policy_target_id'] + } def get_initial(self): return self.kwargs -class ExtRemoveProvidedPRSView(forms.ModalFormView): +class ExtRemoveProvidedPRSView(gbforms.ReversingModalFormView): form_class = policy_target_forms.ExtRemoveProvidedPRSForm form_id = "ext_remove_provided_form" modal_header = _("Remove Provided PRS") - template_name = "project/policytargets/ext_remove_provided_prs.html" + template_name = "gbpui/form_with_description.html" submit_label = _("Save Changes") submit_url = "horizon:project:policytargets:ext_remove_provided_prs" page_title = _("Remove Provided PRS") @@ -212,21 +214,20 @@ class ExtRemoveProvidedPRSView(forms.ModalFormView): "Remove provided policy rule set. Press Ctrl to select multiple items." ) - def get_context_data(self, **kwargs): - context = super(ExtRemoveProvidedPRSView, self).get_context_data( - **kwargs) - context["ext_policy_target_id"] = self.kwargs['ext_policy_target_id'] - return context + def get_submit_url_params(self, **kwargs): + return { + "ext_policy_target_id": self.kwargs['ext_policy_target_id'] + } def get_initial(self): return self.kwargs -class AddProvidedPRSView(forms.ModalFormView): +class AddProvidedPRSView(gbforms.ReversingModalFormView): form_class = policy_target_forms.AddProvidedPRSForm form_id = "add_provided_form" modal_header = _("Add Provided PRS") - template_name = "project/policytargets/add_provided_prs.html" + template_name = "gbpui/form_with_description.html" submit_label = _("Save Changes") submit_url = "horizon:project:policytargets:add_provided_prs" page_title = _("Add Provided PRS") @@ -234,20 +235,20 @@ class AddProvidedPRSView(forms.ModalFormView): "Add provided policy rule set. Press Ctrl to select multiple items." ) - def get_context_data(self, **kwargs): - context = super(AddProvidedPRSView, self).get_context_data(**kwargs) - context["policy_target_id"] = self.kwargs['policy_target_id'] - return context + def get_submit_url_params(self, **kwargs): + return { + "policy_target_id": self.kwargs['policy_target_id'] + } def get_initial(self): return self.kwargs -class RemoveProvidedPRSView(forms.ModalFormView): +class RemoveProvidedPRSView(gbforms.ReversingModalFormView): form_class = policy_target_forms.RemoveProvidedPRSForm form_id = "remove_provided_form" modal_header = _("Remove Provided PRS") - template_name = "project/policytargets/remove_provided_prs.html" + template_name = "gbpui/form_with_description.html" submit_label = _("Save Changes") submit_url = "horizon:project:policytargets:remove_provided_prs" page_title = _("Remove Provided PRS") @@ -255,20 +256,20 @@ class RemoveProvidedPRSView(forms.ModalFormView): "Remove provided policy rule set. Press Ctrl to select multiple items." ) - def get_context_data(self, **kwargs): - context = super(RemoveProvidedPRSView, self).get_context_data(**kwargs) - context["policy_target_id"] = self.kwargs['policy_target_id'] - return context + def get_submit_url_params(self, **kwargs): + return { + "policy_target_id": self.kwargs['policy_target_id'] + } def get_initial(self): return self.kwargs -class ExtAddConsumedPRSView(forms.ModalFormView): +class ExtAddConsumedPRSView(gbforms.ReversingModalFormView): form_class = policy_target_forms.ExtAddConsumedPRSForm form_id = "ext_add_consumed_form" modal_header = _("Add Policy Rule Set") - template_name = "project/policytargets/ext_add_consumed_prs.html" + template_name = "gbpui/form_with_description.html" submit_label = _("Save Changes") submit_url = "horizon:project:policytargets:ext_add_consumed_prs" page_title = _("Add Policy Rule Set") @@ -276,20 +277,20 @@ class ExtAddConsumedPRSView(forms.ModalFormView): "Add consumed policy rule set. Press Ctrl to select multiple items." ) - def get_context_data(self, **kwargs): - context = super(ExtAddConsumedPRSView, self).get_context_data(**kwargs) - context["ext_policy_target_id"] = self.kwargs['ext_policy_target_id'] - return context + def get_submit_url_params(self, **kwargs): + return { + "ext_policy_target_id": self.kwargs['ext_policy_target_id'] + } def get_initial(self): return self.kwargs -class ExtRemoveConsumedPRSView(forms.ModalFormView): +class ExtRemoveConsumedPRSView(gbforms.ReversingModalFormView): form_class = policy_target_forms.ExtRemoveConsumedPRSForm form_id = "remove_contract_form" modal_header = _("Remove Policy Rule Set") - template_name = "project/policytargets/ext_remove_consumed_prs.html" + template_name = "gbpui/form_with_description.html" submit_label = _("Save Changes") submit_url = "horizon:project:policytargets:ext_remove_consumed_prs" page_title = _("Remove Policy Rule Set") @@ -297,21 +298,20 @@ class ExtRemoveConsumedPRSView(forms.ModalFormView): "Remove consumed policy rule set. Press Ctrl to select multiple items." ) - def get_context_data(self, **kwargs): - context = super(ExtRemoveConsumedPRSView, self).get_context_data( - **kwargs) - context["ext_policy_target_id"] = self.kwargs['ext_policy_target_id'] - return context + def get_submit_url_params(self, **kwargs): + return { + "ext_policy_target_id": self.kwargs['ext_policy_target_id'] + } def get_initial(self): return self.kwargs -class AddConsumedPRSView(forms.ModalFormView): +class AddConsumedPRSView(gbforms.ReversingModalFormView): form_class = policy_target_forms.AddConsumedPRSForm form_id = "add_consumed_form" modal_header = _("Add ") - template_name = "project/policytargets/add_consumed_prs.html" + template_name = "gbpui/form_with_description.html" submit_label = _("Save Changes") submit_url = "horizon:project:policytargets:add_consumed_prs" page_title = _("Add ") @@ -319,20 +319,20 @@ class AddConsumedPRSView(forms.ModalFormView): "Add consumed policy rule set. Press Ctrl to select multiple items." ) - def get_context_data(self, **kwargs): - context = super(AddConsumedPRSView, self).get_context_data(**kwargs) - context["policy_target_id"] = self.kwargs['policy_target_id'] - return context + def get_submit_url_params(self, **kwargs): + return { + "policy_target_id": self.kwargs['policy_target_id'] + } def get_initial(self): return self.kwargs -class RemoveConsumedPRSView(forms.ModalFormView): +class RemoveConsumedPRSView(gbforms.ReversingModalFormView): form_class = policy_target_forms.RemoveConsumedPRSForm form_id = "remove_contract_form" modal_header = _("Remove Policy Rule Set") - template_name = "project/policytargets/remove_consumed_prs.html" + template_name = "gbpui/form_with_description.html" submit_label = _("Save Changes") submit_url = "horizon:project:policytargets:remove_consumed_prs" page_title = _("Remove Policy Rule Set") @@ -340,10 +340,10 @@ class RemoveConsumedPRSView(forms.ModalFormView): "Remove consumed policy rule set. Press Ctrl to select multiple items." ) - def get_context_data(self, **kwargs): - context = super(RemoveConsumedPRSView, self).get_context_data(**kwargs) - context["policy_target_id"] = self.kwargs['policy_target_id'] - return context + def get_submit_url_params(self, **kwargs): + return { + "policy_target_id": self.kwargs['policy_target_id'] + } def get_initial(self): return self.kwargs diff --git a/gbpui/templates/gbpui/_form_with_description.html b/gbpui/templates/gbpui/_form_with_description.html new file mode 100644 index 0000000..8ffa7ac --- /dev/null +++ b/gbpui/templates/gbpui/_form_with_description.html @@ -0,0 +1,7 @@ +{% extends "horizon/common/_modal_form.html" %} +{% load i18n %} + +{% block modal-body-right %} +

{% trans "Description:" %}

+

{{ help_text }}

+{% endblock %} diff --git a/gbpui/templates/gbpui/form_with_description.html b/gbpui/templates/gbpui/form_with_description.html new file mode 100644 index 0000000..b519af1 --- /dev/null +++ b/gbpui/templates/gbpui/form_with_description.html @@ -0,0 +1,7 @@ +{% extends 'base.html' %} +{% load i18n %} +{% block title %}{% if base_form_title %}{{ base_form_title }}{% else %}{{ page_title }}{% endif %}{% endblock %} + +{% block main %} + {% include 'gbpui/_form_with_description.html' %} +{% endblock %}