Transform one form to many in the add abac permission template

This commit is contained in:
Mikaël Ates 2011-08-06 09:47:26 +02:00
parent 59515aeeb6
commit 91572594f3
1 changed files with 34 additions and 4 deletions

View File

@ -19,8 +19,6 @@
{% endif %}
<div>
<form method="post" action="">
<p>
<h3>{% trans "Predicate Definitions" %}</h3>
@ -39,12 +37,14 @@
{% if working_predicate.definition_name %}
<p>{% trans "Add a source:" %}
<form method="post" action="">
<select name="source_id" id="source">
{% for source in sources %}
<option value="{{ source.id }}">{{ source.name }}</option>
{% endfor %}
</select>
<input type="submit" name="select_source" value="{% trans "Add" %}"/>
</form>
</p>
{% if working_predicate.sources_selected %}
@ -56,19 +56,23 @@
</ul>
</p>
<p>
<form method="post" action="">
<input type="submit" name="close_working_predicate" value="{% trans "Finish predicate" %}"/>
</form>
</p>
{% endif %}
{% else %}
<p>{% trans "Choose an attribute definition:" %}
<form method="post" action="">
<select name="attribute_definition_id" id="attribute_definition">
{% for attr_definition in attribute_definitions %}
<option value="{{ attr_definition.id }}">{{ attr_definition.attribute_name }}</option>
{% endfor %}
</select>
<input type="submit" name="select_attribute_definition" value="{% trans "Ok" %}"/>
</form>
</p>
{% endif %}
@ -119,31 +123,37 @@
{% else %}
<p>{% trans "Choose operand 2 type:" %}
{% endif %}
<form method="post" action="">
<input type="submit" name="operand_is_definition" value="{% trans "Attribute" %}"/>
<input type="submit" name="operand_is_definition_data" value="{% trans "Attribute value" %}"/>
</form>
</p>
{% else %}
<p>{% trans "The operand definition in progress is a" %} <strong>{{ working_predicate.working_operand.type }}</strong></p>
{% if not working_predicate.working_operand.definition_name %}
<p>{% trans "Choose an attribute definition:" %}
<form method="post" action="">
<select name="attribute_definition_id" id="attribute_definition">
{% for attr_definition in attribute_definitions %}
<option value="{{ attr_definition.id }}">{{ attr_definition.attribute_name }}</option>
{% endfor %}
</select>
<input type="submit" name="select_attribute_definition_operand" value="{% trans "Ok" %}"/>
</form>
</p>
{% else %}
<p>{% trans "On attribute" %} <strong>{{ working_predicate.working_operand.definition_name }}</strong></p>
{% if working_predicate.working_operand.type == "definition" %}
<p>{% trans "Add a source:" %}
<form method="post" action="">
<select name="source_operand_id" id="source">
{% for source in sources %}
<option value="{{ source.id }}">{{ source.name }}</option>
{% endfor %}
</select>
<input type="submit" name="select_source_operand" value="{% trans "Add" %}"/>
</form>
</p>
{% if working_predicate.working_operand.sources_selected %}
@ -155,15 +165,19 @@
</ul>
</p>
<p>
<form method="post" action="">
<input type="submit" name="close_working_operand" value="{% trans "Finish operand" %}"/>
</form>
</p>
{% endif %}
{% else %}
<p>{% trans "Add a value:" %}
<form method="post" action="">
<input type="text" name="value_operand" label="{% trans "Give a value to test" %}"/>
<input type="submit" name="value_operand_submitted" value="{% trans "Add" %}"/>
</form>
</p>
{% if working_predicate.working_operand.values_selected %}
@ -175,7 +189,9 @@
</ul>
</p>
<p>
<form method="post" action="">
<input type="submit" name="close_working_operand" value="{% trans "Finish operand" %}"/>
</form>
</p>
{% endif %}
@ -183,19 +199,25 @@
{% endif %}
<p>
<br style="clear: both;"/>
<form method="post" action="">
<input type="submit" name="delete_working_operand" value="{% trans "Cancel operand" %}"/>
</form>
<p>
{% endif %}
{% else %}
<p>
<form method="post" action="">
<input type="submit" name="close_working_predicate" value="{% trans "Finish predicate" %}"/>
</form>
</p>
{% endif %}
{% endif %}
<br style="clear: both;"/>
<form method="post" action="">
<input type="submit" name="delete_working_predicate" value="{% trans "Cancel predicate" %}"/>
</form>
</p>
{% endif %}
@ -245,8 +267,10 @@
{% endif %}
</li>
<br style="clear: both;"/>
<form method="post" action="">
<input type="hidden" name="predicate_id" value="{{ p_id }}"/>
<input type="submit" name="delete_predicate" value="{% trans "Delete" %}"/>
</form>
</ul>
</li>
<br style="clear: both;"/>
@ -259,12 +283,14 @@
<p>
<strong>{% trans "Add a new predicate:" %}</strong>
<br style="clear: both;"/>
<form method="post" action="">
<select name="predicate_type" id="id_new_predicate">
{% for predicate_type, friendly_name in predicate_types %}
<option value="{{ predicate_type }}">{{ friendly_name }}</option>
{% endfor %}
</select>
<input type="submit" name="new_predicate" value="{% trans "Add a predicate" %}"/>
</form>
</p>
{% endif %}
</p>
@ -275,14 +301,17 @@
<h3>{% trans "Define the logic expression combining predicates" %}</h3>
<strong>{% trans "Use the predicates identifier. AND is '&', OR is '|', NOT is '-'. Use parenthesis for priority." %} (e.g. (1&2)|(-3))</strong>
<br style="clear: both;"/>
<form method="post" action="">
<input type="text" name="rule_string" label="{% trans "Define rule" %}" {% if rule %}value="{{ rule }}"{% endif %}/>
<input type="submit" name="set_rule" value="{% trans "Set" %}"/>
</form>
<p>
{% if rule %}
{% if what_to_display and how_to_display %}
<form method="post" action="">
<p>
<h3>{% trans "What" %}</h3>
<select name="what_matches" id="id_what_matches">
@ -303,6 +332,7 @@
<br style="clear: both;"/>
<input type="submit" name="add_permission" value="{% trans "Add" %}"/>
</p>
</form>
{% else %}
@ -317,9 +347,9 @@
{% endif %}
<br style="clear: both;"/>
<form method="post" action="">
<input type="submit" name="cancel_all" value="{% trans "Cancel" %}"/>
</form>
</form>
</div>
<p><a href="{{ backlink }}">{% trans "Back" %}</a></p>