From 78168ae2b43b2b089a63889f9e1b76ced3b71947 Mon Sep 17 00:00:00 2001
From: Konrad Mohrfeldt <konrad.mohrfeldt@farbdev.org>
Date: Tue, 22 Mar 2022 13:50:23 +0100
Subject: [PATCH] fix: always include API fields

Simply omitting properties in the API in certain edge cases makes API
client implementations brittle and documentation a lot harder.
---
 program/models.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/program/models.py b/program/models.py
index 2d8fc1f9..fe132cea 100644
--- a/program/models.py
+++ b/program/models.py
@@ -526,10 +526,10 @@ class Schedule(models.Model):
 
                 # Get note
                 try:
-                    note = Note.objects.get(timeslot=c.id).values_list("id", flat=True)
-                    collision["note_id"] = note
+                    note = Note.objects.get(timeslot=c.id)
+                    collision["note_id"] = note.pk
                 except ObjectDoesNotExist:
-                    pass
+                    collision["note_id"] = None
 
                 collisions.append(collision)
 
@@ -607,6 +607,7 @@ class Schedule(models.Model):
 
             projected_entry["collisions"] = collisions
             projected_entry["solution_choices"] = solution_choices
+            projected_entry["error"] = None
             projected.append(projected_entry)
 
         conflicts["projected"] = projected
-- 
GitLab