Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

[OpenKAT v1.5] Fix boefje detail checkboxes function at scan oois #111

Merged
merged 9 commits into from
Jan 16, 2023
36 changes: 18 additions & 18 deletions katalogus/templates/partials/objects_to_scan.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,32 @@
{% translate 'Object list' as form_title %}
<div>
<h2>{{ form_title }}</h2>

<p>
{% blocktranslate trimmed with scan_level=plugin.scan_level %}
This boefje will only scan objects with a corresponding clearance level of <strong>L{{ scan_level }}</strong>
or higher. There is no indemnification for this boefje to scan an OOI with a lower clearance level then <strong>L{{ scan_level }}</strong>. Use the filter to show OOI's with a lower clearance level.
or higher. There is no indemnification for this boefje to scan an OOI with a lower clearance level than <strong>L{{ scan_level }}</strong>. Use the filter to show OOI's with a lower clearance level.
{% endblocktranslate %}
</p>

<div class="horizontal-view toolbar">
<div>
<form method="get" class="inline">
<div class="horizontal-view">
{% include 'partials/form/form_errors.html' with form=select_ooi_filter_form %}
{% for field in select_ooi_filter_form %}{{ field }}{% endfor %}
{% for field in select_ooi_filter_form %}
<input type="{{ field.field.widget.input_type }}"
name="{{ field.name }}"
class="{{ field.field.widget.attrs.class }}"
{% if 'show_all=on' in request.get_full_path %}checked{% endif %}/>
<label>{{ field.label }}</label>
{% endfor %}
</div>
</form>
</div>
</div>

{% if 'show_all=on' in request.get_full_path %}
underdarknl marked this conversation as resolved.
Show resolved Hide resolved
{% if 'show_all=on' in request.get_full_path and select_oois_form.fields.ooi.choices %}
<p class="warning"
role="group"
aria-label="{% translate 'scan level warning' %}">
role="group"
aria-label="{% translate 'scan level warning' %}">
{% blocktranslate %}
<span>Warning scan level:</span>
Scanning OOI's with a lower clearance level will result in KAT increasing the clearance level on that OOI,
Expand All @@ -35,24 +38,21 @@ <h2>{{ form_title }}</h2>
{% endblocktranslate %}
</p>
{% endif %}

{% if select_oois_form.fields.ooi.choices %}
{% include 'partials/form/checkbox_group_table_form.html' with checkbox_group_table_form=select_oois_form btn_text='Start scan' plugin_enabled=plugin.enabled key='boefje_id' value=plugin.id action="scan" checkbox_group_table_filter_form=select_ooi_filter_form unique_id="" %}
{% else %}
{% if has_consumable_oois %}
{% blocktranslate %}
You currently don't have any objects that meet the scan level of {{ plugin.name }}.
{% elif has_consumable_oois %}
{% blocktranslate with name=plugin.name%}
You currently don't have any objects that meet the scan level of {{ name }}.
Add objects with a complying clearance level, or alter the clearance level of existing objects.
{% endblocktranslate %}
{% else %}
{% blocktranslate %}
You currently don't have scannable objects for {{ plugin.name }}.
{% else %}
{% blocktranslate with name=plugin.name%}
You currently don't have scannable objects for {{ name }}.
Add objects to use this boefje. This boefje is able to scan objects of the following types:
{% endblocktranslate %}
{% endif %}
<p>
{% for ooi in plugin.consumes %}
<a href="{% url 'ooi_add' ooi %}">{{ ooi }}</a>
<a href="{% url 'ooi_add' ooi_type=ooi organization_code=organization.code %}">{{ ooi }}</a>
{% if ooi != plugin.consumes|last %}-{% endif %}
{% endfor %}
</p>
Expand Down
4 changes: 2 additions & 2 deletions katalogus/views/plugin_detail_scan_oois.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["select_ooi_filter_form"] = SelectOOIFilterForm
if "show_all" in self.request.GET:
context["select_oois_form"] = SelectOOIForm(self.get_form_consumable_oois())
context["select_oois_form"] = SelectOOIForm(oois=self.get_form_consumable_oois())
else:
context["select_oois_form"] = SelectOOIForm(self.get_form_filtered_consumable_oois())
context["select_oois_form"] = SelectOOIForm(oois=self.get_form_filtered_consumable_oois())
return context
2 changes: 1 addition & 1 deletion rocky/templates/forms/widgets/checkbox_group_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<thead>
<tr>
<th>
{% if widget.options|length > 1 %}<input name="toggle-all" type="checkbox"/>{% endif %}
{% if widget.options|length > 1 %}<input class="toggle-all" data-toggle-target="ooi" type="checkbox"/>{% endif %}
</th>
{% for column_name in widget.column_names %}<th>{{ column_name }}</th>{% endfor %}
</tr>
Expand Down
6 changes: 3 additions & 3 deletions tools/forms/ooi.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ def _to_choice(ooi: OOI) -> Tuple[str, Any]:

class SelectOOIFilterForm(BaseRockyForm):
show_all = forms.NullBooleanField(
widget=LabeledCheckboxInput(
label=_("Show objects that don't meet the Boefjes scan level"),
autosubmit=True,
label=_("Show objects that don't meet the Boefjes scan level"),
widget=forms.CheckboxInput(
attrs={"class": "submit-on-click"},
),
)

Expand Down