<commit_before>{% extends "helpdesk_base.html" %}

{% load i18n vpfilters staticfiles memberships %}

{% block title %}
    {% blocktrans trimmed context "title with facility" with facility_name=facility.name %}
        Schedule for {{ facility_name }}
    {% endblocktrans %}
{% endblock %}

{% if facility.timeline_enabled > facility.TimelineViewMode.DISABLED %}

    {% block additional_js %}
        <script src="{% static "momentjs/moment.min.js" %}"></script>
        {{ block.super }}
        <script src="{% static "visjs/vis.min.js" %}"></script>
        <script>
            var now = moment().minutes(0).seconds(0).milliseconds(0);
            var groupCount = 3;
            var itemCount = 20;

            // create a data set with groups
            var groups = new vis.DataSet();
            var items = new vis.DataSet(
                    {
                        type: {
                            start: 'ISODate',
                            end: 'ISODate'
                        }
                    }
            );

            {% regroup shifts by task as shifts_by_task %}
            {% for shift_by_task in shifts_by_task %}
                {% with shift_by_task.grouper as task %}


                    groups.add(
                            {
                                id: {{ task.id }},
                                content: '{{ task.name }}',
                                value: '{{ task.name }}',
                                subgroupOrder: function (a, b) {
                                    return a.subgroupOrder - b.subgroupOrder;
                                },
                                stack: false
                            }
                    );
                    {% regroup shift_by_task.list by workplace as shifts_by_workplace %}
                    {% for shift_by_workplace in shifts_by_workplace %}
                        {% with shift_by_workplace.grouper as workplace %}

                            {% for shift in shift_by_workplace.list %}
                                {% with slots_left=shift.volunteer_count|subtract:shift.slots slots_percent=shift.volunteer_count|divide:shift.slots is_assigned=shift.helpers.all|contains:user.account %}

                                    items.add({
                                        id: {{ shift.id }},
                                        group: {{ task.id }},
                                        subgroup: '{{ workplace.id|default:"no workplace" }}',
                                        content: '<a href="#{{ shift.id }}">{{ shift.workplace.name|default:shift.task.name }} ({{ shift.volunteer_count }}/{{ shift.slots }})<br>{% blocktrans trimmed with starting_time=shift.starting_time|date:"H:i" ending_time=shift.ending_time|date:"H:i" %}{{ starting_time }} - {{ ending_time }}{% endblocktrans %}</a>',
                                        subgroupOrder: '{{ workplace.name }}',
                                        start: "{{ shift.starting_time|date:"c" }}",
                                        end: "{{ shift.ending_time|date:"c" }}"
                                    });
                                {% endwith %}
                            {% endfor %}
                        {% endwith %}
                    {% endfor %}
                {% endwith %}
            {% endfor %}


            // create visualization
            var container = document.getElementById('timeline');

            startDate = moment('{{ schedule_date|date:"c" }}');
            endDate = startDate.clone()
            endDate.add(moment.duration({'days': 1}))
            var options = {
                groupOrder: 'value',  // groupOrder can be a property name or a sorting function
                start: startDate,
                end: endDate,
                editable: false,
                stack: false,
                moveable: false,
                orientation: {
                    axis: 'both',
                    item: 'bottom'
                }
            };

            var timeline;  //= new vis.Timeline(container);

            function showTimeline() {
                timeline = new vis.Timeline(container);
                timeline.setOptions(options);
                timeline.setGroups(groups);
                timeline.setItems(items);
                timeline.fit({animation: false});
            }

            $('#timeline').on('shown.bs.collapse', function () {
                showTimeline();
            });


            $('#timeline').on('hidden.bs.collapse', function () {
                timeline.destroy();
            });

            {% if facility.timeline_enabled > facility.TimelineViewMode.COLLAPSED %}
                $(function () {
                            $('#timeline').collapse("show");
                        }
                );
            {% endif %}

        </script>
    {% endblock %}
{% endif %}

{% block additional_css %}
    {{ block.super }}
    {% if facility.timeline_enabled > facility.TimelineViewMode.DISABLED %}
        <link href="{% static "visjs/vis.min.css" %}" rel="stylesheet">
    {% endif %}

    <style>
        .collapsing {
            -webkit-transition: none;
            transition: none;
        }

        *:target, tr:target td {
            background-color: #FFFDD9;
        }
    </style>
{% endblock %}

