From 83409ef2c8b6e04cc2c5a4a65aa994ef5d9cff43 Mon Sep 17 00:00:00 2001 From: Luca Date: Fri, 16 Feb 2024 19:11:14 +0100 Subject: [PATCH] chore: update for pretalx 2024.1.0 --- pretalx_musicrate/__init__.py | 2 +- pretalx_musicrate/forms.py | 7 +++++++ .../pretalx_musicrate/enhanced_list.html | 4 ++-- pretalx_musicrate/views.py | 19 ++++++++++++------- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/pretalx_musicrate/__init__.py b/pretalx_musicrate/__init__.py index 23f0070..9da2f8f 100644 --- a/pretalx_musicrate/__init__.py +++ b/pretalx_musicrate/__init__.py @@ -1 +1 @@ -__version__ = "0.14.3" +__version__ = "0.15.0" diff --git a/pretalx_musicrate/forms.py b/pretalx_musicrate/forms.py index 83d03c1..b4d9fc9 100644 --- a/pretalx_musicrate/forms.py +++ b/pretalx_musicrate/forms.py @@ -83,3 +83,10 @@ class AssigneeForm(forms.ModelForm): class EnhancedSubmissionFilterForm(SubmissionFilterForm): require_all_tags = forms.BooleanField(required=False, label=_("require all")) + + def filter_queryset(self, qs): + qs = super().filter_queryset(qs) + if self.cleaned_data.get("require_all_tags"): + for tag in self.cleaned_data.get("tags"): + qs = qs.filter(tags__in=[tag]) + return qs diff --git a/pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html b/pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html index 8bd6ded..d90b5af 100644 --- a/pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html +++ b/pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html @@ -29,7 +29,7 @@
- {% bootstrap_form search_form %} + {% bootstrap_field filter_form.q %} {% if show_submission_types and filter_form.submission_type %}{% bootstrap_field filter_form.submission_type %}{% endif %}
{% bootstrap_field filter_form.state layout='inline' %} @@ -150,5 +150,5 @@
- {% include "orga/pagination.html" %} + {% include "orga/includes/pagination.html" %} {% endblock %} diff --git a/pretalx_musicrate/views.py b/pretalx_musicrate/views.py index 84fd923..32dc6a8 100644 --- a/pretalx_musicrate/views.py +++ b/pretalx_musicrate/views.py @@ -15,7 +15,7 @@ from django.views.generic import FormView, TemplateView, View from django.views.generic.detail import SingleObjectMixin from django_context_decorator import context from pretalx.common.mixins.views import EventPermissionRequired -from pretalx.orga.views.submission import SubmissionList +from pretalx.orga.views.submission import BaseSubmissionList, SubmissionList from pretalx.submission.models import Submission from .forms import ( @@ -488,11 +488,16 @@ class EnhancedSubmissionList(SubmissionList): event=self.request.event, usable_states=self.usable_states, limit_tracks=self.limit_tracks, + search_fields=self.get_default_filters(), ) - def filter_queryset(self, qs): - qs = super().filter_queryset(qs.prefetch_related("assignee")) - if self.request.GET.get("require_all_tags", "") == "on": - for tag in self.request.GET.getlist("tags"): - qs = qs.filter(tags__in=[tag]) - return qs + def _get_base_queryset(self, for_review=False): + qs = ( + super(BaseSubmissionList, self) + .get_queryset(for_review=for_review) + .prefetch_related("assignee") + .order_by("-id") + ) + if not self.filter_form.is_valid(): + return qs + return self.filter_form.filter_queryset(qs)