diff --git a/home/static/css/style.css b/home/static/css/style.css index e899c98f4c87b4137eeb352caf96673a52d6102b..47c2ae616eb4a85eaf14e47e5d14060a4433f282 100644 --- a/home/static/css/style.css +++ b/home/static/css/style.css @@ -233,14 +233,6 @@ span.helptext { unicode-bidi: bidi-override; direction: rtl; } -.planning_title { - font-size: 1em; -} -.planning_room { - font-size: 1em; - color: #555; - font-style: italic; -} .button, .button:link, .button:visited, input[type=submit] { color: white; diff --git a/home/templates/activites.html b/home/templates/activites.html index b6035c4b20544ccbec46b96de095084d8ec19ef3..db350e2e32421638e01598a67c281dfba5fcbe5e 100644 --- a/home/templates/activites.html +++ b/home/templates/activites.html @@ -10,38 +10,47 @@ {% block "content" %} {% if settings.display_planning %} <h2>Planning</h2> - <div id="visualization"></div> + <div id="planning"></div> <script type="text/javascript"> // https://visjs.org/ // DOM element where the Timeline will be attached - var container = document.getElementById('visualization'); + const container = document.getElementById('planning'); - // Create a DataSet (allows two way data-binding) - var items = new vis.DataSet([ + const groups = new vis.DataSet([ + {id: {{ friday }}, content: "Vendredi", order: 0}, + {id: {{ saturday }}, content: "Samedi", order: 1}, + {id: {{ sunday }}, content: "Dimanche", order: 2}, + ]); + + // Items in the timeline + const items = new vis.DataSet([ {% for act in planning %} { id: {{ act.id }}, content: '<strong>{{ act.title }}</strong><div class="planning_room">{{ act.room }}</div>', - start: '{{ act.start|date:"Y-m-d H:i:s" }}', + start: '{{ settings.date_start|date:"Y-m-d"}} {{ act.start|date:"H:i:s" }}', align: 'left', - title: 'hello', + group: '{{ act.start|date:"d" }}', subgroup: '{{ act.room }}', - //end:'{{ act.end|date:"Y-m-d H:i:s" }}' + end:'{{ settings.date_start|date:"Y-m-d"}} {{ act.end|date:"H:i:s" }}' }, {% endfor %} ]); // Configuration for the Timeline - var options = { - // showMajorLabels: false, + const options = { + showMajorLabels: false, showCurrentTime: false, locale: "fr-fr", + groupOrder: "order", + start: '{{ settings.date_start|date:"Y-m-d"}} 00:00:00', + end: '{{ settings.date_start|date:"Y-m-d"}} 23:59:59', }; // Create a Timeline - var timeline = new vis.Timeline(container, items, options); - + const timeline = new vis.Timeline(container, items, options); + timeline.setGroups(groups); // timeline.on('select', function (properties) { // alert('selected items: ' + properties.items); // }); diff --git a/home/views.py b/home/views.py index 1fa5ab973a7426e14365ecb4979d6f15635b6cd9..0f44c57eb1734f99b7ef7d26723edd65894de76e 100644 --- a/home/views.py +++ b/home/views.py @@ -1,3 +1,5 @@ +from datetime import timedelta + from django.contrib import messages from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.sitemaps import Sitemap @@ -30,8 +32,12 @@ class ActivityView(TemplateView): def get_context_data(self, **kwargs): """ajoute la liste des activités au contexte""" context = super(ActivityView, self).get_context_data(**kwargs) + settings = SiteSettings.load() context['activities'] = InterludesActivity.objects.filter(display=True).order_by("title") context['planning'] = InterludesActivity.objects.filter(on_planning=True).order_by("title") + context['friday'] = settings.date_start.day + context['saturday'] = (settings.date_start + timedelta(days=1)).day + context['sunday'] = (settings.date_start + timedelta(days=2)).day return context