diff --git a/django_project/certification/templates/certifying_organisation/pending-list.html b/django_project/certification/templates/certifying_organisation/pending-list.html index d61cf941a..6708c5730 100644 --- a/django_project/certification/templates/certifying_organisation/pending-list.html +++ b/django_project/certification/templates/certifying_organisation/pending-list.html @@ -9,6 +9,9 @@ table td { background-color: white; } + .sort-header { + background-color: #EEEEEE; + } {% endblock %} @@ -62,12 +65,22 @@

No certifying organisations are defined, but you can +
+ + +
+ + + + - - - + + + diff --git a/django_project/certification/views/certifying_organisation.py b/django_project/certification/views/certifying_organisation.py index 5ce058620..5321c84e6 100644 --- a/django_project/certification/views/certifying_organisation.py +++ b/django_project/certification/views/certifying_organisation.py @@ -1,6 +1,7 @@ # coding=utf-8 from base.models import Project from django.contrib import messages +from django.contrib.postgres.search import SearchVector from django.core.mail import send_mail from django.urls import reverse from django.shortcuts import get_list_or_404 @@ -652,16 +653,27 @@ def form_valid(self, form): 'this name is already exists!') +class CertifyingOrganisationSearchMixin(object): + """Mixin class to provide search in ListView.""" + + def get_queryset_search(self, qs): + q = self.request.GET.get('q') + if q: + qs = qs.annotate(search=SearchVector('name')).filter(search=q) + return qs + + class PendingCertifyingOrganisationListView( LoginRequiredMixin, CertifyingOrganisationMixin, PaginationMixin, + CertifyingOrganisationSearchMixin, ListView): """List view for pending certifying organisation.""" context_object_name = 'certifyingorganisations' template_name = 'certifying_organisation/pending-list.html' - paginate_by = 20 + paginate_by = 10 def __init__(self): """ @@ -732,7 +744,7 @@ def get_queryset(self): queryset = queryset.order_by(Lower('name').desc()) else: queryset = queryset.order_by(sort_by) - return queryset + return self.get_queryset_search(queryset) else: raise Http404( 'Sorry! We could not find your Certifying Organisation!')
{% sort_link "Organisation Name" "name" %}{% sort_link "Application Date" "submit_date" %}{% sort_link "Status" "status" %}{% sort_link "Organisation Name" "name" %}{% sort_link "Application Date" "submit_date" %}{% sort_link "Status" "status" %}