From e18b9574d2e9ce94305170ed5c74717cc0b7b2c8 Mon Sep 17 00:00:00 2001
From: George Katsikas <giorgakis.katsikas@gmail.com>
Date: Tue, 14 Nov 2023 17:29:52 +0100
Subject: [PATCH] add inconclusive outcome to nomination decision

---
 ...ter_fellowshipnominationdecision_outcome.py | 18 ++++++++++++++++++
 scipost_django/colleges/models/nomination.py   |  2 ++
 .../_hx_nomination_voting_rounds_tab.html      |  1 +
 .../colleges/_hx_voting_round_details.html     |  4 +++-
 .../colleges/_hx_voting_round_summary.html     |  8 +++++---
 5 files changed, 29 insertions(+), 4 deletions(-)
 create mode 100644 scipost_django/colleges/migrations/0044_alter_fellowshipnominationdecision_outcome.py

diff --git a/scipost_django/colleges/migrations/0044_alter_fellowshipnominationdecision_outcome.py b/scipost_django/colleges/migrations/0044_alter_fellowshipnominationdecision_outcome.py
new file mode 100644
index 000000000..8525d26bf
--- /dev/null
+++ b/scipost_django/colleges/migrations/0044_alter_fellowshipnominationdecision_outcome.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.2.18 on 2023-11-14 16:11
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('colleges', '0043_alter_fellowshipnominationevent_options'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='fellowshipnominationdecision',
+            name='outcome',
+            field=models.CharField(choices=[('elected', 'Elected'), ('notelected', 'Not elected'), ('inconclusive', 'Inconclusive')], max_length=16),
+        ),
+    ]
diff --git a/scipost_django/colleges/models/nomination.py b/scipost_django/colleges/models/nomination.py
index 95482e225..1f289db9f 100644
--- a/scipost_django/colleges/models/nomination.py
+++ b/scipost_django/colleges/models/nomination.py
@@ -341,9 +341,11 @@ class FellowshipNominationDecision(models.Model):
 
     OUTCOME_ELECTED = "elected"
     OUTCOME_NOT_ELECTED = "notelected"
+    OUTCOME_INCONCLUSIVE = "inconclusive"
     OUTCOME_CHOICES = [
         (OUTCOME_ELECTED, "Elected"),
         (OUTCOME_NOT_ELECTED, "Not elected"),
+        (OUTCOME_INCONCLUSIVE, "Inconclusive"),
     ]
     outcome = models.CharField(max_length=16, choices=OUTCOME_CHOICES)
 
diff --git a/scipost_django/colleges/templates/colleges/_hx_nomination_voting_rounds_tab.html b/scipost_django/colleges/templates/colleges/_hx_nomination_voting_rounds_tab.html
index 11fa485d7..a7a010ef0 100644
--- a/scipost_django/colleges/templates/colleges/_hx_nomination_voting_rounds_tab.html
+++ b/scipost_django/colleges/templates/colleges/_hx_nomination_voting_rounds_tab.html
@@ -7,6 +7,7 @@
            type="button"
            class="me-2 px-2 nav-link border border-success"
            hx-get="{% url 'colleges:_hx_nomination_voting_rounds_create' nomination_id=nomination.id %}"
+           {% if nomination.decision.outcome == 'notelected' %}hx-confirm="Are you sure you want to create a new voting round for a previously non-elected nominee? This should only be performed as a rare exception and after considerable time has passed since the last round."{% endif %}
            hx-target="#nomination-{{ nomination.id }}-round-tab-holder"
            hx-swap="outerHTML">
         <span class="fs-1 align-items-center text-success">+</span>
diff --git a/scipost_django/colleges/templates/colleges/_hx_voting_round_details.html b/scipost_django/colleges/templates/colleges/_hx_voting_round_details.html
index 1fab54c60..233591f87 100644
--- a/scipost_django/colleges/templates/colleges/_hx_voting_round_details.html
+++ b/scipost_django/colleges/templates/colleges/_hx_voting_round_details.html
@@ -51,7 +51,7 @@
 
       {% comment %} If round is closed show results if they exist {% endcomment %}
     {% else %}
-      <div>{% include "colleges/_voting_results_box.html" with voting_round=voting_round %}</div>
+      <div>{% include "colleges/_voting_results_box.html" with voting_round=round %}</div>
  
 
       {% if round.decision %}
@@ -62,6 +62,8 @@
             <div class="badge fs-5 mb-2 bg-success">{{ round.decision.get_outcome_display }}</div>
           {% elif round.decision.outcome == 'notelected' %}
             <div class="badge fs-5 mb-2 bg-danger">{{ round.decision.get_outcome_display }}</div>
+          {% elif round.decision.outcome == 'inconclusive' %}
+            <div class="badge fs-5 mb-2 bg-warning">{{ round.decision.get_outcome_display }}</div>
           {% endif %}
 
           {% if round.decision.comments %}
diff --git a/scipost_django/colleges/templates/colleges/_hx_voting_round_summary.html b/scipost_django/colleges/templates/colleges/_hx_voting_round_summary.html
index 119a04577..257ce41ac 100644
--- a/scipost_django/colleges/templates/colleges/_hx_voting_round_summary.html
+++ b/scipost_django/colleges/templates/colleges/_hx_voting_round_summary.html
@@ -66,12 +66,14 @@
 
         <div class="col-auto">
 
-          {% if round.decision.outcome == "elected" %}
+          {% if not round.decision %}
+            <span class="badge bg-warning">Pending</span>
+          {% elif 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>
+          {% elif round.decision.outcome == "inconclusive"  %}
+            <span class="badge bg-warning">{{ round.decision.get_outcome_display }}</span>
           {% endif %}
 
         </div>
-- 
GitLab