Repository: carpentries/amy

Issue:
 workshop request view page shows 1 page of requests only
Regardless of the filter chosen only one page of 25 requests is shown.
There is no ability to go to prev/next page.




Discussion:
@maneesha there's no pagination widget on that page, but it's easy to add. The real issue here that I can see is that the filter form doesn't work correctly. I'll fix that and add pagination.

Resolving patch:
diff --git a/workshops/filters.py b/workshops/filters.py
--- a/workshops/filters.py
+++ b/workshops/filters.py
@@ -30,8 +30,6 @@
     Membership,
 )
 
-EMPTY_SELECTION = (None, '---------')
-
 
 class AllCountriesFilter(django_filters.ChoiceFilter):
     @property
@@ -45,7 +43,6 @@ def field(self):
         countries.only = choices
 
         self.extra['choices'] = list(countries)
-        self.extra['choices'].insert(0, EMPTY_SELECTION)
         return super().field
 
 
@@ -63,7 +60,6 @@ def field(self):
         qs1 = qs1.order_by(name).values_list(name, flat=True)
         qs2 = model.objects.filter(pk__in=qs1)
         self.extra['choices'] = [(o.pk, str(o)) for o in qs2]
-        self.extra['choices'].insert(0, EMPTY_SELECTION)
         return super().field
 
 
@@ -145,7 +141,7 @@ class EventFilter(AMYFilterSet):
                              widget=Select2())
 
     invoice_status = django_filters.ChoiceFilter(
-        choices=(EMPTY_SELECTION, ) + Event.INVOICED_CHOICES,
+        choices=Event.INVOICED_CHOICES,
     )
 
     tags = django_filters.ModelMultipleChoiceFilter(
@@ -185,18 +181,20 @@ def filter_active_eventrequest(qs, name, value):
 
 
 class EventRequestFilter(AMYFilterSet):
-    assigned_to = ForeignKeyAllValuesFilter(Person)
-    country = AllCountriesFilter()
     active = django_filters.ChoiceFilter(
         choices=(('all', 'All'), ('true', 'Open'), ('false', 'Closed')),
-        label='Status', method=filter_active_eventrequest,
+        label='Status',
+        method=filter_active_eventrequest,
         widget=widgets.RadioSelect,
+        empty_label=None,
     )
+    assigned_to = ForeignKeyAllValuesFilter(Person, widget=Select2())
+    country = AllCountriesFilter(widget=Select2())
     workshop_type = django_filters.ChoiceFilter(
-        choices=(('', 'All'), ('swc', 'Software-Carpentry'),
+        choices=(('swc', 'Software-Carpentry'),
                  ('dc', 'Data-Carpentry')),
         label='Workshop type',
-        widget=widgets.RadioSelect,
+        empty_label='All',
     )
 
     order_by = django_filters.OrderingFilter(
@@ -678,11 +676,13 @@ def filter_active_eventsubmission(qs, name, value):
 
 class EventSubmissionFilter(AMYFilterSet):
     active = django_filters.ChoiceFilter(
-        choices=(('', 'All'), ('true', 'Open'), ('false', 'Closed')),
-        label='Status', method=filter_active_eventsubmission,
+        choices=(('all', 'All'), ('true', 'Open'), ('false', 'Closed')),
+        label='Status',
+        method=filter_active_eventsubmission,
         widget=widgets.RadioSelect,
+        empty_label=None,
     )
-    assigned_to = ForeignKeyAllValuesFilter(Person)
+    assigned_to = ForeignKeyAllValuesFilter(Person, widget=Select2())
 
     order_by = django_filters.OrderingFilter(
         fields=(
@@ -708,11 +708,13 @@ def filter_active_dcselforganizedeventrequest(qs, name, value):
 
 class DCSelfOrganizedEventRequestFilter(AMYFilterSet):
     active = django_filters.ChoiceFilter(
-        choices=(('', 'All'), ('true', 'Open'), ('false', 'Closed')),
-        label='Status', method=filter_active_dcselforganizedeventrequest,
+        choices=(('all', 'All'), ('true', 'Open'), ('false', 'Closed')),
+        label='Status',
+        method=filter_active_dcselforganizedeventrequest,
         widget=widgets.RadioSelect,
+        empty_label=None,
     )
-    assigned_to = ForeignKeyAllValuesFilter(Person)
+    assigned_to = ForeignKeyAllValuesFilter(Person, widget=Select2())
 
     order_by = django_filters.OrderingFilter(
         fields=(
diff --git a/workshops/views.py b/workshops/views.py
--- a/workshops/views.py
+++ b/workshops/views.py
@@ -2214,7 +2214,7 @@ class AllEventRequests(OnlyForAdminsMixin, AMYListView):
     context_object_name = 'requests'
     template_name = 'workshops/all_eventrequests.html'
     filter_class = EventRequestFilter
-    queryset = EventRequest.objects.all()
+    queryset = EventRequest.objects.select_related('assigned_to')
     title = 'Workshop requests'
 
     def get_filter_data(self):


Test patch: