Skip to content

Commit 2deeb8c

Browse files
authored
Enable sorting project list by name and creation date #413 (#446)
[x] Increase table rows to 20 [x] Added created date column in project table [x] Support sorting by name and creation date of the project Signed-off-by: Akhil Raj <[email protected]>
1 parent 7f3de27 commit 2deeb8c

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

scanpipe/filters.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ def verbose_name_plural(cls):
8888

8989
class ProjectFilterSet(FilterSetUtilsMixin, django_filters.FilterSet):
9090
search = django_filters.CharFilter(field_name="name", lookup_expr="icontains")
91+
sort = django_filters.OrderingFilter(
92+
fields=(("name", "name"), ("created_date", "created_date")),
93+
)
9194

9295
class Meta:
9396
model = Project

scanpipe/templates/scanpipe/includes/project_list_table.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@
6666
</tr>
6767
{% endfor %}
6868
</tbody>
69-
</table>
69+
</table>

scanpipe/templates/scanpipe/project_list.html

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,27 @@
2121
</a>
2222
{% endif %}
2323
</div>
24-
<a href="{% url 'project_add' %}" class="button is-link">New Project</a>
24+
<div>
25+
<div class="dropdown is-right is-hoverable">
26+
<div class="dropdown-trigger">
27+
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu">
28+
<span>Sort</span>
29+
<span class="icon is-small">
30+
<i class="fas fa-angle-down" aria-hidden="true"></i>
31+
</span>
32+
</button>
33+
</div>
34+
<div class="dropdown-menu" id="dropdown-sort-filters" role="menu">
35+
<div class="dropdown-content">
36+
<a href="?sort=name" class="dropdown-item">Name (A-Z)</a>
37+
<a href="?sort=-name" class="dropdown-item">Name (Z-A)</a>
38+
<a href="?sort=created_date" class="dropdown-item">Oldest</a>
39+
<a href="?sort=-created_date" class="dropdown-item">Newest</a>
40+
</div>
41+
</div>
42+
</div>
43+
<a href="{% url 'project_add' %}" class="button is-link">New Project</a>
44+
</div>
2545
</div>
2646

2747
{% include 'scanpipe/includes/search_field.html' %}
@@ -49,4 +69,4 @@
4969
</div>
5070

5171
{% include 'scanpipe/includes/run_modal.html' %}
52-
{% endblock %}
72+
{% endblock %}

scanpipe/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class ProjectListView(
185185
filterset_class = ProjectFilterSet
186186
template_name = "scanpipe/project_list.html"
187187
prefetch_related = ["runs"]
188-
paginate_by = 10
188+
paginate_by = 20
189189

190190
def get_context_data(self, **kwargs):
191191
context = super().get_context_data(**kwargs)

0 commit comments

Comments
 (0)