better layout
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled

This commit is contained in:
philipp 2024-05-16 22:35:26 +02:00
parent f034f80794
commit 0eac1a66f9
4 changed files with 77 additions and 85 deletions

View File

@ -21,9 +21,10 @@ use sqlx::SqlitePool;
use tera::Context; use tera::Context;
use crate::model::{ use crate::model::{
logbook::Logbook,
notification::Notification, notification::Notification,
role::Role, role::Role,
user::{User, UserWithDetails}, user::{User, UserWithDetails, SCHECKBUCH},
}; };
pub(crate) mod admin; pub(crate) mod admin;
@ -52,8 +53,15 @@ async fn index(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_
context.insert("flash", &msg.into_inner()); context.insert("flash", &msg.into_inner());
} }
if user.has_role(db, "scheckbuch").await {
let last_trips = Logbook::completed_with_user(db, &user).await;
context.insert("last_trips", &last_trips);
}
context.insert("notifications", &Notification::for_user(db, &user).await); context.insert("notifications", &Notification::for_user(db, &user).await);
context.insert("loggedin_user", &UserWithDetails::from_user(user, db).await); context.insert("loggedin_user", &UserWithDetails::from_user(user, db).await);
context.insert("costs_scheckbuch", &SCHECKBUCH);
Template::render("index", context.into_json()) Template::render("index", context.into_json())
} }

View File

