Skip to content

Commit 25bf560

Browse files
committed
Use html_name in place of field name attribute #1743
Signed-off-by: tdruez <[email protected]>
1 parent 67fc2c3 commit 25bf560

File tree

10 files changed

+29
-22
lines changed

10 files changed

+29
-22
lines changed

scanpipe/templates/scanpipe/forms/project_clone_form.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</div>
3737
<div class="field">
3838
<label class="checkbox" for="{{ form.execute_now.id_for_label }}-clone">
39-
<input type="checkbox" name="{{ form.execute_now.name }}" id="{{ form.execute_now.id_for_label }}-clone">
39+
<input type="checkbox" name="{{ form.execute_now.html_name }}" id="{{ form.execute_now.id_for_label }}-clone">
4040
{{ form.execute_now.label }}
4141
</label>
4242
<p class="help">{{ form.execute_now.help_text }}</p>

scanpipe/templates/scanpipe/forms/project_settings_form.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</div>
1212
</div>
1313
<div class="field">
14-
<label class="label" for="{{ form.name.id_for_label }}">
14+
<label class="label" for="{{ form.purl.id_for_label }}">
1515
PURL
1616
</label>
1717
<div class="control">

scanpipe/templates/scanpipe/includes/search_field.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{% endif %}
55
<form method="get">
66
<p class="control has-icons-left">
7-
<input class="input {{ extra_class }}" type="search" placeholder="{% if placeholder %}{{ placeholder }}{% else %}Search {{ filter.verbose_name_plural }}{% endif %}" name="{{ filter.form.search.name }}" value="{{ filter.form.search.value|default_if_none:'' }}">
7+
<input class="input {{ extra_class }}" type="search" placeholder="{% if placeholder %}{{ placeholder }}{% else %}Search {{ filter.verbose_name_plural }}{% endif %}" name="{{ filter.form.search.html_name }}" value="{{ filter.form.search.value|default_if_none:'' }}">
88
<span class="icon is-small is-left">
99
<i class="fa-solid fa-search"></i>
1010
</span>

scanpipe/templates/scanpipe/modals/projects_archive_modal.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838
<hr>
3939
<div class="field include-all-field">
4040
<label class="checkbox" for="{{ archive_form.select_across.id_for_label }}">
41-
<input type="checkbox" name="{{ archive_form.select_across.name }}" id="{{ archive_form.select_across.id_for_label }}">
41+
<input type="checkbox" name="{{ archive_form.select_across.html_name }}" id="{{ archive_form.select_across.id_for_label }}">
4242
Include all {{ paginator.count|intcomma }} projects
4343
</label>
4444
<p class="help">{{ outputs_download_form.select_across.help_text }}</p>
4545
</div>
4646
</div>
4747
{% endif %}
4848
</section>
49-
<input type="hidden" name="{{ archive_form.url_query.name }}" value="{{ request.GET.urlencode }}">
49+
<input type="hidden" name="{{ archive_form.url_query.html_name }}" value="{{ request.GET.urlencode }}">
5050
<input type="hidden" name="action" value="archive">
5151
<footer class="modal-card-foot is-justify-content-flex-end">
5252
<div class="buttons">

scanpipe/templates/scanpipe/modals/projects_delete_modal.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</p>
2323
</section>
2424
<form action="{% url 'project_action' %}" method="post" id="delete-projects-form">{% csrf_token %}
25-
<input type="hidden" name="{{ action_form.url_query.name }}" value="{{ request.GET.urlencode }}">
25+
<input type="hidden" name="{{ action_form.url_query.html_name }}" value="{{ request.GET.urlencode }}">
2626
<input type="hidden" name="action" value="delete">
2727
<footer class="modal-card-foot is-justify-content-flex-end">
2828
<div class="buttons">

scanpipe/templates/scanpipe/modals/projects_download_modal.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
<hr>
2020
<div class="field">
2121
<label class="checkbox" for="{{ outputs_download_form.select_across.id_for_label }}">
22-
<input type="checkbox" name="{{ outputs_download_form.select_across.name }}" id="{{ outputs_download_form.select_across.id_for_label }}">
22+
<input type="checkbox" name="{{ outputs_download_form.select_across.html_name }}" id="{{ outputs_download_form.select_across.id_for_label }}">
2323
Include all {{ paginator.count|intcomma }} projects
2424
</label>
2525
<p class="help">{{ outputs_download_form.select_across.help_text }}</p>
2626
</div>
2727
</div>
2828
{% endif %}
2929
</section>
30-
<input type="hidden" name="{{ outputs_download_form.url_query.name }}" value="{{ request.GET.urlencode }}">
30+
<input type="hidden" name="{{ outputs_download_form.url_query.html_name }}" value="{{ request.GET.urlencode }}">
3131
<input type="hidden" name="action" value="download">
3232
<footer class="modal-card-foot is-justify-content-flex-end">
3333
<div class="buttons">

