From adefdf60410b1667da25cb5217c2f3321261f5b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Benjamin=20H=C3=A4ttasch?=
 <benjamin.haettasch@fachschaft.informatik.tu-darmstadt.de>
Date: Sat, 26 Nov 2022 21:17:21 +0100
Subject: [PATCH] Move fullcalendar v5 to static common

Adapt loading templates
Move plan loader template to AKModel
Add new template to load all css and scripts for availabilities with one call
Use that loader in views with availabilities editors
---
 .../templates/AKModel}/load_fullcalendar.html     |  4 ++--
 .../AKModel/load_fullcalendar_availabilities.html | 15 +++++++++++++++
 .../templates/admin/AKModel/room_change_form.html |  4 ++--
 AKPlan/templates/AKPlan/plan_akslot.html          |  2 +-
 AKPlan/templates/AKPlan/plan_base.html            |  2 +-
 AKPlan/templates/AKPlan/plan_wall.html            |  2 +-
 .../templates/admin/AKScheduling/scheduling.html  |  2 +-
 .../templates/AKSubmission/submit_new.html        |  4 +---
 .../vendor/fullcalendar-scheduler/locales/de.js   |  0
 .../vendor/fullcalendar-scheduler/main.css        |  0
 .../common}/vendor/fullcalendar-scheduler/main.js |  0
 .../vendor/fullcalendar-scheduler/main.min.css    |  0
 .../vendor/fullcalendar-scheduler/main.min.js     |  0
 13 files changed, 24 insertions(+), 11 deletions(-)
 rename {AKPlan/templates/AKPlan => AKModel/templates/AKModel}/load_fullcalendar.html (77%)
 create mode 100644 AKModel/templates/AKModel/load_fullcalendar_availabilities.html
 rename {AKPlan/static/AKPlan => static_common/common}/vendor/fullcalendar-scheduler/locales/de.js (100%)
 rename {AKPlan/static/AKPlan => static_common/common}/vendor/fullcalendar-scheduler/main.css (100%)
 rename {AKPlan/static/AKPlan => static_common/common}/vendor/fullcalendar-scheduler/main.js (100%)
 rename {AKPlan/static/AKPlan => static_common/common}/vendor/fullcalendar-scheduler/main.min.css (100%)
 rename {AKPlan/static/AKPlan => static_common/common}/vendor/fullcalendar-scheduler/main.min.js (100%)

diff --git a/AKPlan/templates/AKPlan/load_fullcalendar.html b/AKModel/templates/AKModel/load_fullcalendar.html
similarity index 77%
rename from AKPlan/templates/AKPlan/load_fullcalendar.html
rename to AKModel/templates/AKModel/load_fullcalendar.html
index 6c2a93c8..5be1b149 100644
--- a/AKPlan/templates/AKPlan/load_fullcalendar.html
+++ b/AKModel/templates/AKModel/load_fullcalendar.html
@@ -2,8 +2,8 @@
 {% load i18n %}
 {% get_current_language as LANGUAGE_CODE %}
 
-<link href='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.css' %}' rel='stylesheet'/>
-<script src='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.js' %}'></script>
+<link href='{% static 'common/vendor/fullcalendar-scheduler/main.css' %}' rel='stylesheet'/>
+<script src='{% static 'common/vendor/fullcalendar-scheduler/main.js' %}'></script>
 
 {% with 'AKPlan/vendor/fullcalendar-scheduler/locales/'|add:LANGUAGE_CODE|add:'.js' as locale_file %}
     {% if LANGUAGE_CODE != "en" %}
