rowt/templates/index.html.tera

258 lines
12 KiB
Plaintext
Raw Normal View History

{% import "includes/macros" as macros %}
2023-04-03 16:11:26 +02:00
{% extends "base" %}
{% block content %}
2023-04-07 08:57:18 +02:00
<div class="max-w-screen-xl w-full grid sm:grid-cols-2 lg:grid-cols-3 gap-4">
{% if flash %}
2023-04-07 09:57:38 +02:00
{{ macros::alert(message=flash.1, type=flash.0, class="sm:col-span-2 lg:col-span-3") }}
2023-04-07 08:57:18 +02:00
{% endif %}
2023-04-05 22:35:52 +02:00
<h1 class="h1 sm:col-span-2 lg:col-span-3">Ausfahrten</h1>
2023-04-06 09:30:43 +02:00
2023-04-28 18:55:51 +02:00
{% include "includes/buttons" %}
2023-04-07 12:37:33 +02:00
2023-04-07 08:57:18 +02:00
{% for day in days %}
2023-04-07 12:37:33 +02:00
{% set amount_trips = day.planned_events | length + day.trips | length %}
{% set_global day_cox_needed = false %}
{% if day.planned_events | length > 0 %}
{% for planned_event in day.planned_events %}
{% if planned_event.cox_needed %}
{% set_global day_cox_needed = true %}
{% endif %}
{% endfor %}
{% endif %}
2023-04-10 22:42:00 +02:00
<div class="bg-white p-3 rounded-md flex justify-between flex-col shadow reset-js" style="min-height: 10rem;" data-trips="{{ amount_trips }}" data-month="{{ day.day| date(format='%m') }}" data-coxneeded="{{ day_cox_needed }}">
2023-04-07 08:57:18 +02:00
<div>
2023-04-08 07:29:39 +02:00
<h2 class="font-bold uppercase tracking-wide text-center text-primary-950 text-lg">{{ day.day| date(format="%d.%m.%Y") }}
<small class="inline-block ml-1 text-xs text-gray-400">{{ day.day | date(format="%A", locale="de_AT") }}</small>
</h2>
2023-04-08 09:14:48 +02:00
{% if day.planned_events | length > 0 or day.trips | length > 0 %}
<div class="grid grid-cols-1 gap-3 divide-y mb-3">
2023-04-08 09:14:48 +02:00
{# --- START Events --- #}
2023-04-07 08:57:18 +02:00
{% if day.planned_events | length > 0 %}
{% for planned_event in day.planned_events %}
{% set amount_cur_cox = planned_event.cox | length %}
{% set amount_cox_missing = planned_event.planned_amount_cox - amount_cur_cox %}
<div class="pt-2">
2023-04-07 08:57:18 +02:00
<div class="flex justify-between items-center">
<div>
<strong class="text-primary-900">{{ planned_event.planned_starting_time }} Uhr</strong> <small
class="text-gray-600">({{ planned_event.name }})</small><br />
2023-04-08 09:14:48 +02:00
<a href="#" data-sidebar="true" data-trigger="sidebar"
2023-04-28 21:42:12 +02:00
data-header="<strong>{{ planned_event.planned_starting_time }} Uhr</strong> ({{ planned_event.name }}){% if planned_event.notes %}<small class='block'>{{ planned_event.notes }}</small>{% endif %}"
2023-04-08 09:17:46 +02:00
data-body="#event{{ planned_event.trip_details_id }}"
2023-04-08 09:14:48 +02:00
class="inline-block link-primary mr-3">
Details
</a>
</div>
2023-04-07 08:57:18 +02:00
<div class="text-right grid gap-2">
2023-04-08 09:14:48 +02:00
{# --- START Row Buttons --- #}
2023-04-07 08:57:18 +02:00
{% set_global cur_user_participates = false %}
{% for rower in planned_event.rower%}
{% if rower.name == loggedin_user.name %}
{% set_global cur_user_participates = true %}
2023-04-06 19:53:22 +02:00
{% endif %}
{% endfor %}
2023-04-07 08:57:18 +02:00
{% if cur_user_participates %}
<a href="/remove/{{ planned_event.trip_details_id }}" class="btn btn-attention btn-fw">Abmelden</a>
2023-04-07 08:57:18 +02:00
{% endif %}
{% if planned_event.max_people > planned_event.rower | length %}
{% if cur_user_participates == false %}
<a href="/join/{{ planned_event.trip_details_id }}" class="btn btn-primary btn-fw">Mitrudern</a>
{% endif %}
2023-04-07 08:57:18 +02:00
{% endif %}
2023-04-08 09:14:48 +02:00
{# --- END Row Buttons --- #}
2023-04-07 08:57:18 +02:00
2023-04-08 09:14:48 +02:00
{# --- START Cox Buttons --- #}
2023-04-07 08:57:18 +02:00
{% if loggedin_user.is_cox %}
2023-04-08 09:14:48 +02:00
{% set_global cur_user_participates = false %}
{% for cox in planned_event.cox %}
{% if cox.name == loggedin_user.name %}
{% set_global cur_user_participates = true %}
{% endif %}
{% endfor %}
{% if cur_user_participates %}
<a href="/cox/remove/{{ planned_event.id }}" class="block btn btn-attention btn-fw">
{% include "includes/cox-icon" %}
Abmelden
</a>
{% else %}
<a href="/cox/join/{{ planned_event.id }}" class="block btn {% if amount_cox_missing > 0 %} btn-dark {% else %} btn-gray {% endif %} btn-fw">
2023-04-08 09:14:48 +02:00
{% include "includes/cox-icon" %}
Steuern
</a>
{% endif %}
2023-04-07 08:57:18 +02:00
{% endif %}
2023-04-08 09:14:48 +02:00
{# --- END Cox Buttons --- #}
2023-04-07 08:57:18 +02:00
</div>
</div>
2023-04-08 09:14:48 +02:00
{# --- START Sidebar Content --- #}
<div class="hidden">
<div id="event{{ planned_event.trip_details_id }}">
{# --- START List Coxes --- #}
2023-04-07 08:57:18 +02:00
{% if planned_event.planned_amount_cox > 0 %}
2023-04-17 19:21:19 +02:00
{% if amount_cox_missing > 0 %}
2023-04-28 19:35:21 +02:00
{{ macros::box(participants=planned_event.cox, empty_seats=planned_event.planned_amount_cox - amount_cur_cox, header='Noch benötigte Steuerleute:', text='Keine Steuerleute angemeldet') }}
2023-04-17 19:21:19 +02:00
{% else %}
{{ macros::box(participants=planned_event.cox, empty_seats="", header='Genügend Steuerleute haben sich angemeldet :-)', text='Keine Steuerleute angemeldet') }}
{% endif %}
2023-04-07 08:57:18 +02:00
{% endif %}
{# --- END List Coxes --- #}
{# --- START List Rowers --- #}
2023-04-07 08:57:18 +02:00
{% if planned_event.max_people > 0 %}
{% set amount_cur_rower = planned_event.rower | length %}
{{ macros::box(participants=planned_event.rower, empty_seats=planned_event.max_people - amount_cur_rower, bg='primary-100', color='black') }}
2023-04-07 08:57:18 +02:00
{% endif %}
{# --- END List Rowers --- #}
2023-04-07 08:57:18 +02:00
{% if planned_event.allow_guests %}
<div class="text-primary-900 bg-primary-50 text-center p-1 mb-4">Gäste sind erlaubt</div>
2023-04-07 08:57:18 +02:00
{% endif %}
{# --- START Delete Btn --- #}
2023-04-07 08:57:18 +02:00
{% if loggedin_user.is_admin %}
<div class="text-right">
<a href="/admin/planned-event/{{ planned_event.id }}/delete" class="inline-block btn btn-alert">
{% include "includes/delete-icon" %}
Termin löschen
</a>
</div>
2023-04-07 08:57:18 +02:00
{% endif %}
{# --- END Delete Btn --- #}
2023-04-06 13:15:40 +02:00
</div>
</div>
2023-04-08 09:14:48 +02:00
{# --- END Sidebar Content --- #}
</div>
2023-04-07 08:57:18 +02:00
{% endfor %}
{% endif %}
2023-04-08 09:14:48 +02:00
{# --- END Events --- #}
2023-04-05 22:35:52 +02:00
2023-04-08 09:14:48 +02:00
{# --- START Trips --- #}
2023-04-07 08:57:18 +02:00
{% if day.trips | length > 0 %}
{% for trip in day.trips %}
2023-04-10 22:42:00 +02:00
<div class="pt-2 reset-js" data-coxneeded="false">
2023-04-07 08:57:18 +02:00
<div class="flex justify-between items-center">
<div>
<strong class="text-primary-900">{% if trip.max_people == 0 %}<span class="text-[#f43f5e]">&#9888; </span>{% endif %}{{ trip.planned_starting_time }} Uhr</strong>
{% if trip.max_people == 0 %}
<small class="text-[#f43f5e]">(Absage {{ trip.cox_name }})</small>
{% else %}
<small class="text-gray-600">({{ trip.cox_name }})</small>
{% endif %}
<br />
2023-04-08 09:14:48 +02:00
<a href="#" data-sidebar="true" data-trigger="sidebar"
data-header="<strong>{% if trip.max_people == 0 %}&#9888; {% endif %}{{ trip.planned_starting_time }} Uhr</strong> ({{ trip.cox_name }}){% if trip.notes and trip.max_people > 0 %}<small class='block'>{{ trip.notes }}</small>{% endif %}{% if trip.max_people == 0 %}<small class='block'>Ausfahrt abgesagt!</small>{% endif %}"
2023-04-08 09:17:46 +02:00
data-body="#trip{{ trip.trip_details_id }}"
2023-04-08 09:14:48 +02:00
class="inline-block link-primary mr-3">
Details
</a>
2023-04-07 08:57:18 +02:00
</div>
2023-04-08 09:14:48 +02:00
2023-04-07 08:57:18 +02:00
<div>
{% set_global cur_user_participates = false %}
{% for rower in trip.rower %}
2023-04-08 09:14:48 +02:00
{% if rower.name == loggedin_user.name %}
{% set_global cur_user_participates = true %}
{% endif %}
2023-04-07 08:57:18 +02:00
{% endfor %}
{% if cur_user_participates %}
2023-04-08 09:14:48 +02:00
<a href="/remove/{{ trip.trip_details_id }}"
2023-04-09 19:03:04 +02:00
class="btn btn-attention btn-fw">Abmelden</a>
2023-04-07 08:57:18 +02:00
{% endif %}
2023-04-08 09:14:48 +02:00
{% if trip.max_people > trip.rower | length and trip.cox_id != loggedin_user.id and cur_user_participates == false%}
<a href="/join/{{ trip.trip_details_id }}"
2023-04-09 19:03:04 +02:00
class="btn btn-primary btn-fw">Mitrudern</a>
2023-04-07 08:57:18 +02:00
{% endif %}
</div>
</div>
</div>
2023-04-08 09:14:48 +02:00
{# --- START Sidebar Content --- #}
<div class="hidden">
<div id="trip{{ trip.trip_details_id }}">
2023-04-28 20:46:46 +02:00
{% if trip.max_people == 0 %}
{# --- border-[#f43f5e] bg-[#f43f5e] --- #}
{{ macros::box(participants=trip.rower,bg='[#f43f5e]',header='Absage') }}
{% else %}
{% set amount_cur_rower = trip.rower | length %}
{{ macros::box(participants=trip.rower, empty_seats=trip.max_people - amount_cur_rower, bg='primary-100', color='black') }}
{% endif %}
{# --- START Edit Form --- #}
2023-04-10 22:42:00 +02:00
{% if trip.cox_id == loggedin_user.id %}
<div class="bg-gray-100 p-3 mt-4 rounded-md">
<h3 class="text-primary-950 font-bold uppercase tracking-wide mb-2">Ausfahrt bearbeiten</h3>
<form action="/cox/trip/{{ trip.id }}" method="post" class="grid gap-3">
{{ macros::input(label='Anzahl Ruderer', name='max_people', type='number', required=true, value=trip.max_people, min='0') }}
2023-04-10 22:42:00 +02:00
{{ macros::input(label='Anmerkungen', name='notes', type='input', value=trip.notes) }}
<input value="Bearbeiten" class="btn btn-primary" type="submit" />
</form>
</div>
{% if trip.rower | length == 0 %}
<div class="text-right mt-6">
<a href="/cox/remove/trip/{{ trip.id }}" class="inline-block btn btn-alert">
{% include "includes/delete-icon" %}
Termin löschen
</a>
</div>
2023-04-07 21:30:55 +02:00
{% endif %}
{% endif %}
2023-04-10 22:42:00 +02:00
{# --- END Edit Form --- #}
2023-04-08 09:14:48 +02:00
</div>
2023-04-07 08:57:18 +02:00
</div>
2023-04-08 09:14:48 +02:00
{# --- END Sidebar Content --- #}
2023-04-07 08:57:18 +02:00
{% endfor %}
{% endif %}
2023-04-08 09:14:48 +02:00
{# --- END Trips --- #}
</div>
{% endif %}
2023-04-07 08:57:18 +02:00
</div>
2023-04-08 09:14:48 +02:00
{# --- START Add Buttons --- #}
2023-04-08 07:29:39 +02:00
{% if loggedin_user.is_admin or loggedin_user.is_cox %}
<div class="-mb-3 -mx-3 grid {% if loggedin_user.is_admin %} grid-cols-2 {% endif %} text-center">
{% if loggedin_user.is_admin %}
2023-04-08 09:14:48 +02:00
<a href="#" data-sidebar="true" data-trigger="sidebar"
2023-04-08 07:29:39 +02:00
data-header="<strong>Event</strong> am {{ day.day| date(format='%d.%m.%Y') }} erstellen"
data-day="{{ day.day }}"
2023-04-08 09:17:46 +02:00
data-body="#addEventForm"
2023-04-08 07:29:39 +02:00
class="relative inline-block w-full bg-primary-900 hover:bg-primary-950 focus:bg-primary-950 text-white py-2 rounded-bl-md text-sm font-semibold">
<span class="absolute inset-y-0 left-0 flex items-center pl-3">
{% include "includes/plus-icon" %}
</span>
Event
</a>
{% endif %}
2023-04-05 22:35:52 +02:00
2023-04-08 07:29:39 +02:00
{% if loggedin_user.is_cox%}
2023-04-08 09:14:48 +02:00
<a href="#" data-sidebar="true" data-trigger="sidebar"
2023-04-08 07:29:39 +02:00
data-header="<strong>Ausfahrt</strong> am {{ day.day| date(format='%d.%m.%Y') }} erstellen"
data-day="{{ day.day }}"
2023-04-08 09:17:46 +02:00
data-body="#sidebarForm"
2023-04-08 07:33:32 +02:00
class="relative inline-block w-full py-2 text-primary-900 hover:text-primary-950 focus:text-primary-950 text-sm font-semibold bg-gray-100 hover:bg-gray-200 focus:bg-gray-200 {% if loggedin_user.is_admin %} rounded-br-md {% else %} rounded-b-md {% endif %}">
2023-04-08 07:29:39 +02:00
<span class="absolute inset-y-0 left-0 flex items-center pl-3">
{% include "includes/plus-icon" %}
</span>
Ausfahrt
</a>
{% endif %}
</div>
{% endif %}
2023-04-08 09:14:48 +02:00
{# --- END Add Buttons --- #}
</div>
2023-04-07 08:57:18 +02:00
{% endfor %}
2023-04-08 09:14:48 +02:00
</div>
2023-04-05 22:35:52 +02:00
</div>
2023-04-28 18:55:51 +02:00
{% include "dynamics/sidebar" %}
2023-04-28 18:35:42 +02:00
{% include "forms/trip" %}
{% include "forms/event" %}
{% endblock content %}