From b571fdc95c7b00b2eaa64a9230bb3177a872fac1 Mon Sep 17 00:00:00 2001
From: Bjarke Madsen <bjarke@nordu.net>
Date: Wed, 22 Jan 2025 15:29:41 +0100
Subject: [PATCH] Fix data download

---
 Changelog.md                          | 3 +++
 compendium_v2/routes/data_download.py | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/Changelog.md b/Changelog.md
index b1587b59..1d119f2d 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -2,6 +2,9 @@
 
 All notable changes to this project will be documented in this file.
 
+## [0.82] - 2025-01-22
+- Fix data download in case of survey responses that haven't been initialized for NRENs
+
 ## [0.81] - 2025-01-22
 - Harden get_response_data for moving responses from a previous survey to a new survey year.
 - Moved response data now satisfies the dependencies of the new survey. If a question would be hidden in the new survey, the data for that question is removed.
diff --git a/compendium_v2/routes/data_download.py b/compendium_v2/routes/data_download.py
index 214043e4..bd394ddc 100644
--- a/compendium_v2/routes/data_download.py
+++ b/compendium_v2/routes/data_download.py
@@ -99,7 +99,7 @@ def fetch_survey_comments():
             'A NREN': response.nren.name,
             'A Year': response.survey_year,
         }
-        for key, val in response.answers['data'].items():
+        for key, val in response.answers.get('data', {}).items():
             if key.endswith('_comments'):
                 data[key] = val
         if len(data) > 2:  # only return responses with comments
-- 
GitLab