diff --git a/AKModel/templates/AKModel/load_fullcalendar_availabilities.html b/AKModel/templates/AKModel/load_fullcalendar_availabilities.html
new file mode 100644
index 00000000..2d218668
--- /dev/null
+++ b/AKModel/templates/AKModel/load_fullcalendar_availabilities.html
@@ -0,0 +1,15 @@
+{% load static %}
+{% load i18n %}
+{% get_current_language as LANGUAGE_CODE %}
+
+<link href='{% static 'common/vendor/fullcalendar-scheduler/main.css' %}' rel='stylesheet'/>
+<script src='{% static 'common/vendor/fullcalendar-scheduler/main.js' %}'></script>
+<script src="{% static "common/vendor/moment/moment-with-locales.js" %}"></script>
+<script src="{% static "common/js/availabilities.js" %}"></script>
+
+{% with 'common/vendor/fullcalendar/locales/'|add:LANGUAGE_CODE|add:'.js' as locale_file %}
+    {% if LANGUAGE_CODE != "en" %}
+        {# Locale 'en' is included in main.js and does not exist separately #}
+        <script src="{% static locale_file %}"></script>
+    {% endif %}
+{% endwith %}
diff --git a/AKModel/templates/admin/AKModel/room_change_form.html b/AKModel/templates/admin/AKModel/room_change_form.html
index f2db1fbc..aac03532 100644
--- a/AKModel/templates/admin/AKModel/room_change_form.html
+++ b/AKModel/templates/admin/AKModel/room_change_form.html
@@ -7,8 +7,8 @@
 {% block extrahead %}
     {{ block.super }}
     {% bootstrap_javascript jquery='slim' %}
-    {% include "AKPlan/load_fullcalendar.html" %}
-    <script src="{% static "common/js/availabilities.js" %}"></script>
+    {% include "AKModel/load_fullcalendar_availabilities.html" %}
+
     <script>
         {% get_current_language as LANGUAGE_CODE %}
 
diff --git a/AKPlan/templates/AKPlan/plan_akslot.html b/AKPlan/templates/AKPlan/plan_akslot.html
index b13ba8e9..06bce88a 100644
--- a/AKPlan/templates/AKPlan/plan_akslot.html
+++ b/AKPlan/templates/AKPlan/plan_akslot.html
@@ -3,7 +3,7 @@
 {% load i18n %}
 {% load tags_AKPlan %}
 
-{% include "AKPlan/load_fullcalendar.html" %}
+{% include "AKModel/load_fullcalendar.html" %}
 
 <script>
     {% get_current_language as LANGUAGE_CODE %}
diff --git a/AKPlan/templates/AKPlan/plan_base.html b/AKPlan/templates/AKPlan/plan_base.html
index 7234dad4..351e39d0 100644
--- a/AKPlan/templates/AKPlan/plan_base.html
+++ b/AKPlan/templates/AKPlan/plan_base.html
@@ -10,7 +10,7 @@
 {% endblock %}
 
 {% block imports %}
-    {% include "AKPlan/load_fullcalendar.html" %}
+    {% include "AKModel/load_fullcalendar.html" %}
 
     {% block fullcalendar %}{% endblock %}
 {% endblock imports %}
diff --git a/AKPlan/templates/AKPlan/plan_wall.html b/AKPlan/templates/AKPlan/plan_wall.html
index 5d09ece0..93aa070c 100644
--- a/AKPlan/templates/AKPlan/plan_wall.html
+++ b/AKPlan/templates/AKPlan/plan_wall.html
@@ -20,7 +20,7 @@
 
     <link rel="stylesheet" href="{% static 'common/css/custom.css' %}">
 
-    {% include "AKPlan/load_fullcalendar.html" %}
+    {% include "AKModel/load_fullcalendar.html" %}
 
     {% get_current_language as LANGUAGE_CODE %}
 
diff --git a/AKScheduling/templates/admin/AKScheduling/scheduling.html b/AKScheduling/templates/admin/AKScheduling/scheduling.html
index 77db3f58..76be0908 100644
--- a/AKScheduling/templates/admin/AKScheduling/scheduling.html
+++ b/AKScheduling/templates/admin/AKScheduling/scheduling.html
@@ -11,7 +11,7 @@
 
 {% block extrahead %}
     {{ block.super }}
-    {% include "AKPlan/load_fullcalendar.html" %}
+    {% include "AKModel/templates/AKModel/load_fullcalendar.html" %}
 
     <style>
         .unscheduled-slot {
diff --git a/AKSubmission/templates/AKSubmission/submit_new.html b/AKSubmission/templates/AKSubmission/submit_new.html
index 60e387f7..b3699b3c 100644
--- a/AKSubmission/templates/AKSubmission/submit_new.html
+++ b/AKSubmission/templates/AKSubmission/submit_new.html
@@ -12,9 +12,7 @@
     <link rel="stylesheet" href="{% static 'common/vendor/chosen-js/chosen.css' %}">
     <link rel="stylesheet" href="{% static 'common/css/bootstrap-chosen.css' %}">
 
-    {% include "AKPlan/load_fullcalendar.html" %}
-    <script src="{% static "AKSubmission/vendor/moment/moment-with-locales.js" %}"></script>
-    <script src="{% static "common/js/availabilities.js" %}"></script>
+    {% include "AKModel/load_fullcalendar_availabilities.html" %}
 
     <script>
     {% get_current_language as LANGUAGE_CODE %}
diff --git a/AKPlan/static/AKPlan/vendor/fullcalendar-scheduler/locales/de.js b/static_common/common/vendor/fullcalendar-scheduler/locales/de.js
similarity index 100%
rename from AKPlan/static/AKPlan/vendor/fullcalendar-scheduler/locales/de.js
rename to static_common/common/vendor/fullcalendar-scheduler/locales/de.js
diff --git a/AKPlan/static/AKPlan/vendor/fullcalendar-scheduler/main.css b/static_common/common/vendor/fullcalendar-scheduler/main.css
similarity index 100%
rename from AKPlan/static/AKPlan/vendor/fullcalendar-scheduler/main.css
rename to static_common/common/vendor/fullcalendar-scheduler/main.css
diff --git a/AKPlan/static/AKPlan/vendor/fullcalendar-scheduler/main.js b/static_common/common/vendor/fullcalendar-scheduler/main.js
similarity index 100%
rename from AKPlan/static/AKPlan/vendor/fullcalendar-scheduler/main.js
rename to static_common/common/vendor/fullcalendar-scheduler/main.js
diff --git a/AKPlan/static/AKPlan/vendor/fullcalendar-scheduler/main.min.css b/static_common/common/vendor/fullcalendar-scheduler/main.min.css
similarity index 100%
rename from AKPlan/static/AKPlan/vendor/fullcalendar-scheduler/main.min.css
rename to static_common/common/vendor/fullcalendar-scheduler/main.min.css
diff --git a/AKPlan/static/AKPlan/vendor/fullcalendar-scheduler/main.min.js b/static_common/common/vendor/fullcalendar-scheduler/main.min.js
similarity index 100%
rename from AKPlan/static/AKPlan/vendor/fullcalendar-scheduler/main.min.js
rename to static_common/common/vendor/fullcalendar-scheduler/main.min.js
-- 
GitLab