{% block helpdesk_content %}

    <ul class="breadcrumb">
        <li>
            <a href="/helpdesk/">{% trans "Helpdesk" %}</a>
        </li>

        <li>
            <a href="{{ facility.organization.get_absolute_url }}">
                {{ facility.organization.name }}
            </a>
        </li>

        <li>
            <a href="{{ facility.get_absolute_url }}">
                {{ facility.name }}
            </a>
        </li>

        <li class="active">
            {{ schedule_date|date }}
        </li>
    </ul>

    {% include "partials/alert_messages.html" %}

    <div class="row">
        <h2>
            {{ facility.name }}
        </h2>

        <h3>
            {% blocktrans trimmed context "title with date" with schedule_date=schedule_date|date %}
                Schedule for {{ schedule_date }}
            {% endblocktrans %}

        </h3>

        {% if facility.timeline_enabled > facility.TimelineViewMode.DISABLED %}
            <button class="small fa fa-calendar"
                    role="button"
                    data-toggle="collapse"
                    href="#timeline"
                    aria-expanded="false"
                    aria-controls="timeline">
                {% trans "Toggle Timeline" %}
            </button>

            {% if facility.timeline_enabled > facility.TimelineViewMode.DISABLED %}
                <div id="timeline" class="collapse">

                </div>
            {% endif %}
        {% endif %}
    </div>
    <form method="POST">
        {% csrf_token %}

        {% regroup shifts by task as shifts_by_task %}

        {% for shift_by_task in shifts_by_task %}
            {% with shift_by_task.grouper as task %}

                {% regroup shift_by_task.list by workplace as shifts_by_workplace %}

                {% for shift_by_workplace in shifts_by_workplace %}
                    {% with shift_by_workplace.grouper as workplace %}

                        <div class="row">
                            <h3 id="task-{{ task.id }}-{{ workplace.id }}">
                                {% if workplace %}
                                    {{ task.name }} -
                                    {{ workplace.name }}
                                {% else %}
                                    {{ task.name }}
                                {% endif %}

                                <a href="#task-{{ task.id }}-{{ workplace.id }}">
                                    <span class="small fa fa-link"></span>
                                </a>
                            </h3>

                            {% if task.description %}
                                <p>
                                    {{ task.description|safe }}
                                </p>
                            {% endif %}
                            {% if workplace.description %}
                                <p>
                                    <strong>{{ workplace.name }}</strong>: {{ workplace.description|safe }}
                                </p>
                            {% endif %}

                            <table class="table table-striped">
                                <thead>
                                <tr>
                                    <th>
                                        {% trans "Link" %}
                                    </th>
                                    <th colspan="2" width="10%"><commit_msg>Fix main content alignment on /shifts show page<commit_after>{% extends "helpdesk_base.html" %}

{% load i18n vpfilters staticfiles memberships %}

{% block title %}
    {% blocktrans trimmed context "title with facility" with facility_name=facility.name %}
        Schedule for {{ facility_name }}
    {% endblocktrans %}
{% endblock %}

{% if facility.timeline_enabled > facility.TimelineViewMode.DISABLED %}

    {% block additional_js %}
        <script src="{% static "momentjs/moment.min.js" %}"></script>
        {{ block.super }}
        <script src="{% static "visjs/vis.min.js" %}"></script>
        <script>
            var now = moment().minutes(0).seconds(0).milliseconds(0);
            var groupCount = 3;
            var itemCount = 20;

            // create a data set with groups
            var groups = new vis.DataSet();
            var items = new vis.DataSet(
                    {
                        type: {
                            start: 'ISODate',
                            end: 'ISODate'
                        }
                    }
            );

            {% regroup shifts by task as shifts_by_task %}
            {% for shift_by_task in shifts_by_task %}
                {% with shift_by_task.grouper as task %}


                    groups.add(
                            {
                                id: {{ task.id }},
                                content: '{{ task.name }}',
                                value: '{{ task.name }}',
                                subgroupOrder: function (a, b) {
                                    return a.subgroupOrder - b.subgroupOrder;
                                },
                                stack: false
                            }
                    );
                    {% regroup shift_by_task.list by workplace as shifts_by_workplace %}
                    {% for shift_by_workplace in shifts_by_workplace %}
                        {% with shift_by_workplace.grouper as workplace %}

                            {% for shift in shift_by_workplace.list %}
                                {% with slots_left=shift.volunteer_count|subtract:shift.slots slots_percent=shift.volunteer_count|divide:shift.slots is_assigned=shift.helpers.all|contains:user.account %}

                                    items.add({
                                        id: {{ shift.id }},
                                        group: {{ task.id }},
                                        subgroup: '{{ workplace.id|default:"no workplace" }}',
                                        content: '<a href="#{{ shift.id }}">{{ shift.workplace.name|default:shift.task.name }} ({{ shift.volunteer_count }}/{{ shift.slots }})<br>{% blocktrans trimmed with starting_time=shift.starting_time|date:"H:i" ending_time=shift.ending_time|date:"H:i" %}{{ starting_time }} - {{ ending_time }}{% endblocktrans %}</a>',
                                        subgroupOrder: '{{ workplace.name }}',
                                        start: "{{ shift.starting_time|date:"c" }}",
                                        end: "{{ shift.ending_time|date:"c" }}"
                                    });
                                {% endwith %}
                            {% endfor %}
                        {% endwith %}
                    {% endfor %}
                {% endwith %}
            {% endfor %}


            // create visualization
            var container = document.getElementById('timeline');

            startDate = moment('{{ schedule_date|date:"c" }}');
            endDate = startDate.clone()
            endDate.add(moment.duration({'days': 1}))
            var options = {
                groupOrder: 'value',  // groupOrder can be a property name or a sorting function
                start: startDate,
                end: endDate,
                editable: false,
                stack: false,
                moveable: false,
                orientation: {
                    axis: 'both',
                    item: 'bottom'
                }
            };

            var timeline;  //= new vis.Timeline(container);

            function showTimeline() {
                timeline = new vis.Timeline(container);
                timeline.setOptions(options);
                timeline.setGroups(groups);
                timeline.setItems(items);
                timeline.fit({animation: false});
            }

            $('#timeline').on('shown.bs.collapse', function () {
                showTimeline();
            });


            $('#timeline').on('hidden.bs.collapse', function () {
                timeline.destroy();
            });

            {% if facility.timeline_enabled > facility.TimelineViewMode.COLLAPSED %}
                $(function () {
                            $('#timeline').collapse("show");
                        }
                );
            {% endif %}

        </script>
    {% endblock %}
{% endif %}

