Skip to content

Commit

Permalink
Add a select_across checkbox on the ProjectReportForm #1524
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez committed Jan 13, 2025
1 parent ce4e46a commit a5d756d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
6 changes: 6 additions & 0 deletions scanpipe/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@ class ProjectReportForm(forms.Form):
initial="discoveredpackage",
widget=forms.RadioSelect,
)
select_across = forms.BooleanField(
label="",
required=False,
initial=0,
help_text="All project matching current search and filters will be included.",
)


class ListTextarea(forms.CharField):
Expand Down
2 changes: 0 additions & 2 deletions scanpipe/templates/registration/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<div class="field">
<label class="label">Username</label>
<div class="control has-icons-left">
<!-- {{ form.username }}-->
<input class="input" type="text" name="username" autofocus autocomplete="username" maxlength="150" required id="id_username">
<span class="icon is-small is-left">
<i class="fa-solid fa-user"></i>
Expand All @@ -32,7 +31,6 @@
<div class="field mb-5">
<label class="label">Password</label>
<div class="control has-icons-left">
<!-- {{ form.password }}-->
<input class="input" type="password" name="password" autocomplete="current-password" required id="id_password">
<span class="icon is-small is-left">
<i class="fa-solid fa-lock"></i>
Expand Down
17 changes: 14 additions & 3 deletions scanpipe/templates/scanpipe/modals/projects_report_modal.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% load humanize %}
<div class="modal" id="modal-projects-report">
<div class="modal-background"></div>
<div class="modal-card">
Expand All @@ -7,9 +8,19 @@
</header>
<form action="{% url 'project_action' %}" method="post" id="report-projects-form">{% csrf_token %}
<section class="modal-card-body">
<ul class="mb-3">
{{ report_form.as_ul }}
</ul>
<div class="field">
<label class="label">{{ report_form.model_name.label }}</label>
<div class="control">
{{ report_form.model_name }}
</div>
</div>
<div class="field">
<label class="checkbox" for="{{ report_form.select_across.id_for_label }}">
<input type="checkbox" name="{{ report_form.select_across.name }}" id="{{ report_form.select_across.id_for_label }}">
Include all {{ paginator.count|intcomma }} projects
</label>
<p class="help">{{ report_form.select_across.help_text }}</p>
</div>
</section>
<input type="hidden" name="action" value="report">
<footer class="modal-card-foot is-flex is-justify-content-space-between">
Expand Down
6 changes: 4 additions & 2 deletions scanpipe/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,13 +1232,15 @@ def export_xlsx_file_response(self):

return super().export_xlsx_file_response()

def get_projects_queryset(self):
def get_projects_queryset(self, select_across=False):
# TODO: select_across
return Project.objects.filter(pk__in=self.selected_project_ids)

def get_export_xlsx_queryset(self):
model_name = self.report_form.cleaned_data["model_name"]
select_across = self.report_form.cleaned_data["select_across"]
queryset = output.get_queryset(project=None, model_name=model_name)
projects = self.get_projects_queryset()
projects = self.get_projects_queryset(select_across=select_across)
return queryset.filter(project__in=projects)

def get_export_xlsx_prepend_fields(self):
Expand Down

0 comments on commit a5d756d

Please sign in to comment.