From f9358ed4ccd874cb0969614674b7964c83a9f28b Mon Sep 17 00:00:00 2001 From: "Rem M." Date: Mon, 21 Oct 2024 20:16:10 +0700 Subject: [PATCH] Fix labels filtering on repositories page --- contributors/views/repositories_views/repositories.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/contributors/views/repositories_views/repositories.py b/contributors/views/repositories_views/repositories.py index 763599f..b189300 100644 --- a/contributors/views/repositories_views/repositories.py +++ b/contributors/views/repositories_views/repositories.py @@ -46,6 +46,11 @@ def get_queryset(self): Prefetch('labels', queryset=Label.objects.only('name')) ) ) + + filtered_labels = self.request.GET.get('labels') + if filtered_labels: + queryset = queryset.filter( + labels__name__lower__in=filtered_labels.split('.')) return queryset template_name = 'contributors_sections/repositories/repositories_list.html' @@ -69,6 +74,10 @@ def get_context_data(self, **kwargs): repository__in=self.get_queryset(), ).distinct().only('name') + filtered_labels = self.request.GET.get('labels') + if filtered_labels: + labels = labels.filter(name__lower__in=filtered_labels.split('.')) + context['all_labels'] = all_labels context['labels'] = labels