From 042c70d20f8791d7d8ad8851445311b5c65805c2 Mon Sep 17 00:00:00 2001 From: Akhil Raj Date: Wed, 15 Jun 2022 17:16:19 +0530 Subject: [PATCH] Enable sorting project list by name and creation date #413 [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 --- scanpipe/filters.py | 3 +++ .../scanpipe/includes/project_list_table.html | 3 ++- scanpipe/templates/scanpipe/project_list.html | 24 +++++++++++++++++-- scanpipe/views.py | 2 +- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/scanpipe/filters.py b/scanpipe/filters.py index 1f322fb81..60f5f75ea 100644 --- a/scanpipe/filters.py +++ b/scanpipe/filters.py @@ -88,6 +88,9 @@ def verbose_name_plural(cls): class ProjectFilterSet(FilterSetUtilsMixin, django_filters.FilterSet): search = django_filters.CharFilter(field_name="name", lookup_expr="icontains") + sort = django_filters.OrderingFilter( + fields=(("name", "name"), ("created_date", "created_date")), + ) class Meta: model = Project diff --git a/scanpipe/templates/scanpipe/includes/project_list_table.html b/scanpipe/templates/scanpipe/includes/project_list_table.html index a525ff392..231f89fda 100644 --- a/scanpipe/templates/scanpipe/includes/project_list_table.html +++ b/scanpipe/templates/scanpipe/includes/project_list_table.html @@ -15,6 +15,7 @@ {{ project }} + Created {{ project.created_date|naturaltime }} {% if project.package_count %} @@ -65,4 +66,4 @@ {% endfor %} - \ No newline at end of file + diff --git a/scanpipe/templates/scanpipe/project_list.html b/scanpipe/templates/scanpipe/project_list.html index bbbae8802..2a601d375 100644 --- a/scanpipe/templates/scanpipe/project_list.html +++ b/scanpipe/templates/scanpipe/project_list.html @@ -21,7 +21,27 @@ {% endif %} - New Project +
+ + New Project +
{% include 'scanpipe/includes/search_field.html' %} @@ -49,4 +69,4 @@ {% include 'scanpipe/includes/run_modal.html' %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/scanpipe/views.py b/scanpipe/views.py index fc2fed203..c38288b37 100644 --- a/scanpipe/views.py +++ b/scanpipe/views.py @@ -102,7 +102,7 @@ class ProjectListView( filterset_class = ProjectFilterSet template_name = "scanpipe/project_list.html" prefetch_related = ["runs"] - paginate_by = 10 + paginate_by = 20 def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs)