From 94b566c3c40c4423ea4acc8d0aab341807111d1c Mon Sep 17 00:00:00 2001
From: George Katsikas <giorgakis.katsikas@gmail.com>
Date: Wed, 6 Sep 2023 17:29:36 +0200
Subject: [PATCH] change voting round search to nominations

---
 scipost_django/colleges/forms.py              | 230 +++++++++++++++---
 scipost_django/colleges/managers.py           |   8 +-
 scipost_django/colleges/models/nomination.py  |   3 +-
 .../colleges/_hx_nomination_details.html      |  11 +
 .../colleges/_hx_nomination_summary.html      |  40 +++
 .../colleges/_hx_nominations_list.html        |  24 ++
 .../colleges/_hx_nominations_new.html         |  23 +-
 .../colleges/_hx_nominations_search_form.html |  10 +
 .../colleges/_hx_voting_round_list.html       |   6 +-
 .../_hx_voting_round_search_form.html         |  10 +-
 .../templates/colleges/nominations.html       |  51 +---
 scipost_django/colleges/urls.py               |  12 +-
 scipost_django/colleges/views.py              |  31 +--
 13 files changed, 339 insertions(+), 120 deletions(-)
 create mode 100644 scipost_django/colleges/templates/colleges/_hx_nomination_details.html
 create mode 100644 scipost_django/colleges/templates/colleges/_hx_nomination_summary.html
 create mode 100644 scipost_django/colleges/templates/colleges/_hx_nominations_list.html
 create mode 100644 scipost_django/colleges/templates/colleges/_hx_nominations_search_form.html

diff --git a/scipost_django/colleges/forms.py b/scipost_django/colleges/forms.py
index 7b56621b2..dada1f7b7 100644
--- a/scipost_django/colleges/forms.py
+++ b/scipost_django/colleges/forms.py
@@ -7,7 +7,7 @@ from typing import Dict
 
 from django import forms
 from django.contrib.sessions.backends.db import SessionStore
-from django.db.models import Q
+from django.db.models import Q, Max, OuterRef, Subquery
 
 from crispy_forms.helper import FormHelper
 from crispy_forms.layout import Layout, Div, Field, ButtonHolder, Submit
@@ -463,52 +463,222 @@ class FellowshipNominationForm(forms.ModelForm):
         return nomination
 
 
+# class FellowshipNominationSearchForm(forms.Form):
+#     """Filter a FellowshipNomination queryset using basic search fields."""
+
+#     college = forms.ModelChoiceField(queryset=College.objects.all(), required=False)
+#     specialty = forms.ModelChoiceField(
+#         queryset=Specialty.objects.all(),
+#         label="Specialty",
+#         required=False,
+#     )
+#     name = forms.CharField(max_length=128, required=False)
+
+#     def __init__(self, *args, **kwargs):
+#         super().__init__(*args, **kwargs)
+#         self.helper = FormHelper()
+#         self.helper.layout = Layout(
+#             Div(
+#                 FloatingField("category"),
+#                 css_class="row",
+#             ),
+#             Div(
+#                 Div(FloatingField("college"), css_class="col-lg-6"),
+#                 Div(FloatingField("specialty"), css_class="col-lg-6"),
+#                 css_class="row",
+#             ),
+#             Div(
+#                 Div(FloatingField("name", autocomplete="off"), css_class="col-lg-6"),
+#                 css_class="row",
+#             ),
+#         )
+
+#     def search_results(self):
+#         if self.cleaned_data.get("name"):
+#             nominations = FellowshipNomination.objects.filter(
+#                 Q(profile__last_name__icontains=self.cleaned_data.get("name"))
+#                 | Q(profile__first_name__icontains=self.cleaned_data.get("name"))
+#             )
+#         else:
+#             nominations = FellowshipNomination.objects.all()
+#         if self.cleaned_data.get("college"):
+#             nominations = nominations.filter(college=self.cleaned_data.get("college"))
+#         if self.cleaned_data.get("specialty"):
+#             nominations = nominations.filter(
+#                 profile__specialties__in=[
+#                     self.cleaned_data.get("specialty"),
+#                 ]
+#             )
+#         return nominations
+
+
 class FellowshipNominationSearchForm(forms.Form):
