From c39c563f142ebd7be32f3a8101bbe94e93211087 Mon Sep 17 00:00:00 2001
From: Markus Tuominen <markus.tuominen@tuni.fi>
Date: Wed, 17 Apr 2024 10:19:16 +0000
Subject: [PATCH] =?UTF-8?q?Release=201.0.12=202024-04-17=20-=20#10624:=20K?=
 =?UTF-8?q?orjattu=20Data-kansion=20nimi=20sellaiseksi=20kuin=20se=20tiedo?=
 =?UTF-8?q?stoj=C3=A4rjestelm=C3=A4ss=C3=A4=20on=20ja=20css-tiedoston=20ni?=
 =?UTF-8?q?mi=20vastaamaan=20templatessa=20olevaa?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 CHANGES.rst                               |  5 +++++
 VERSION                                   |  2 +-
 kvalikirstu2/kvali_interface.py           | 16 ++++++++++++++++
 kvalikirstu2/templates/index_template.xml |  2 +-
 4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/CHANGES.rst b/CHANGES.rst
index 3c7b5b8..22adaa7 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,6 +1,11 @@
 Kvalikirstu2 Changelog
 ======================
 
+1.0.12 - 2024/04/17
+-------------------
+- Fixed css file name to be consistent with template
+- Fixed study data folder name case issues by checking the actual name on filesystem
+
 1.0.11 - 2023/11/29
 -------------------
 - Added Jenkins CI configuration
diff --git a/VERSION b/VERSION
index 8684498..492b167 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.11
\ No newline at end of file
+1.0.12
\ No newline at end of file
diff --git a/kvalikirstu2/kvali_interface.py b/kvalikirstu2/kvali_interface.py
index e20025e..0ac2ebe 100644
--- a/kvalikirstu2/kvali_interface.py
+++ b/kvalikirstu2/kvali_interface.py
@@ -137,6 +137,21 @@ def _try_load_header_info():
         _DATA['header_info'] = header_scanner.get_header_info_for_study(_DATA['data_path'])
 
 
+def update_study_data_folder(data_folder, study_path):
+    """Returns study data folder name as it is on filesystem if possible, otherwise returns the parsed value unchanged.
+
+    :param data_folder: Parsed study data folder arg.
+    :param path: The study path.
+
+    """
+    # Check for a case-insensitive match from the list of folders in the study_path
+    matching_folder = next((folder for folder in os.listdir(study_path) if folder.lower() == data_folder.lower()), None)
+
+    # If there's a case-insensitive match, return the matching folder name with the original casing
+    # If no case-insensitive match, return the provided folder name
+    return matching_folder if matching_folder else data_folder
+
+
 def set_study_path(path: str):
     """Sets the path for the study
 
@@ -147,6 +162,7 @@ def set_study_path(path: str):
         path = os.getcwd()
 
     args = argument_parser.get_args()
+    args.study_data_folder = update_study_data_folder(args.study_data_folder, path)
     logger.debug('setting study_path %s', path)
     _DATA['data_path'] = os.path.join(path, args.study_data_folder)
     _DATA['study_path'] = path
diff --git a/kvalikirstu2/templates/index_template.xml b/kvalikirstu2/templates/index_template.xml
index f89629c..fc67aa1 100644
--- a/kvalikirstu2/templates/index_template.xml
+++ b/kvalikirstu2/templates/index_template.xml
@@ -3,7 +3,7 @@
 <head>
 	<meta charset="utf-8"/>
     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
-	<link rel="stylesheet" type="text/css" href="{{file_mapping.get_html_link('data')}}/css/dataTables.min.css"/>
+	<link rel="stylesheet" type="text/css" href="{{file_mapping.get_html_link('data')}}/css/datatables.min.css"/>
 	<link rel="stylesheet" href="{{file_mapping.get_html_link('data')}}/css/foundation.min.css"/>
     <title>{{metadata.study_id}} - {{metadata.title}} - {{_("Index")}}</title>
 	<style> .nojscell { display: none }
-- 
GitLab