@ -32,11 +32,6 @@ async fn index(
context.insert("trip_types", &triptypes); context.insert("trip_types", &triptypes);
} }
if user.has_role(db, "scheckbuch").await {
let last_trips = Logbook::completed_with_user(db, &user).await;
context.insert("last_trips", &last_trips);
}
let days = user.get_days(db).await; let days = user.get_days(db).await;
if let Some(msg) = flash { if let Some(msg) = flash {
@ -46,7 +41,6 @@ async fn index(
context.insert("fee", &user.fee(db).await); context.insert("fee", &user.fee(db).await);
context.insert("loggedin_user", &UserWithDetails::from_user(user, db).await); context.insert("loggedin_user", &UserWithDetails::from_user(user, db).await);
context.insert("days", &days); context.insert("days", &days);
context.insert("costs_scheckbuch", &SCHECKBUCH);
Template::render("planned", context.into_json()) Template::render("planned", context.into_json())
} }

View File

@ -1,12 +1,9 @@
{% import "includes/macros" as macros %} {% import "includes/macros" as macros %}
{% import "includes/forms/log" as log %}
{% extends "base" %} {% extends "base" %}
{% block content %} {% block content %}
<div class="max-w-screen-lg w-full"> <div class="max-w-screen-lg w-full">
<h1 class="h1"> <h1 class="h1">Ruder&shy;assistent</h1>
Ruder
<wbr />
assistent
</h1>
<div class="grid gap-3 my-5"> <div class="grid gap-3 my-5">
<div class="m-auto"> <div class="m-auto">
<a href="/planned" <a href="/planned"
@ -15,55 +12,57 @@
<span class="text-xl px-3">Geplante Ausfahrten</span> <span class="text-xl px-3">Geplante Ausfahrten</span>
</a> </a>
</div> </div>
<div id="notification" {% if notifications %}
class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5" <div id="notification"
role="alert"> class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"
<h2 class="h2">Nachrichten</h2> role="alert">
{% if loggedin_user.amount_unread_notifications > 10 %} <h2 class="h2">Nachrichten</h2>
<div class="text-primary-950 dark:text-white bg-gray-200 dark:bg-primary-950 bg-opacity-80 text-center pb-3 px-3"> {% if loggedin_user.amount_unread_notifications > 10 %}
Du hast viele ungelesene Benachrichtigungen. Um deine Oberfläche übersichtlich zu halten und wichtige Updates nicht zu verpassen, nimm dir bitte einen Moment Zeit sie zu überprüfen und als gelesen zu markieren (&#10003;). <div class="text-primary-950 dark:text-white bg-gray-200 dark:bg-primary-950 bg-opacity-80 text-center pb-3 px-3">
</div> Du hast viele ungelesene Benachrichtigungen. Um deine Oberfläche übersichtlich zu halten und wichtige Updates nicht zu verpassen, nimm dir bitte einen Moment Zeit sie zu überprüfen und als gelesen zu markieren (&#10003;).
{% endif %} </div>
<div class="divide-y"> {% endif %}
{% for notification in notifications %} <div class="divide-y">
{% if not notification.read_at %}
<div class="relative flex justify-between items-center p-3">
<div class="grow me-4">
<small class="uppercase text-gray-600 dark:text-gray-100">
<strong>{{ notification.category }}</strong> &bullet; {{ notification.created_at | date(format="%d.%m.%Y %H:%M",) }}
</small>
<div class="mt-1">{{ notification.message | safe }}</div>
</div>
<div>
{% if not notification.read_at %}
<a href="/notification/{{ notification.id }}/read" class="inline-block">
<button class="btn btn-primary" type="button">
&#10003;
<span class="sr-only">Notification gelesen</span>
</button>
</a>
{% endif %}
</div>
</div>
{% endif %}
{% endfor %}
</div>
<details class="py-3 border-t rounded-b-md">
<summary class="px-3 cursor-pointer">Vergangene Nachrichten (14 Tage)</summary>
<div class="divide-y text-sm">
{% for notification in notifications %} {% for notification in notifications %}
{% if notification.read_at %} {% if not notification.read_at %}
<div class="p-3 relative"> <div class="relative flex justify-between items-center p-3">
<small class="uppercase text-gray-600 dark:text-gray-100"> <div class="grow me-4">
<strong>{{ notification.category }}</strong> &bullet; {{ notification.created_at | date(format="%d.%m.%Y %H:%M") }} <small class="uppercase text-gray-600 dark:text-gray-100">
</small> <strong>{{ notification.category }}</strong> &bullet; {{ notification.created_at | date(format="%d.%m.%Y %H:%M",) }}
<div class="mt-1">{{ notification.message | safe }}</div> </small>
<div class="mt-1">{{ notification.message | safe }}</div>
</div>
<div>
{% if not notification.read_at %}
<a href="/notification/{{ notification.id }}/read" class="inline-block">
<button class="btn btn-primary" type="button">
&#10003;
<span class="sr-only">Notification gelesen</span>
</button>
</a>
{% endif %}
</div>
</div> </div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div> </div>
</details> <details class="py-3 border-t rounded-b-md">
</div> <summary class="px-3 cursor-pointer">Vergangene Nachrichten (14 Tage)</summary>
<div class="divide-y text-sm">
{% for notification in notifications %}
{% if notification.read_at %}
<div class="p-3 relative">
<small class="uppercase text-gray-600 dark:text-gray-100">
<strong>{{ notification.category }}</strong> &bullet; {{ notification.created_at | date(format="%d.%m.%Y %H:%M") }}
</small>
<div class="mt-1">{{ notification.message | safe }}</div>
</div>
{% endif %}
{% endfor %}
</div>
</details>
</div>
{% endif %}
{% if "Donau Linz" in loggedin_user.roles and "Unterstützend" not in loggedin_user.roles and "Förderndes Mitglied" not in loggedin_user.roles %} {% if "Donau Linz" in loggedin_user.roles and "Unterstützend" not in loggedin_user.roles and "Förderndes Mitglied" not in loggedin_user.roles %}
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5" <div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"
role="alert"> role="alert">
@ -98,14 +97,26 @@
</div> </div>
{% endif %} {% endif %}
{% if "scheckbuch" in loggedin_user.roles %} {% if "scheckbuch" in loggedin_user.roles %}
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5" <div class="grid gap-3 mb-4">
role="alert"> <div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"
<h2 class="h2">Scheckbuch</h2> role="alert">
<ul class="list-none ms-2 divide-y divide-gray-200 dark:divide-primary-600"> <h2 class="h2">Scheckbuch</h2>
<li class="py-1"> {% if "paid" not in loggedin_user.roles %}
<a href="/planned" class="block w-100 py-2 hover:text-primary-600">Geplante Ausfahrten</a> <div class="p-3 dark:text-white bg-white dark:bg-primary-900">
</li> Bitte nimm zur nächsten Ausfahrt die {{ costs_scheckbuch / 100 }}&nbsp;€ für das Scheckbuch mit. Falls du das bereits gemacht hast, gibt uns bitte kurz Bescheid, dass dies noch nicht eingetragen wurde.
</ul> </div>
{% endif %}
<div class="text-sm p-3 bg-gray-200 bg-opacity-80 dark:bg-primary-950 dark:text-white text-primary-950">
<h3>Du hast bisher an {{ last_trips | length }} deiner 5 Scheckbuch-Ausfahrten teilgenommen.</h3>
{% if last_trips %}
<ol class="mt-3">
{% for last_trip in last_trips %}
<li>{{ log::show_old(log=last_trip, state="completed", only_ones=false, index=loop.index) }}</li>
{% endfor %}
</ol>
{% endif %}
</div>
</div>
</div> </div>
{% endif %} {% endif %}
{% if "schnupper-betreuer" in loggedin_user.roles %} {% if "schnupper-betreuer" in loggedin_user.roles %}

View File

@ -3,27 +3,6 @@
{% extends "base" %} {% extends "base" %}
{% block content %} {% block content %}
<div class="max-w-screen-xl w-full grid sm:grid-cols-2 lg:grid-cols-3 gap-4"> <div class="max-w-screen-xl w-full grid sm:grid-cols-2 lg:grid-cols-3 gap-4">
{% if "scheckbuch" in loggedin_user.roles %}
<div class="grid gap-3 sm:col-span-2 lg:col-span-3">
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"
role="alert">
<h2 class="h2">Scheckbuch</h2>
{% if "paid" not in loggedin_user.roles %}
<div class="bg-gray-300 text-center text-black">
Bitte nimm zur nächsten Ausfahrt die {{ costs_scheckbuch / 100 }}&nbsp;€ für das Scheckbuch mit. Falls du das bereits gemacht hast, gibt uns bitte kurz Bescheid, dass dies noch nicht eingetragen wurde.
</div>
{% endif %}
<div class="text-sm p-3">
<h3>Du hast bisher {{ last_trips | length }} deiner 5 Scheckbuch-Ausfahrten gemacht:</h3>
<ol>
{% for last_trip in last_trips %}
<li>{{ log::show_old(log=last_trip, state="completed", only_ones=false, index=loop.index) }}</li>
{% endfor %}
</ol>
</div>
</div>
</div>
{% endif %}
{% if "paid" not in loggedin_user.roles and "Donau Linz" in loggedin_user.roles %} {% if "paid" not in loggedin_user.roles and "Donau Linz" in loggedin_user.roles %}
<div class="grid gap-3 sm:col-span-2 lg:col-span-3"> <div class="grid gap-3 sm:col-span-2 lg:col-span-3">
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5" <div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"