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 <marek.lycka@ultimum.io>
Change-Id: I4f8f6cef04fd514eccb428e8a89cc030ae99cb2a
This commit is contained in:
Aleš Křivák 2017-08-14 19:06:51 +02:00 committed by Marek Lycka
parent 8e80d41aec
commit 268ae1259a
31 changed files with 101 additions and 601 deletions

0
gbpui/common/__init__.py Normal file
View File

33
gbpui/common/forms.py Normal file
View File

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

View File

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

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Add Consumed Policy Rule Set. Press Ctrl to select multiple items." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:policytargets:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Add Consumed Policy Rule Set. Press Ctrl to select multiple items." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:policytargets:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Add Policy Rule Set. Press Ctrl to select multiple items." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:policytargets:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

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

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Add Policy Rule Set. Press Ctrl to select multiple items." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:policytargets:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Add Provided Policy Rule Set. Press Ctrl to select multiple items." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:policytargets:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Launch instance here." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Launch" %}" />
<a href="{% url 'horizon:project:policytargets:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Launch instance here." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Launch" %}" />
<a href="{% url 'horizon:project:policytargets:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Add Consumed Policy Rule Set. Press Ctrl to select multiple items." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:policytargets:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Add Consumed Policy Rule Set. Press Ctrl to select multiple items." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:policytargets:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Remove Consumed Policy Rule Set. Press Ctrl to select multiple items." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:policytargets:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Remove Consumed Policy Rule Set. Press Ctrl to select multiple items." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:policytargets:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -1,17 +0,0 @@
{% load i18n sizeformat parse_date %}
{% load url from future %}
<div class="info row detail">
<hr class="header_rule">
<dl>
<dt>{% trans "Name" %}</dt>
<dd>{{ l3policy.name|default:_("-") }}</dd>
<dt>{% trans "Description" %}</dt>
<dd>{{ l3policy.description|default:_("-") }}</dd>
<dt>{% trans "ID" %}</dt>
<dd>{{ l3policy.id }} </dd>
</dl>
</div>

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Remove Consumed Policy Rule Set. Press Ctrl to select multiple items." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:policytargets:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Remove Consumed Policy Rule Set. Press Ctrl to select multiple items." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:policytargets:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Remove Policy Rule Set. Press Ctrl to select multiple items." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:policytargets:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Remove Consumed Policy Rule Set. Press Ctrl to select multiple items." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:policytargets:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 %}
<div class="row">
<div class="col-sm-12">

View File

@ -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 %}
<div class="row">
<div class="col-sm-12">

View File

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

View File

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

View File

@ -0,0 +1,7 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% block modal-body-right %}
<h3>{% trans "Description:" %}</h3>
<p>{{ help_text }}</p>
{% endblock %}

View File

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