{# djlint:off #}
{% load training_tags %}
{% load custom_tags_and_filters %}
[
	{% for x in events %}
	{
		{% if personal_schedule and x.tool %}
			"title": "{{x.reservation_item.name|escapejs}} ({{x.user.username|escapejs}})\n{{ x.title|escapejs }}",
			"color": "#33ad33",
		{% elif personal_schedule and x.area %}
			"title": "{{x.reservation_item.name|escapejs}} ({{x.user.username|escapejs}})\n{{ x.title|escapejs }}",
			"color": "#84CD84",
		{% elif all_tools or all_areastools and x.tool %}
			"title": "{{x.reservation_item.name|escapejs}} ({{x.user.username|escapejs}})\n{{ x.title|escapejs }}",
			"color": "{{ x.reservation_item.tool_calendar_color|default:'#33ad33'|escapejs }}",
		{% elif all_areas or all_areastools and x.area %}
			"title": "{{x.reservation_item.name|escapejs}} ({{x.user.username|escapejs}})\n{{ x.title|escapejs }}",
			"color": "{{ x.reservation_item.area_calendar_color|default:'#84CD84'|escapejs }}",
		{% else %}
            {% if display_name %}
			    "title": "{{x.reservation_item.name|escapejs}} ({{x.user.username|escapejs}})\n{{ x.title|escapejs }}",
            {% else %}
                "title": "{{ x.title|default:x.user|escapejs }}{% if display_configuration %}\n{{ x.get_configuration_options_display|escapejs }}{% endif %}",
                {% if display_configuration and x.get_configuration_options_colors %}"colors": ["{{ x.get_configuration_options_colors|join:'","' }}"],{% endif %}
            {% endif %}
            "color": "{% if x.tool %}{% if x.reservation_item.tool_calendar_color|lower == "#33ad33" %}#88B7CD{% else %}{{ x.reservation_item.tool_calendar_color|default:"#88B7CD"|escapejs }}{% endif %}{% else %}{{ x.reservation_item.area_calendar_color|default:"#88B7CD"|escapejs }}{% endif %}",
			{% if x.user.id == user.id %}"own-reservation": true,{% endif %}
		{% endif %}
		{% if x.creator.id == x.user.id %}
			"tooltip": "{{ x.reservation_item.name }} reservation for {{ x.user }}",
		{% else %}
			"tooltip": "{{ x.reservation_item.name }} reservation for {{ x.user }}, created by {{ x.creator }}",
		{% endif %}
		"id": "Reservation {{ x.id }}",
		{# The reservation creator or staff may edit the event: #}
		{% if user.id == x.user.id or user.is_staff %}"editable": true,{% endif %}
		"start": "{{ x.start|date:"c" }}",
		"end": "{{ x.get_visual_end|date:"c" }}",
		"details_url": "{% url 'reservation_details' x.id %}"
	}{% if not forloop.last %},{% elif outages or trainings %},{% endif %}
	{% endfor %}
	{% for x in outages %}
	{
		"title": "{{ x.title|escapejs }}",
		"id": "Outage {{ x.id }}",
		{% if user.is_staff %}"editable": true,{% endif %}
		"color": "#ff0000",
		"start": "{{ x.start|date:"c" }}",
		"end": "{{ x.end|date:"c" }}",
		"details_url": "{% url 'outage_details' x.id %}"
	}{% if not forloop.last %},{% elif trainings %},{% endif %}
	{% endfor %}
	{% for training in trainings %}
	{
		{% with default_technique="training"|customization:"training_technique_empty_label" %}
			{% if personal_schedule or all_tools or all_areastools %}
				"title": "{{ training.tool.name }} training by {{ training.trainer.get_name }}\n({{ training.technique|default_if_none:default_technique }})",
			{% else %}
				"title": "Training by {{ training.trainer.get_name }}\n({{ training.technique|default_if_none:default_technique }})",
			{% endif %}
		{% endwith %}
		{% if training.invitation_only and user not in training.users.all and not training|training_event_invitations:user or training.current_capacity >= training.capacity or not training|is_qualified:user %}
			"before": "<span class='pull-right glyphicon glyphicon-lock'></span>",
		{% endif %}
		"id": "Training {{ training.id }}",
		"color": "#BF00FFFF",
		"start": "{{ training.start|date:"c" }}",
		"end": "{{ training.end|date:"c" }}",
		{% if user.is_staff or user|is_trainer:training.tool %}"editable": true,{% endif %}
		"details_url": "{% url 'training_event_details' training.id %}"
	}{% if not forloop.last %},{% endif %}
	{% endfor %}
]