scanpipe/templates/scanpipe/modals/projects_report_modal.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
<hr>
2020
<div class="field include-all-field">
2121
<label class="checkbox" for="{{ report_form.select_across.id_for_label }}">
22-
<input type="checkbox" name="{{ report_form.select_across.name }}" id="{{ report_form.select_across.id_for_label }}">
22+
<input type="checkbox" name="{{ report_form.select_across.html_name }}" id="{{ report_form.select_across.id_for_label }}">
2323
Include all {{ paginator.count|intcomma }} projects
2424
</label>
2525
<p class="help">{{ report_form.select_across.help_text }}</p>
2626
</div>
2727
</div>
2828
{% endif %}
2929
</section>
30-
<input type="hidden" name="{{ report_form.url_query.name }}" value="{{ request.GET.urlencode }}">
30+
<input type="hidden" name="{{ report_form.url_query.html_name }}" value="{{ request.GET.urlencode }}">
3131
<input type="hidden" name="action" value="report">
3232
<footer class="modal-card-foot is-justify-content-flex-end">
3333
<div class="buttons">

scanpipe/templates/scanpipe/modals/projects_reset_modal.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@
4040
<hr>
4141
<div class="field include-all-field">
4242
<label class="checkbox" for="{{ reset_form.select_across.id_for_label }}">
43-
<input type="checkbox" name="{{ reset_form.select_across.name }}" id="{{ reset_form.select_across.id_for_label }}">
43+
<input type="checkbox" name="{{ reset_form.select_across.html_name }}" id="{{ reset_form.select_across.id_for_label }}">
4444
Include all {{ paginator.count|intcomma }} projects
4545
</label>
4646
<p class="help">{{ outputs_download_form.select_across.help_text }}</p>
4747
</div>
4848
</div>
4949
{% endif %}
5050
</section>
51-
<input type="hidden" name="{{ action_form.url_query.name }}" value="{{ request.GET.urlencode }}">
51+
<input type="hidden" name="{{ reset_form.url_query.html_name }}" value="{{ request.GET.urlencode }}">
5252
<input type="hidden" name="action" value="reset">
5353
<footer class="modal-card-foot is-justify-content-flex-end">
5454
<div class="buttons">

scanpipe/tests/test_views.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,22 @@ def test_scanpipe_views_project_list_modal_forms_include_url_query(self):
174174
url = reverse("project_list")
175175
response = self.client.get(url)
176176

177-
expected = '<input type="hidden" name="url_query" value="">'
178-
self.assertContains(response, expected, html=True)
177+
expected_html_names = [
178+
"url_query",
179+
"download-url_query",
180+
"report-url_query",
181+
"archive-url_query",
182+
"reset-url_query",
183+
]
184+
for html_name in expected_html_names:
185+
expected = f'<input type="hidden" name="{html_name}" value="">'
186+
self.assertContains(response, expected, html=True)
179187

180188
url_query = "name=search_value"
181189
response = self.client.get(url + "?" + url_query)
182-
expected = f'<input type="hidden" name="url_query" value="{url_query}">'
183-
self.assertContains(response, expected, html=True)
190+
for html_name in expected_html_names:
191+
expected = f'<input type="hidden" name="{html_name}" value="{url_query}">'
192+
self.assertContains(response, expected, html=True)
184193

185194
@mock.patch("scanpipe.views.ProjectListView.get_paginate_by")
186195
def test_scanpipe_views_project_list_modal_forms_include_show_on_all_checked(

scanpipe/views.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,14 +1351,12 @@ def get_project_queryset(selected_project_ids=None, action_form=None):
13511351
An instance of BaseProjectActionForm can be provided as the ``action_form``
13521352
argument for the support of ``select_across``.
13531353
"""
1354-
if action_form:
1355-
select_across = action_form.cleaned_data.get("select_across")
1354+
if action_form and action_form.cleaned_data.get("select_across"):
13561355
# url_query may be empty for a "select everything"
13571356
url_query = action_form.cleaned_data.get("url_query", "")
1358-
if select_across:
1359-
project_filterset = ProjectFilterSet(data=QueryDict(url_query))
1360-
if project_filterset.is_valid():
1361-
return project_filterset.qs
1357+
project_filterset = ProjectFilterSet(data=QueryDict(url_query))
1358+
if project_filterset.is_valid():
1359+
return project_filterset.qs
13621360

13631361
if selected_project_ids:
13641362
return Project.objects.filter(uuid__in=selected_project_ids)

0 commit comments

Comments
 (0)