From 10667a087964ef22759ddb256543f4aa85ff1e3e Mon Sep 17 00:00:00 2001
From: Nils Steinger <git@n-st.de>
Date: Sat, 7 Nov 2020 22:04:49 +0100
Subject: [PATCH] Extract fullcalendar import as reusable snippet

This removes support for the explicit "locale: '{{ LANGUAGE_CODE }}'" setting,
but that should not be a problem as https://fullcalendar.io/docs/v3/locale
states:
> If you are simply loading one locale, you do not need to specify the locale
> option.
---
 AKPlan/templates/AKPlan/load_fullcalendar.html     | 13 +++++++++++++
 AKPlan/templates/AKPlan/plan_akslot.html           | 13 +------------
 AKPlan/templates/AKPlan/plan_base.html             | 12 +-----------
 AKPlan/templates/AKPlan/plan_wall.html             | 14 +-------------
 .../templates/admin/AKScheduling/scheduling.html   | 14 +-------------
 5 files changed, 17 insertions(+), 49 deletions(-)
 create mode 100644 AKPlan/templates/AKPlan/load_fullcalendar.html

diff --git a/AKPlan/templates/AKPlan/load_fullcalendar.html b/AKPlan/templates/AKPlan/load_fullcalendar.html
new file mode 100644
index 0000000..30fc76b
--- /dev/null
+++ b/AKPlan/templates/AKPlan/load_fullcalendar.html
@@ -0,0 +1,13 @@
+{% load static %}
+{% load i18n %}
+{% get_current_language as LANGUAGE_CODE %}
+
+<script src='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.js' %}'></script>
+<link href='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.css' %}' rel='stylesheet'/>
+
+{% with 'AKPlan/vendor/fullcalendar-scheduler/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/AKPlan/templates/AKPlan/plan_akslot.html b/AKPlan/templates/AKPlan/plan_akslot.html
index fe86ad2..ffa9dae 100644
--- a/AKPlan/templates/AKPlan/plan_akslot.html
+++ b/AKPlan/templates/AKPlan/plan_akslot.html
@@ -1,17 +1,8 @@
 {% load static %}
 {% load tz %}
 {% load i18n %}
-{% get_current_language as LANGUAGE_CODE %}
 
-<script src='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.js' %}'></script>
-<link href='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.css' %}' rel='stylesheet'/>
-
-{% with 'AKPlan/vendor/fullcalendar-scheduler/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 %}
+{% include "AKPlan/load_fullcalendar.html" %}
 
 <script>
 
@@ -22,8 +13,6 @@
             // Adapt to timezone of the connected event
             timeZone: '{{ ak.event.timezone }}',
             initialView: 'timeGrid',
-            // Adapt to user selected locale
-            locale: '{{ LANGUAGE_CODE }}',
             // No header, not buttons
             headerToolbar: false,
             aspectRatio: 2.5,
diff --git a/AKPlan/templates/AKPlan/plan_base.html b/AKPlan/templates/AKPlan/plan_base.html
index 320e3f8..7234dad 100644
--- a/AKPlan/templates/AKPlan/plan_base.html
+++ b/AKPlan/templates/AKPlan/plan_base.html
@@ -10,17 +10,7 @@
 {% endblock %}
 
 {% block imports %}
-    {% get_current_language as LANGUAGE_CODE %}
-
-    <script src='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.js' %}'></script>
-    <link href='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.css' %}' rel='stylesheet'/>
-
-    {% with 'AKPlan/vendor/fullcalendar-scheduler/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 %}
+    {% include "AKPlan/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 c824955..ac49b82 100644
--- a/AKPlan/templates/AKPlan/plan_wall.html
+++ b/AKPlan/templates/AKPlan/plan_wall.html
@@ -19,17 +19,7 @@
 
     <link rel="stylesheet" href="{% static 'common/css/custom.css' %}">
 
-    {% get_current_language as LANGUAGE_CODE %}
-
-    <script src='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.js' %}'></script>
-    <link href='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.css' %}' rel='stylesheet'/>
-
-    {% with 'AKPlan/vendor/fullcalendar-scheduler/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 %}
+    {% include "AKPlan/load_fullcalendar.html" %}
 
     <script>
         document.addEventListener('DOMContentLoaded', function () {
@@ -39,8 +29,6 @@
                 timeZone: '{{ event.timezone }}',
                 headerToolbar: false,
                 themeSystem: 'bootstrap',
-                // Adapt to user selected locale
-                locale: '{{ LANGUAGE_CODE }}',
                 slotDuration: '01:00',
                 initialView: 'resourceTimeline',
                 visibleRange: {
diff --git a/AKScheduling/templates/admin/AKScheduling/scheduling.html b/AKScheduling/templates/admin/AKScheduling/scheduling.html
index 79480ee..75dc0c3 100644
--- a/AKScheduling/templates/admin/AKScheduling/scheduling.html
+++ b/AKScheduling/templates/admin/AKScheduling/scheduling.html
@@ -11,17 +11,7 @@
 
 {% block extrahead %}
     {{ block.super }}
-    {% get_current_language as LANGUAGE_CODE %}
-
-    <script src='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.js' %}'></script>
-    <link href='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.css' %}' rel='stylesheet'/>
-
-    {% with 'AKPlan/vendor/fullcalendar-scheduler/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 %}
+    {% include "AKPlan/load_fullcalendar.html" %}
 
     <style>
         .unscheduled-slot {
@@ -88,8 +78,6 @@
                 },
                 //aspectRatio: 2,
                 themeSystem: 'bootstrap',
-                // Adapt to user selected locale
-                locale: '{{ LANGUAGE_CODE }}',
                 initialView: 'resourceTimelineEventVert',
                 views: {
                     resourceTimelineDayHoriz: {
-- 
GitLab