-    """Filter a FellowshipNomination queryset using basic search fields."""
+    nominee = forms.CharField(max_length=100, required=False, label="Nominee")
 
-    college = forms.ModelChoiceField(queryset=College.objects.all(), required=False)
-    specialty = forms.ModelChoiceField(
-        queryset=Specialty.objects.all(),
-        label="Specialty",
+    college = forms.MultipleChoiceField(
+        choices=College.objects.all().order_by("name").values_list("id", "name"),
+        required=False,
+    )
+
+    decision = forms.ChoiceField(
+        choices=[("", "Any"), ("pending", "Pending")]
+        + FellowshipNominationDecision.OUTCOME_CHOICES,
+        required=False,
+    )
+
+    can_vote = forms.BooleanField(
+        label="I can vote",
+        required=False,
+        initial=True,
+    )
+    voting_open = forms.BooleanField(
+        label="Voting open now",
+        required=False,
+        initial=True,
+    )
+    has_rounds = forms.BooleanField(
+        label="Has voting rounds",
+        required=False,
+        initial=True,
+    )
+
+    orderby = forms.ChoiceField(
+        label="Order by",
+        choices=(
+            ("voting_rounds__voting_deadline", "Deadline"),
+            ("voting_rounds__voting_opens", "Voting start"),
+            ("voting_rounds__decision__outcome", "Decision"),
+            ("profile__last_name", "Nominee"),
+        ),
+        required=False,
+    )
+    ordering = forms.ChoiceField(
+        label="Ordering",
+        choices=(
+            # FIXME: Emperically, the ordering appers to be reversed for dates?
+            ("-", "Ascending"),
+            ("+", "Descending"),
+        ),
         required=False,
     )
-    name = forms.CharField(max_length=128, required=False)
 
     def __init__(self, *args, **kwargs):
+        self.user = kwargs.pop("user")
+        self.session_key = kwargs.pop("session_key", None)
         super().__init__(*args, **kwargs)
+
+        # Set the initial values of the form fields from the session data
+        if self.session_key:
+            session = SessionStore(session_key=self.session_key)
+
+            for field in self.fields:
+                if field in session:
+                    self.fields[field].initial = session[field]
+
         self.helper = FormHelper()
+
+        div_block_ordering = Div(
+            Div(FloatingField("orderby"), css_class="col-6 col-md-12 col-xl-6"),
+            Div(FloatingField("ordering"), css_class="col-6 col-md-12 col-xl-6"),
+            css_class="row mb-0",
+        )
+        div_block_checkbox = Div(
+            Div(Field("can_vote"), css_class="col-auto col-lg-12 col-xl-auto"),
+            Div(Field("voting_open"), css_class="col-auto col-lg-12 col-xl-auto"),
+            Div(Field("has_rounds"), css_class="col-auto col-lg-12 col-xl-auto"),
+            css_class="row mb-0",
+        )
+
         self.helper.layout = Layout(
             Div(
-                FloatingField("category"),
-                css_class="row",
-            ),
-            Div(
-                Div(FloatingField("college"), css_class="col-lg-6"),
-                Div(FloatingField("specialty"), css_class="col-lg-6"),
-                css_class="row",
-            ),
-            Div(
-                Div(FloatingField("name", autocomplete="off"), css_class="col-lg-6"),
-                css_class="row",
+                Div(
+                    Div(
+                        Div(FloatingField("nominee"), css_class="col-8"),
+                        Div(FloatingField("decision"), css_class="col-4"),
+                        Div(div_block_ordering, css_class="col-12 col-md-6 col-xl-12"),
+                        Div(div_block_checkbox, css_class="col-12 col-md-6 col-xl-12"),
+                        css_class="row mb-0",
+                    ),
+                    css_class="col",
+                ),
+                Div(
+                    Field("college", size=6),
+                    css_class="col-12 col-md-6 col-lg-4",
+                ),
+                css_class="row mb-0",
             ),
         )
 
+    def apply_filter_set(self, filters: Dict, none_on_empty: bool = False):
+        # Apply the filter set to the form
+        for key in self.fields:
+            if key in filters:
+                self.fields[key].initial = filters[key]
+            elif none_on_empty:
+                if isinstance(self.fields[key], forms.MultipleChoiceField):
+                    self.fields[key].initial = []
+                else:
+                    self.fields[key].initial = None
+
     def search_results(self):
-        if self.cleaned_data.get("name"):
-            nominations = FellowshipNomination.objects.filter(
-                Q(profile__last_name__icontains=self.cleaned_data.get("name"))
-                | Q(profile__first_name__icontains=self.cleaned_data.get("name"))
+        # Save the form data to the session
+        if self.session_key is not None:
+            session = SessionStore(session_key=self.session_key)
+
+            for key in self.cleaned_data:
+                session[key] = self.cleaned_data.get(key)
+
+            session.save()
+
+        nominations = FellowshipNomination.objects.all()
+
+        if self.cleaned_data.get("can_vote") or not self.user.has_perm(
+            "scipost.can_view_all_nomination_voting_rounds"
+        ):
+            # Restrict rounds to those the user can vote on
+            nominations = nominations.with_user_votable_rounds(self.user)
+
+        if nominee := self.cleaned_data.get("nominee"):
+            nominations = nominations.filter(
+                Q(profile__first_name__icontains=nominee)
+                | Q(profile__last_name__icontains=nominee)
             )
-        else:
-            nominations = FellowshipNomination.objects.all()
-        if self.cleaned_data.get("college"):
-            nominations = nominations.filter(college=self.cleaned_data.get("college"))
-        if self.cleaned_data.get("specialty"):
+        if college := self.cleaned_data.get("college"):
+            nominations = nominations.filter(college__id__in=college)
+        if decision := self.cleaned_data.get("decision"):
+            if decision == "pending":
+                nominations = nominations.filter(
+                    voting_rounds__decision__isnull=True,
+                )
+            else:
+                nominations = nominations.filter(
+                    voting_rounds__decision__outcome=decision,
+                )
+        if self.cleaned_data.get("voting_open"):
             nominations = nominations.filter(
-                profile__specialties__in=[
-                    self.cleaned_data.get("specialty"),
+                Q(voting_rounds__voting_opens__lte=timezone.now())
+                & Q(voting_rounds__voting_deadline__gte=timezone.now())
+            )
+        if self.cleaned_data.get("has_rounds"):
+            nominations = nominations.filter(voting_rounds__isnull=False)
+
+        # Ordering of nominations
+        # Only order if both fields are set
+        if (orderby_value := self.cleaned_data.get("orderby")) and (
+            ordering_value := self.cleaned_data.get("ordering")
+        ):
+            # Remove the + from the ordering value, causes a Django error
+            ordering_value = ordering_value.replace("+", "")
+
+            # Ordering string is built by the ordering (+/-), and the field name
+            # from the orderby field split by "," and joined together
+            nominations = nominations.order_by(
+                *[
+                    ordering_value + order_part
+                    for order_part in orderby_value.split(",")
                 ]
             )
+
         return nominations
 
 
@@ -718,7 +888,7 @@ class FellowshipNominationVotingRoundSearchForm(forms.Form):
                 & Q(voting_deadline__gte=timezone.now())
             )
 
-        # Ordering of streams
+        # Ordering of voting rounds
         # Only order if both fields are set
         if (orderby_value := self.cleaned_data.get("orderby")) and (
             ordering_value := self.cleaned_data.get("ordering")
diff --git a/scipost_django/colleges/managers.py b/scipost_django/colleges/managers.py
index 1e7c47e99..bc326b2cf 100644
--- a/scipost_django/colleges/managers.py
+++ b/scipost_django/colleges/managers.py
@@ -3,7 +3,7 @@ __license__ = "AGPL v3"
 
 
 from django.db import models
-from django.db.models import Q
+from django.db.models import Q, Prefetch
 from django.utils import timezone
 
 from .constants import POTENTIAL_FELLOWSHIP_ELECTION_VOTE_ONGOING
@@ -131,6 +131,12 @@ class FellowshipNominationQuerySet(models.QuerySet):
             voting_rounds__decision__isnull=False
         )
 
+    def with_user_votable_rounds(self, user):
+        # votable_rounds = self.voting_rounds.where_user_can_vote(user)
+        return self.filter(
+            Q(voting_rounds__eligible_to_vote__in=user.contributor.fellowships.active())
+        )
+
 
 class FellowshipNominationVotingRoundQuerySet(models.QuerySet):
     def ongoing(self):
diff --git a/scipost_django/colleges/models/nomination.py b/scipost_django/colleges/models/nomination.py
index a3e6cf745..4c0a5faf0 100644
--- a/scipost_django/colleges/models/nomination.py
+++ b/scipost_django/colleges/models/nomination.py
@@ -94,8 +94,7 @@ class FellowshipNomination(models.Model):
         """
         List of blocking facts (if any) preventing fixing a decision.
         """
-        latest_round = self.voting_rounds.first()
-        if latest_round:
+        if latest_round := self.latest_voting_round:
             eligible_count = latest_round.eligible_to_vote.count()
             if eligible_count < 3:
                 return "Fewer than 3 eligible voters (insufficient)."
diff --git a/scipost_django/colleges/templates/colleges/_hx_nomination_details.html b/scipost_django/colleges/templates/colleges/_hx_nomination_details.html
new file mode 100644
index 000000000..ad427ab2b
--- /dev/null
+++ b/scipost_django/colleges/templates/colleges/_hx_nomination_details.html
@@ -0,0 +1,11 @@
+<details id="nomination-{{ nomination.id }}-details"
+         class="border border-2 mx-3 p-2 bg-primary bg-opacity-10">
+  <summary class="list-none">{% include "colleges/_hx_nomination_summary.html" with nomination=nomination %}</summary>
+
+  <div id="nomination-{{ nomination.id }}-details-contents"
+       class="p-2 mt-2 bg-white"
+       hx-get="{% url 'colleges:_hx_nomination_li_contents' nomination_id=nomination.id %}"
+       hx-trigger="toggle once from:#nomination-{{ nomination.id }}-details"
+       hx-indicator="#indicator-nomination-{{ nomination.id }}-details-contents"></div>
+
+</details>
diff --git a/scipost_django/colleges/templates/colleges/_hx_nomination_summary.html b/scipost_django/colleges/templates/colleges/_hx_nomination_summary.html
new file mode 100644
index 000000000..2d1083408
--- /dev/null
+++ b/scipost_django/colleges/templates/colleges/_hx_nomination_summary.html
@@ -0,0 +1,40 @@
+<div class="row mb-0 w-100">
+
+  <div class="col-12 col-sm">
+    <div class="fs-6">{{ nomination.profile }}</div>
+    <div class="d-none d-md-block">(click for details)</div>
+  </div>
+
+  {% with nomination.latest_voting_round as round %}
+
+    <div class="col-12 col-sm-auto">
+      <div>
+        <span>Editorial College:</span><span>&emsp;{{ nomination.college.name }}</span>
+      </div>
+      <div>
+        <span>Voting started:</span><span>&emsp;{{ round.voting_opens|date:"Y-m-d" }}</span>
+      </div>
+    </div>
+
+    <div class="col-12 col-sm-auto">
+      <div>
+        <span>Decision:</span>
+
+        {% if round.decision.outcome == "elected" %}
+          <span class="badge bg-success">{{ round.decision.get_outcome_display }}</span>
+        {% elif round.decision.outcome == "notelected" %}
+          <span class="badge bg-danger">{{ round.decision.get_outcome_display }}</span>
+        {% else %}
+          <span class="badge bg-warning">Pending</span>
+        {% endif %}
+
+      </div>
+
+      <div>
+        <span>Deadline:&nbsp;</span><span>{{ round.voting_deadline|date:"Y-m-d" }}</span>
+      </div>
+    </div>
+ 
+  {% endwith %}
+ 
+</div>
diff --git a/scipost_django/colleges/templates/colleges/_hx_nominations_list.html b/scipost_django/colleges/templates/colleges/_hx_nominations_list.html
new file mode 100644
index 000000000..2be19aa8b
--- /dev/null
+++ b/scipost_django/colleges/templates/colleges/_hx_nominations_list.html
@@ -0,0 +1,24 @@
+{% for nomination in page_obj %}
+  <div class="ms-1 mt-2">{% include 'colleges/_hx_nomination_details.html' with nomination=nomination %}</div>
+{% empty %}
+  <strong>No Nominations could be found</strong>
+{% endfor %}
+
+{% if page_obj.has_next %}
+  <div hx-post="{% url 'colleges:_hx_nominations_list' %}?page={{ page_obj.next_page_number }}"
+       hx-include="#search-nominations-form"
+       hx-trigger="revealed"
+       hx-swap="afterend"
+       hx-indicator="#indicator-search-page-{{ page_obj.number }}">
+    <div id="indicator-search-page-{{ page_obj.number }}"
+         class="htmx-indicator p-2">
+      <button class="btn btn-warning" type="button" disabled>
+        <strong>Loading page {{ page_obj.next_page_number }} out of {{ page_obj.paginator.num_pages }}</strong>
+	
+        <div class="spinner-grow spinner-grow-sm ms-2"
+             role="status"
+             aria-hidden="true"></div>
+      </button>
+    </div>
+  </div>
+{% endif %}
diff --git a/scipost_django/colleges/templates/colleges/_hx_nominations_new.html b/scipost_django/colleges/templates/colleges/_hx_nominations_new.html
index 439a4585f..c7cfd7ed2 100644
--- a/scipost_django/colleges/templates/colleges/_hx_nominations_new.html
+++ b/scipost_django/colleges/templates/colleges/_hx_nominations_new.html
@@ -29,12 +29,18 @@
         </div>
  
       </div>
-      <div class="row mb-0">
+    </div>
+
+    <div class="col-lg-6">
+      <h3>Matching profiles</h3>
+      <div id="profile_dynsel_results" class="border border-light m-2 p-1"></div>
 
+      <div class="row mb-0">
+ 
         <div class="col-auto">
-          <div id="nomination_form_response-indicator" class="htmx-indicator">
+          <div id="profile_dynsel_results-indicator" class="htmx-indicator">
             <button class="btn btn-sm btn-warning" type="button" disabled>
-              <strong>Loading form...</strong>
+              <strong>Loading results...</strong>
               <div class="spinner-grow spinner-grow-sm ms-2"
                    role="status"
                    aria-hidden="true"></div>
@@ -43,24 +49,19 @@
         </div>
 
         <div class="col-auto">
-          <div id="profile_dynsel_results-indicator" class="htmx-indicator">
+          <div id="nomination_form_response-indicator" class="htmx-indicator">
             <button class="btn btn-sm btn-warning" type="button" disabled>
-              <strong>Loading results...</strong>
+              <strong>Loading form...</strong>
               <div class="spinner-grow spinner-grow-sm ms-2"
                    role="status"
                    aria-hidden="true"></div>
             </button>
           </div>
         </div>
-
+ 
       </div>
     </div>
 
-    <div class="col-lg-6">
-      <h3>Matching profiles</h3>
-      <div id="profile_dynsel_results" class="border border-light m-2 p-1"></div>
-    </div>
-
   </div>
 
   <div id="nomination_form_response">
diff --git a/scipost_django/colleges/templates/colleges/_hx_nominations_search_form.html b/scipost_django/colleges/templates/colleges/_hx_nominations_search_form.html
new file mode 100644
index 000000000..6c95f95a9
--- /dev/null
+++ b/scipost_django/colleges/templates/colleges/_hx_nominations_search_form.html
@@ -0,0 +1,10 @@
+{% load crispy_forms_tags %}
+
+<form hx-post="{% url 'colleges:_hx_nominations_list' %}"
+      hx-trigger="load, keyup delay:500ms, change delay:500ms, click from:#refresh-button"
+      hx-sync="#search-nominations-form:replace"
+      hx-target="#search-nominations-results"
+      hx-indicator="#indicator-search-nominations">
+ 
+  <div id="search-nominations-form">{% crispy form %}</div>
+</form>
diff --git a/scipost_django/colleges/templates/colleges/_hx_voting_round_list.html b/scipost_django/colleges/templates/colleges/_hx_voting_round_list.html
index f3b212b5e..bfbd6306d 100644
--- a/scipost_django/colleges/templates/colleges/_hx_voting_round_list.html
+++ b/scipost_django/colleges/templates/colleges/_hx_voting_round_list.html
@@ -1,13 +1,11 @@
 {% for round in page_obj %}
-  <div class="ms-1 mt-2">
-    {% include 'colleges/_hx_voting_round_details.html' with round=round %}
-  </div>
+  <div class="ms-1 mt-2">{% include 'colleges/_hx_voting_round_details.html' with round=round %}</div>
 {% empty %}
   <strong>No Voting Rounds could be found</strong>
 {% endfor %}
 
 {% if page_obj.has_next %}
-  <div hx-post="{% url 'colleges:_hx_voting_round_list' %}?page={{ page_obj.next_page_number }}"
+  <div hx-post="{% url 'colleges:_hx_nominations_list' %}?page={{ page_obj.next_page_number }}"
        hx-include="#search-voting_rounds-form"
        hx-trigger="revealed"
        hx-swap="afterend"
diff --git a/scipost_django/colleges/templates/colleges/_hx_voting_round_search_form.html b/scipost_django/colleges/templates/colleges/_hx_voting_round_search_form.html
index 26fdc0d40..6c95f95a9 100644
--- a/scipost_django/colleges/templates/colleges/_hx_voting_round_search_form.html
+++ b/scipost_django/colleges/templates/colleges/_hx_voting_round_search_form.html
@@ -1,10 +1,10 @@
 {% load crispy_forms_tags %}
 
-<form hx-post="{% url 'colleges:_hx_voting_round_list' %}"
+<form hx-post="{% url 'colleges:_hx_nominations_list' %}"
       hx-trigger="load, keyup delay:500ms, change delay:500ms, click from:#refresh-button"
-      hx-sync="#search-voting_rounds-form:replace"
-      hx-target="#search-voting_rounds-results"
-      hx-indicator="#indicator-search-voting_rounds">
+      hx-sync="#search-nominations-form:replace"
+      hx-target="#search-nominations-results"
+      hx-indicator="#indicator-search-nominations">
  
-  <div id="search-voting_rounds-form">{% crispy form %}</div>
+  <div id="search-nominations-form">{% crispy form %}</div>
 </form>
diff --git a/scipost_django/colleges/templates/colleges/nominations.html b/scipost_django/colleges/templates/colleges/nominations.html
index 736184c12..29016329d 100644
--- a/scipost_django/colleges/templates/colleges/nominations.html
+++ b/scipost_django/colleges/templates/colleges/nominations.html
@@ -30,12 +30,12 @@
 
   <div id="new-nomination-container"></div>
 
-  <details id="voting_rounds-filter-details" class="card my-4">
+  <details id="nominations-filter-details" class="card my-4">
     <summary class="card-header d-flex flex-row align-items-center justify-content-between list-triangle">
       <div class="fs-3">Search / Filter</div>
       <div class="d-none d-md-flex align-items-center">
  
-        <div id="indicator-search-voting_rounds" class="htmx-indicator">
+        <div id="indicator-search-nominations" class="htmx-indicator">
           <button class="btn btn-warning text-white d-none d-md-block me-2"
                   type="button"
                   disabled>
@@ -49,8 +49,8 @@
 
         <button class="btn btn-outline-secondary me-2"
                 type="button"
-                hx-get="{% url 'colleges:_hx_voting_round_search_form' filter_set="empty" %}"
-                hx-target="#voting_round-search-form-container">Clear Filters</button>
+                hx-get="{% url 'colleges:_hx_nominations_search_form' filter_set="empty" %}"
+                hx-target="#nominations-search-form-container">Clear Filters</button>
  
         <button class="btn btn-success me-2 text-white"
                 type="button"
@@ -68,13 +68,13 @@
 
     </summary>
     <div class="card-body">
-      <div id="voting_round-search-form-container"
-           hx-get="{% url 'colleges:_hx_voting_round_search_form' filter_set='default' %}"
+      <div id="nominations-search-form-container"
+           hx-get="{% url 'colleges:_hx_nominations_search_form' filter_set='default' %}"
            hx-trigger="intersect once"></div>
     </div>
   </details>
 
-  <div id="search-voting_rounds-results" class="mt-2"></div>
+  <div id="search-nominations-results" class="mt-2"></div>
 
   {% if "edadmin" in user_roles or "active_senior_fellow" in user_roles %}
     <details id="ensure-specialties-details"
@@ -112,7 +112,7 @@
     </summary>
 
     <div class="p-2">
-      <div id="voting_tablist" hx-trigger="toggle from:#voting-details, click from:body target:.nomination-start-round-btn" hx-get="{% url 'colleges:_hx_voting_rounds' %}?tab= 
+      <div id="voting_tablist" hx-trigger="toggle from:#voting-details, click from:body target:.nomination-start-round-btn" hx-get="{% url 'colleges:_hx_nominations' %}?tab= 
         {% if 'edadmin' in user_roles %}ongoing{% else %}ongoing-vote_required{% endif %}
          "></div>
     </div>
@@ -133,39 +133,4 @@
     </details>
   {% endif %}
 
-  <details id="list-details" class="border border-2 mt-4">
-    <summary class="bg-light p-2 d-block list-triangle">
-      <div class="fs-5">List / filter</div>
-    </summary>
-
-    <div class="p-2 mt-2">
-      <form hx-post="{% url 'colleges:_hx_nominations' %}"
-            hx-trigger="toggle from:#list-details, keyup delay:500ms, change"
-            hx-target="#search-nominations-results"
-            hx-indicator="#indicator-search">
-        <div id="search-nominations-form">{% crispy search_nominations_form %}</div>
-      </form>
-
-      <div class="row">
-        <div class="col">
-          <h3>Nominations list</h3>
-        </div>
-
-        <div class="col">
-          <div id="indicator-search-nominations" class="htmx-indicator">
-            <button class="btn btn-sm btn-warning" type="button" disabled>
-              <strong>Loading...</strong>
-              <div class="spinner-grow spinner-grow-sm ms-2"
-                   role="status"
-                   aria-hidden="true"></div>
-            </button>
-          </div>
-        </div>
-      </div>
-
-      <ul id="search-nominations-results" class="list-unstyled mt-2">
-      </ul>
-
-    </div>
-  </details>
 {% endblock content %}
diff --git a/scipost_django/colleges/urls.py b/scipost_django/colleges/urls.py
index ee62e72ca..ba02334c7 100644
--- a/scipost_django/colleges/urls.py
+++ b/scipost_django/colleges/urls.py
@@ -170,9 +170,9 @@ urlpatterns = [
     ),
     path("_hx_nominations", views._hx_nominations, name="_hx_nominations"),
     path(
-        "_hx_voting_round_search_form/<str:filter_set>",
-        views._hx_voting_round_search_form,
-        name="_hx_voting_round_search_form",
+        "_hx_nominations_search_form/<str:filter_set>",
+        views._hx_nominations_search_form,
+        name="_hx_nominations_search_form",
     ),
     path(
         "_hx_nomination_li_contents/<int:nomination_id>",
@@ -254,9 +254,9 @@ urlpatterns = [
         name="_hx_voting_rounds",
     ),
     path(
-        "_hx_voting_round_list",
-        views._hx_voting_round_list,
-        name="_hx_voting_round_list",
+        "_hx_nominations_list",
+        views._hx_nominations_list,
+        name="_hx_nominations_list",
     ),
     path(
         "_hx_nomination_vote/<int:voting_round_id>",
diff --git a/scipost_django/colleges/views.py b/scipost_django/colleges/views.py
index 27ea43479..3f6aabf10 100644
--- a/scipost_django/colleges/views.py
+++ b/scipost_django/colleges/views.py
@@ -42,7 +42,7 @@ from .constants import (
 )
 from .forms import (
     CollegeChoiceForm,
-    FellowshipNominationVotingRoundSearchForm,
+    FellowshipNominationSearchForm,
     FellowshipSearchForm,
     FellowshipDynSelForm,
     FellowshipForm,
@@ -697,9 +697,7 @@ def nominations(request):
     """
     List Nominations.
     """
-    context = {
-        "search_nominations_form": FellowshipNominationSearchForm(),
-    }
+    context = {}
     return render(request, "colleges/nominations.html", context)
 
 
@@ -855,33 +853,30 @@ def _hx_nomination_li_contents(request, nomination_id):
     return render(request, "colleges/_hx_nomination_li_contents.html", context)
 
 
-def _hx_voting_round_search_form(request, filter_set: str):
-    voting_rounds_search_form = FellowshipNominationVotingRoundSearchForm(
+def _hx_nominations_search_form(request, filter_set: str):
+    form = FellowshipNominationSearchForm(
         user=request.user,
         session_key=request.session.session_key,
     )
 
     if filter_set == "empty":
-        voting_rounds_search_form.apply_filter_set({}, none_on_empty=True)
-    # TODO: add more filter sets saved in the session of the user
-
-    print(type(voting_rounds_search_form))
+        form.apply_filter_set({}, none_on_empty=True)
 
     context = {
-        "form": voting_rounds_search_form,
+        "form": form,
     }
-    return render(request, "colleges/_hx_voting_round_search_form.html", context)
+    return render(request, "colleges/_hx_nominations_search_form.html", context)
 
 
-def _hx_voting_round_list(request):
-    form = FellowshipNominationVotingRoundSearchForm(
+def _hx_nominations_list(request):
+    form = FellowshipNominationSearchForm(
         request.POST or None, user=request.user, session_key=request.session.session_key
     )
     if form.is_valid():
-        rounds = form.search_results()
+        nominations = form.search_results()
     else:
-        rounds = FellowshipNominationVotingRound.objects.all()
-    paginator = Paginator(rounds, 16)
+        nominations = FellowshipNomination.objects.all()
+    paginator = Paginator(nominations, 16)
     page_nr = request.GET.get("page")
     page_obj = paginator.get_page(page_nr)
     count = paginator.count
@@ -891,7 +886,7 @@ def _hx_voting_round_list(request):
         "page_obj": page_obj,
         "start_index": start_index,
     }
-    return render(request, "colleges/_hx_voting_round_list.html", context)
+    return render(request, "colleges/_hx_nominations_list.html", context)
 
 
 def _hx_voting_round_li_contents(request, round_id):
-- 
GitLab