{% block additional_css %}
    {{ block.super }}
    {% if facility.timeline_enabled > facility.TimelineViewMode.DISABLED %}
        <link href="{% static "visjs/vis.min.css" %}" rel="stylesheet">
    {% endif %}

    <style>
        .collapsing {
            -webkit-transition: none;
            transition: none;
        }

        *:target, tr:target td {
            background-color: #FFFDD9;
        }
    </style>
{% endblock %}

{% block helpdesk_content %}

    <ul class="breadcrumb">
        <li>
            <a href="/helpdesk/">{% trans "Helpdesk" %}</a>
        </li>

        <li>
            <a href="{{ facility.organization.get_absolute_url }}">
                {{ facility.organization.name }}
            </a>
        </li>

        <li>
            <a href="{{ facility.get_absolute_url }}">
                {{ facility.name }}
            </a>
        </li>

        <li class="active">
            {{ schedule_date|date }}
        </li>
    </ul>

    {% include "partials/alert_messages.html" %}

    <div>
        <h2>
            {{ facility.name }}
        </h2>

        <h3>
            {% blocktrans trimmed context "title with date" with schedule_date=schedule_date|date %}
                Schedule for {{ schedule_date }}
            {% endblocktrans %}

        </h3>

        {% if facility.timeline_enabled > facility.TimelineViewMode.DISABLED %}
            <button class="small fa fa-calendar"
                    role="button"
                    data-toggle="collapse"
                    href="#timeline"
                    aria-expanded="false"
                    aria-controls="timeline">
                {% trans "Toggle Timeline" %}
            </button>

            {% if facility.timeline_enabled > facility.TimelineViewMode.DISABLED %}
                <div id="timeline" class="collapse">

                </div>
            {% endif %}
        {% endif %}
    </div>
    <form method="POST">
        {% csrf_token %}

        {% regroup shifts by task as shifts_by_task %}

        {% for shift_by_task in shifts_by_task %}
            {% with shift_by_task.grouper as task %}

                {% regroup shift_by_task.list by workplace as shifts_by_workplace %}

                {% for shift_by_workplace in shifts_by_workplace %}
                    {% with shift_by_workplace.grouper as workplace %}

                        <div>
                            <h3 id="task-{{ task.id }}-{{ workplace.id }}">
                                {% if workplace %}
                                    {{ task.name }} -
                                    {{ workplace.name }}
                                {% else %}
                                    {{ task.name }}
                                {% endif %}

                                <a href="#task-{{ task.id }}-{{ workplace.id }}">
                                    <span class="small fa fa-link"></span>
                                </a>
                            </h3>

                            {% if task.description %}
                                <p>
                                    {{ task.description|safe }}
                                </p>
                            {% endif %}
                            {% if workplace.description %}
                                <p>
                                    <strong>{{ workplace.name }}</strong>: {{ workplace.description|safe }}
                                </p>
                            {% endif %}

                            <table class="table table-striped">
                                <thead>
                                <tr>
                                    <th>
                                        {% trans "Link" %}
                                    </th>
                                    <th colspan="2" width="10%">
{'fraction_non_alphanumeric': 0.11996596710153148, 'fraction_numerical': 0.0021554169030062395, 'mean_word_length': 1.06621352396578, 'pattern_counts': {'":': 0, '<': 119, '<?xml version=': 0, '>': 129, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 62, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6600482', 'n_tokens_mistral': 4595, 'n_tokens_neox': 4087, 'n_words': 824}