Compare commits

..

27 Commits

Author SHA1 Message Date
a27e9612e4 Merge pull request 'notification' (#292) from notification into main
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
Reviewed-on: #292
2024-03-21 20:48:20 +01:00
04b09983bc format with djlint
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
2024-03-21 20:47:48 +01:00
Marie Birner
7050d68293 [TASK] style notifications, add rowing icon and refactor menu
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
2024-03-21 20:42:49 +01:00
d1067988c6 update wording
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m24s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
2024-03-21 19:38:47 +01:00
257a682eb4 Merge branch 'main' into notification
All checks were successful
CI/CD Pipeline / test (push) Successful in 22m8s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
2024-03-21 00:27:11 +01:00
31348a6a93 Merge branch 'main' into notification
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
2024-03-21 00:18:18 +01:00
4624dfaf17 Merge branch 'main' into notification
Some checks failed
CI/CD Pipeline / test (push) Failing after 1m35s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
2024-03-20 23:52:37 +01:00
6a6afe5e60 Merge branch 'staging' into notification
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m13s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
2024-03-20 22:22:38 +01:00
63af74662f Merge branch 'main' into notification
Some checks are pending
CI/CD Pipeline / test (push) Waiting to run
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
2024-03-20 22:21:12 +01:00
c9270b2c54 Merge pull request 'only-show-input-when-possible' (#289) from only-show-input-when-possible into staging
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
Reviewed-on: #289
2024-03-20 22:13:48 +01:00
39306150bb Merge pull request 'only accept pdf' (#287) from fix-ci into staging
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m3s
CI/CD Pipeline / deploy-staging (push) Successful in 5m41s
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #287
2024-03-20 21:40:33 +01:00
638c13bc53 Merge pull request 'fix-ci' (#286) from fix-ci into staging
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
Reviewed-on: #286
2024-03-20 21:27:44 +01:00
9a1117a7c8 Merge pull request 'membership-pdf-new' (#284) from membership-pdf-new into staging
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
Reviewed-on: #284
2024-03-20 21:05:22 +01:00
9d14dae4a7 notification (#282)
All checks were successful
CI/CD Pipeline / test (push) Successful in 8m58s
CI/CD Pipeline / deploy-staging (push) Successful in 4m18s
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #282
2024-03-20 16:19:12 +01:00
6959f71f96 show additional notification
All checks were successful
CI/CD Pipeline / test (push) Successful in 8m48s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
2024-03-20 16:09:55 +01:00
be50e65846 add notifications; fixes #127
All checks were successful
CI/CD Pipeline / test (push) Successful in 8m48s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
2024-03-20 15:56:34 +01:00
2ebfe7564a Merge branch 'staging' into notification
All checks were successful
CI/CD Pipeline / test (push) Successful in 8m23s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
2024-03-20 14:00:25 +01:00
21265e20cb Merge branch 'notification' of ssh://git.hofer.link:2222/Ruderverein-Donau-Linz/rowt into notification
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m39s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
2024-03-09 17:22:39 +01:00
aef5748f5f add table 2024-03-09 17:21:15 +01:00
5af1860607 notifications 2024-03-09 17:20:38 +01:00
ec5a69f3e6 Merge branch 'notification' of ssh://git.hofer.link:2222/Ruderverein-Donau-Linz/rowt into notification
All checks were successful
CI/CD Pipeline / test (push) Successful in 15m26s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
2024-03-04 10:03:59 +01:00
09fffa1830 add table 2024-03-04 10:03:53 +01:00
28acee3085 notifications 2024-03-04 10:03:53 +01:00
f4cdd0ae28 add table
All checks were successful
CI/CD Pipeline / test (push) Successful in 15m15s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
2024-01-10 14:20:30 +01:00
fc8529c20b Merge branch 'notification' of ssh://git.hofer.link:2222/Ruderverein-Donau-Linz/rowt into notification
Some checks are pending
CI/CD Pipeline / test (push) Waiting to run
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
2024-01-10 14:14:13 +01:00
ab64583efc notifications 2024-01-10 14:14:06 +01:00
26ad0ba80a notifications 2023-11-17 10:30:30 +01:00
14 changed files with 584 additions and 342 deletions

View File

@ -151,3 +151,12 @@ CREATE TABLE IF NOT EXISTS "boathouse" (
CONSTRAINT unq UNIQUE (aisle, side, level) -- only 1 boat allowed to rest at each space CONSTRAINT unq UNIQUE (aisle, side, level) -- only 1 boat allowed to rest at each space
); );
CREATE TABLE IF NOT EXISTS "notification" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"user_id" INTEGER NOT NULL REFERENCES user(id),
"message" TEXT NOT NULL,
"read_at" DATETIME,
"created_at" DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
"category" TEXT NOT NULL,
"link" TEXT
);

View File

@ -61,3 +61,4 @@ INSERT INTO "logbook" (boat_id, shipmaster, steering_person, shipmaster_only_ste
INSERT INTO "rower" (logbook_id, rower_id) VALUES(3,3); INSERT INTO "rower" (logbook_id, rower_id) VALUES(3,3);
INSERT INTO "boat_damage" (boat_id, desc, user_id_created, created_at) VALUES(4,'Dolle bei Position 2 fehlt', 5, '2142-12-24 15:02'); INSERT INTO "boat_damage" (boat_id, desc, user_id_created, created_at) VALUES(4,'Dolle bei Position 2 fehlt', 5, '2142-12-24 15:02');
INSERT INTO "boat_damage" (boat_id, desc, user_id_created, created_at, lock_boat) VALUES(5, 'TOHT', 5, '2142-12-24 15:02', 1); INSERT INTO "boat_damage" (boat_id, desc, user_id_created, created_at, lock_boat) VALUES(5, 'TOHT', 5, '2142-12-24 15:02', 1);
INSERT INTO "notification" (user_id, message, category) VALUES (1, 'This is a test notification', 'test-cat');

View File

@ -5,7 +5,7 @@ use rocket::FromForm;
use serde::Serialize; use serde::Serialize;
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction}; use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
use super::{boat::Boat, log::Log, rower::Rower, user::User}; use super::{boat::Boat, log::Log, notification::Notification, rower::Rower, user::User};
#[derive(FromRow, Serialize, Clone, Debug)] #[derive(FromRow, Serialize, Clone, Debug)]
pub struct Logbook { pub struct Logbook {
@ -525,6 +525,23 @@ ORDER BY departure DESC
Rower::create(db, self.id, *rower) Rower::create(db, self.id, *rower)
.await .await
.map_err(|e| LogbookUpdateError::RowerCreateError(*rower, e.to_string()))?; .map_err(|e| LogbookUpdateError::RowerCreateError(*rower, e.to_string()))?;
let user = User::find_by_id_tx(db, *rower as i32).await.unwrap();
Notification::create_with_tx(
db,
&user,
&format!(
"Ausfahrt am {}.{}.{} nach {} ({} km)",
dep.day(),
dep.month(),
dep.year(),
log.destination,
log.distance_in_km
),
"Neuer Logbucheintrag",
None,
)
.await;
} }
sqlx::query!( sqlx::query!(

View File

@ -16,6 +16,7 @@ pub mod log;
pub mod logbook; pub mod logbook;
pub mod logtype; pub mod logtype;
pub mod mail; pub mod mail;
pub mod notification;
pub mod planned_event; pub mod planned_event;
pub mod role; pub mod role;
pub mod rower; pub mod rower;

View File

@ -1,36 +1,78 @@
use chrono::{DateTime, Local, NaiveDateTime, TimeZone}; use std::ops::DerefMut;
use chrono::NaiveDateTime;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sqlx::{FromRow, SqlitePool}; use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
use super::user::User;
#[derive(FromRow, Debug, Serialize, Deserialize)] #[derive(FromRow, Debug, Serialize, Deserialize)]
pub struct Notification { pub struct Notification {
pub id: i64, pub id: i64,
pub user_id: i64, pub user_id: i64,
pub message: String, pub message: String,
pub read_at: NaiveDateTime, pub read_at: Option<NaiveDateTime>,
pub created_at: NaiveDateTime,
pub category: String, pub category: String,
pub link: Option<String>,
} }
impl Notification { impl Notification {
//pub async fn create(db: &SqlitePool, msg: String) -> bool { pub async fn find_by_id(db: &SqlitePool, id: i64) -> Option<Self> {
// sqlx::query!("INSERT INTO log(msg) VALUES (?)", msg,) sqlx::query_as!(Self, "SELECT * FROM notification WHERE id like ?", id)
// .execute(db) .fetch_one(db)
// .await .await
// .is_ok() .ok()
//} }
pub async fn create_with_tx(
db: &mut Transaction<'_, Sqlite>,
user: &User,
message: &str,
category: &str,
link: Option<&str>,
) {
sqlx::query!(
"INSERT INTO notification(user_id, message, category, link) VALUES (?, ?, ?, ?)",
user.id,
message,
category,
link
)
.execute(db.deref_mut())
.await
.unwrap();
}
async fn for_user(db: &SqlitePool, user: &User) -> Vec<Self> { pub async fn create(
db: &SqlitePool,
user: &User,
message: &str,
category: &str,
link: Option<&str>,
) {
let mut tx = db.begin().await.unwrap();
Self::create_with_tx(&mut tx, user, message, category, link).await;
tx.commit().await.unwrap();
}
pub async fn for_user(db: &SqlitePool, user: &User) -> Vec<Self> {
sqlx::query_as!( sqlx::query_as!(
Log, Self,
" "SELECT * FROM notification WHERE user_id = ?",
SELECT id, user_id, message, read_at, category
FROM notification
WHERE user_id = {}
",
user.id user.id
) )
.fetch_all(db) .fetch_all(db)
.await .await
.unwrap() .unwrap()
} }
pub async fn mark_read(self, db: &SqlitePool) {
sqlx::query!(
"UPDATE notification SET read_at=CURRENT_TIMESTAMP WHERE id=?",
self.id
)
.execute(db)
.await
.unwrap();
}
} }

View File

@ -3,21 +3,22 @@ use serde::Serialize;
use sqlx::SqlitePool; use sqlx::SqlitePool;
use super::{ use super::{
notification::Notification,
planned_event::{PlannedEvent, Registration}, planned_event::{PlannedEvent, Registration},
tripdetails::TripDetails, tripdetails::TripDetails,
triptype::TripType, triptype::TripType,
user::CoxUser, user::{CoxUser, User},
}; };
#[derive(Serialize, Clone, Debug)] #[derive(Serialize, Clone, Debug)]
pub struct Trip { pub struct Trip {
id: i64, id: i64,
cox_id: i64, pub cox_id: i64,
cox_name: String, cox_name: String,
trip_details_id: Option<i64>, trip_details_id: Option<i64>,
planned_starting_time: String, planned_starting_time: String,
pub max_people: i64, pub max_people: i64,
day: String, pub day: String,
pub notes: Option<String>, pub notes: Option<String>,
pub allow_guests: bool, pub allow_guests: bool,
trip_type_id: Option<i64>, trip_type_id: Option<i64>,
@ -43,6 +44,51 @@ impl Trip {
) )
.execute(db) .execute(db)
.await; .await;
let same_starting_datetime = TripDetails::find_by_startingdatetime(
db,
trip_details.day,
trip_details.planned_starting_time,
)
.await;
if same_starting_datetime.len() > 1 {
for notify in same_starting_datetime {
if notify.id != trip_details.id {
// notify everyone except oneself
if let Some(trip) = Trip::find_by_trip_details(db, notify.id).await {
let user = User::find_by_id(db, trip.cox_id as i32).await.unwrap();
Notification::create(
db,
&user,
&format!(
"{} hat eine Ausfahrt zur selben Zeit ({} um {}) wie du erstellt",
user.name, trip.day, trip.planned_starting_time
),
"Neue Ausfahrt zur selben Zeit".into(),
None,
)
.await;
}
}
}
}
}
pub async fn find_by_trip_details(db: &SqlitePool, tripdetails_id: i64) -> Option<Self> {
sqlx::query_as!(
Self,
"
SELECT trip.id, cox_id, user.name as cox_name, trip_details_id, planned_starting_time, max_people, day, trip_details.notes, allow_guests, trip_type_id, always_show, is_locked
FROM trip
INNER JOIN trip_details ON trip.trip_details_id = trip_details.id
INNER JOIN user ON trip.cox_id = user.id
WHERE trip_details.id=?
",
tripdetails_id
)
.fetch_one(db)
.await
.ok()
} }
pub async fn find_by_id(db: &SqlitePool, id: i64) -> Option<Self> { pub async fn find_by_id(db: &SqlitePool, id: i64) -> Option<Self> {

View File

@ -46,6 +46,24 @@ WHERE id like ?
.ok() .ok()
} }
pub async fn find_by_startingdatetime(
db: &SqlitePool,
day: String,
planned_starting_time: String,
) -> Vec<Self> {
sqlx::query_as!(
Self,
"
SELECT id, planned_starting_time, max_people, day, notes, allow_guests, trip_type_id, always_show, is_locked
FROM trip_details
WHERE day = ? AND planned_starting_time = ?
"
, day, planned_starting_time
)
.fetch_all(db)
.await.unwrap()
}
/// Creates a new entry in `trip_details` and returns its id. /// Creates a new entry in `trip_details` and returns its id.
pub async fn create(db: &SqlitePool, tripdetails: TripDetailsToAdd<'_>) -> i64 { pub async fn create(db: &SqlitePool, tripdetails: TripDetailsToAdd<'_>) -> i64 {
let query = sqlx::query!( let query = sqlx::query!(

View File

@ -1,6 +1,6 @@
use sqlx::SqlitePool; use sqlx::SqlitePool;
use super::{tripdetails::TripDetails, user::User}; use super::{notification::Notification, trip::Trip, tripdetails::TripDetails, user::User};
use crate::model::tripdetails::{Action, CoxAtTrip::Yes}; use crate::model::tripdetails::{Action, CoxAtTrip::Yes};
pub struct UserTrip {} pub struct UserTrip {}
@ -27,6 +27,7 @@ impl UserTrip {
//TODO: Check if user sees the event (otherwise she could forge trip_details_id) //TODO: Check if user sees the event (otherwise she could forge trip_details_id)
let is_cox = trip_details.user_is_cox(db, user).await; let is_cox = trip_details.user_is_cox(db, user).await;
let mut name_newly_registered_person = String::new();
if user_note.is_none() { if user_note.is_none() {
if let Yes(action) = is_cox { if let Yes(action) = is_cox {
match action { match action {
@ -47,6 +48,8 @@ impl UserTrip {
.execute(db) .execute(db)
.await .await
.unwrap(); .unwrap();
name_newly_registered_person = user.name.clone();
} else { } else {
if !trip_details.user_allowed_to_change(db, user).await { if !trip_details.user_allowed_to_change(db, user).await {
return Err(UserTripError::NotAllowedToAddGuest); return Err(UserTripError::NotAllowedToAddGuest);
@ -59,6 +62,23 @@ impl UserTrip {
.execute(db) .execute(db)
.await .await
.unwrap(); .unwrap();
name_newly_registered_person = user_note.unwrap();
}
if let Some(trip) = Trip::find_by_trip_details(db, trip_details.id).await {
let cox = User::find_by_id(db, trip.cox_id as i32).await.unwrap();
Notification::create(
db,
&cox,
&format!(
"{} hat sich für deine Ausfahrt am {} registriert",
name_newly_registered_person, trip.day
),
"Registrierung bei deiner Ausfahrt",
None,
)
.await;
} }
Ok(()) Ok(())

View File

@ -17,7 +17,10 @@ use serde::Deserialize;
use sqlx::SqlitePool; use sqlx::SqlitePool;
use tera::Context; use tera::Context;
use crate::model::user::{User, UserWithRoles}; use crate::model::{
notification::Notification,
user::{User, UserWithRoles},
};
pub(crate) mod admin; pub(crate) mod admin;
mod auth; mod auth;
@ -27,6 +30,7 @@ mod cox;
mod ergo; mod ergo;
mod log; mod log;
mod misc; mod misc;
mod notification;
mod planned; mod planned;
mod stat; mod stat;
@ -43,6 +47,7 @@ async fn index(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_
context.insert("flash", &msg.into_inner()); context.insert("flash", &msg.into_inner());
} }
context.insert("notifications", &Notification::for_user(db, &user).await);
context.insert("loggedin_user", &UserWithRoles::from_user(user, db).await); context.insert("loggedin_user", &UserWithRoles::from_user(user, db).await);
Template::render("index", context.into_json()) Template::render("index", context.into_json())
} }
@ -86,6 +91,7 @@ pub fn config(rocket: Rocket<Build>) -> Rocket<Build> {
.mount("/log", log::routes()) .mount("/log", log::routes())
.mount("/planned", planned::routes()) .mount("/planned", planned::routes())
.mount("/ergo", ergo::routes()) .mount("/ergo", ergo::routes())
.mount("/notification", notification::routes())
.mount("/stat", stat::routes()) .mount("/stat", stat::routes())
.mount("/boatdamage", boatdamage::routes()) .mount("/boatdamage", boatdamage::routes())
.mount("/cox", cox::routes()) .mount("/cox", cox::routes())

32
src/tera/notification.rs Normal file
View File

@ -0,0 +1,32 @@
use rocket::{
get,
response::{Flash, Redirect},
routes, Route, State,
};
use sqlx::SqlitePool;
use crate::model::{notification::Notification, user::User};
#[get("/<notification_id>/read")]
async fn mark_read(db: &State<SqlitePool>, user: User, notification_id: i64) -> Flash<Redirect> {
let Some(notification) = Notification::find_by_id(db, notification_id).await else {
return Flash::error(
Redirect::to("/"),
format!("Nachricht mit ID {notification_id} nicht gefunden."),
);
};
if notification.user_id == user.id {
notification.mark_read(db).await;
Flash::success(Redirect::to("/"), "Nachricht als gelesen markiert")
} else {
Flash::success(
Redirect::to("/"),
"Du kannst fremde Nachrichten nicht als gelesen markieren.",
)
}
}
pub fn routes() -> Vec<Route> {
routes![mark_read]
}

View File

@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS "notification" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"user_id" INTEGER NOT NULL REFERENCES user(id),
"message" TEXT NOT NULL,
"read_at" DATETIME,
"created_at" DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
"category" TEXT NOT NULL,
"link" TEXT
);

View File

@ -16,22 +16,12 @@
<header class="bg-primary-900 text-white flex justify-center p-3 fixed w-full z-10"> <header class="bg-primary-900 text-white flex justify-center p-3 fixed w-full z-10">
<div class="max-w-screen-xl w-full flex justify-between items-center"> <div class="max-w-screen-xl w-full flex justify-between items-center">
<div class="w-1/3 truncate"> <div class="w-1/3 truncate">
{% if "Donau Linz" in loggedin_user.roles %}
<a href="/planned">
{% else %}
<a href="/"> <a href="/">
{% endif %}
{{ loggedin_user.name }} {{ loggedin_user.name }}
</a> </a>
</div> </div>
<div> <div>
<a href="https://wiki.rudernlinz.at/ruderassistent#faq"
target="_blank"
class="inline-flex justify-center rounded-md bg-primary-600 mx-1 px-3 py-2 text-sm font-semibold text-white hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer">
{% include "includes/question-icon" %}
<span class="sr-only">FAQs</span>
</a>
{% if "scheckbuch" in loggedin_user.roles and loggedin_user.weight and loggedin_user.sex and loggedin_user.dob %} {% if "scheckbuch" in loggedin_user.roles and loggedin_user.weight and loggedin_user.sex and loggedin_user.dob %}
<a href="#" <a href="#"
class="inline-flex justify-center rounded-md bg-primary-600 mx-1 px-3 py-2 text-sm font-semibold text-white hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer" class="inline-flex justify-center rounded-md bg-primary-600 mx-1 px-3 py-2 text-sm font-semibold text-white hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer"
@ -63,6 +53,10 @@
<a href="/log" class="block w-100 py-2 hover:text-primary-600">Ausfahrt eintragen</a> <a href="/log" class="block w-100 py-2 hover:text-primary-600">Ausfahrt eintragen</a>
<a href="/log/show" <a href="/log/show"
class="block w-100 py-2 hover:text-primary-600 border-t">Logbuch</a> class="block w-100 py-2 hover:text-primary-600 border-t">Logbuch</a>
{% if "admin" in loggedin_user.roles or "Vorstand" in loggedin_user.roles %}
<a href="/admin/user"
class="block w-100 py-2 hover:text-primary-600 border-t">Userverwaltung</a>
{% endif %}
{% if loggedin_user.weight and loggedin_user.sex and loggedin_user.dob %} {% if loggedin_user.weight and loggedin_user.sex and loggedin_user.dob %}
<a href="/ergo" class="block w-100 py-2 hover:text-primary-600 border-t">Ergo</a> <a href="/ergo" class="block w-100 py-2 hover:text-primary-600 border-t">Ergo</a>
{% endif %} {% endif %}
@ -78,20 +72,6 @@
</div> </div>
</div> </div>
{% endif %} {% endif %}
{% if "admin" in loggedin_user.roles or "Vorstand" in loggedin_user.roles %}
<a href="/admin/user"
class="inline-flex justify-center rounded-md bg-primary-600 mx-1 px-3 py-2 text-sm font-semibold text-white hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer">
<svg class="inline h-4"
width="16"
height="16"
fill="currentColor"
class="bi bi-person-lines-fill"
viewbox="0 0 16 16">
<path d="M6 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-5 6s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H1zM11 3.5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 0 1h-4a.5.5 0 0 1-.5-.5zm.5 2.5a.5.5 0 0 0 0 1h4a.5.5 0 0 0 0-1h-4zm2 3a.5.5 0 0 0 0 1h2a.5.5 0 0 0 0-1h-2zm0 3a.5.5 0 0 0 0 1h2a.5.5 0 0 0 0-1h-2z" />
</svg>
<span class="sr-only">Userverwaltung</span>
</a>
{% endif %}
<a href="/auth/logout" <a href="/auth/logout"
class="inline-flex justify-center rounded-md bg-gray-200 ml-1 px-3 py-2 text-sm font-semibold text-primary-950 hover:bg-gray-300 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer"> class="inline-flex justify-center rounded-md bg-gray-200 ml-1 px-3 py-2 text-sm font-semibold text-primary-950 hover:bg-gray-300 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer">
<svg class="inline h-4" <svg class="inline h-4"
@ -114,8 +94,8 @@
</div> </div>
</header> </header>
<div class="h-8"></div> <div class="h-8"></div>
{% endmacro header %} {% endmacro header %}
{% macro input(label, name, type, required=false, class='rounded-md', value='', min='', hide_label=false, id='', autofocus=false, wrapper_class='', pattern='', readonly=false, accept='') %} {% macro input(label, name, type, required=false, class='rounded-md', value='', min='', hide_label=false, id='', autofocus=false, wrapper_class='', pattern='', readonly=false, accept='') %}
<div class="{{ wrapper_class }}"> <div class="{{ wrapper_class }}">
<label for="{{ name }}" <label for="{{ name }}"
class="{% if hide_label %} sr-only {% else %} text-sm text-gray-600 dark:text-white {% endif %}"> class="{% if hide_label %} sr-only {% else %} text-sm text-gray-600 dark:text-white {% endif %}">
@ -135,8 +115,8 @@
{% if pattern %}pattern="{{ pattern }}"{% endif %} {% if pattern %}pattern="{{ pattern }}"{% endif %}
{% if readonly %}readonly{% endif %}> {% if readonly %}readonly{% endif %}>
</div> </div>
{% endmacro input %} {% endmacro input %}
{% macro checkbox(label, name, id='', checked=false, class='', disabled=false) %} {% macro checkbox(label, name, id='', checked=false, class='', disabled=false) %}
<label for="{{ name }}{{ id }}" <label for="{{ name }}{{ id }}"
class="flex items-center cursor-pointer text-black dark:text-white hover:text-gray-900 dark:hover:text-gray-100 {{ class }}"> class="flex items-center cursor-pointer text-black dark:text-white hover:text-gray-900 dark:hover:text-gray-100 {{ class }}">
<input type="checkbox" <input type="checkbox"
@ -147,8 +127,8 @@
class="h-4 w-4 accent-primary-600 dark:accent-primary-200 mr-2" /> class="h-4 w-4 accent-primary-600 dark:accent-primary-200 mr-2" />
{{ label }} {{ label }}
</label> </label>
{% endmacro checkbox %} {% endmacro checkbox %}
{% macro select(label, data, name='trip_type', default='', id='', selected_id='', display='', extras='', class='', wrapper_class='', required=false, show_seats=false, new_last_entry='') %} {% macro select(label, data, name='trip_type', default='', id='', selected_id='', display='', extras='', class='', wrapper_class='', required=false, show_seats=false, new_last_entry='') %}
<div class="{{ wrapper_class }}"> <div class="{{ wrapper_class }}">
<label for="{{ name }}" class="text-sm text-gray-600 dark:text-gray-100">{{ label }}</label> <label for="{{ name }}" class="text-sm text-gray-600 dark:text-gray-100">{{ label }}</label>
{% if display == '' %} {% if display == '' %}
@ -173,11 +153,11 @@
{% if new_last_entry %}<option value="-1">{{ new_last_entry }}</option>{% endif %} {% if new_last_entry %}<option value="-1">{{ new_last_entry }}</option>{% endif %}
</select> </select>
</div> </div>
{% endmacro select %} {% endmacro select %}
{% macro alert(message, type, class='') %} {% macro alert(message, type, class='') %}
<div class="{{ class }} alert-{{ type }} text-white px-3 py-1 rounded-md text-center">{{ message }}</div> <div class="{{ class }} alert-{{ type }} text-white px-3 py-1 rounded-md text-center">{{ message }}</div>
{% endmacro alert %} {% endmacro alert %}
{% macro box(participants, empty_seats='', header='Freie Plätze:', text='Keine Ruderer angemeldet', bg='primary-600', color='white', trip_details_id='', allow_removing=false) %} {% macro box(participants, empty_seats='', header='Freie Plätze:', text='Keine Ruderer angemeldet', bg='primary-600', color='white', trip_details_id='', allow_removing=false) %}
<div class="text-{{ color }} bg-{{ bg }} text-center p-1 mt-1 rounded-t-md"> <div class="text-{{ color }} bg-{{ bg }} text-center p-1 mt-1 rounded-t-md">
{{ header }} {{ header }}
{{ empty_seats }} {{ empty_seats }}
@ -202,10 +182,10 @@
{{ text }} {{ text }}
{% endif %} {% endif %}
</div> </div>
{% endmacro box %} {% endmacro box %}
{% macro faq(question, answer) %} {% macro faq(question, answer) %}
<div> <div>
<h2 class="flex mb-4 text-lg font-bold text-primary-900">{{ question }}</h2> <h2 class="flex mb-4 text-lg font-bold text-primary-900">{{ question }}</h2>
<p class="text-primary-950">{{ answer | safe }}</p> <p class="text-primary-950">{{ answer | safe }}</p>
</div> </div>
{% endmacro faq %} {% endmacro faq %}

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%"
class="flex-shrink-0 w-6 h-6 inline-block"
height="100%"
viewBox="0 0 583 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xml:space="preserve"
xmlns:serif="http://www.serif.com/"
style="fill-rule:evenodd;
clip-rule:evenodd;
stroke-linejoin:round;
stroke-miterlimit:2">
<g transform="matrix(1,0,0,1,-1574,-536.199)">
<g transform="matrix(1,0,0,1,0,10.8235)">
<g transform="matrix(0.948324,0.317305,0.307947,-0.920356,-304.665,1886.18)">
<rect x="1838.29" y="1006.52" width="17.353" height="644.204" style="fill:white;fill-opacity:0.7;" />
</g>
<path d="M1944.68,934.772C1921.09,896.523 1932.18,782.181 1974.56,655.531C1990.23,608.676 2009.04,563.787 2029.1,525.376L2156.88,568.132C2149.78,610.876 2137.79,658.046 2122.11,704.901C2079.26,832.966 2018.43,931.728 1976.52,946.409L2085.08,568.504L1944.68,934.772Z" style="fill:white;fill-opacity:0.7;" />
</g>
<g transform="matrix(-1,0,0,1,3730.88,10.8235)">
<g transform="matrix(0.948324,0.317305,0.307947,-0.920356,-304.665,1886.18)">
<rect x="1838.29" y="1006.52" width="17.353" height="644.204" style="fill:white;fill-opacity:0.7;" />
</g>
<path d="M1944.68,934.772C1921.09,896.523 1932.18,782.181 1974.56,655.531C1990.23,608.676 2009.04,563.787 2029.1,525.376L2156.88,568.132C2149.78,610.876 2137.79,658.046 2122.11,704.901C2079.26,832.966 2018.43,931.728 1976.52,946.409L2085.08,568.504L1944.68,934.772Z" style="fill:white;fill-opacity:0.7;" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -3,146 +3,177 @@
{% block content %} {% block content %}
<div class="max-w-screen-lg w-full"> <div class="max-w-screen-lg w-full">
<h1 class="h1">Ruderassistent</h1> <h1 class="h1">Ruderassistent</h1>
<div class="grid gap-3"> <div class="grid gap-3 my-5">
<div class="m-auto">
<a href="/planned"
class="btn btn-primary flex items-center justify-center">
{% include "includes/rowing-icon" %}
<span class="text-xl px-3">Geplante Ausfahrten</span>
</a>
</div>
<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">
<h2 class="h2">Allgemein</h2> <h2 class="h2">Nachrichten</h2>
<div class="text-sm p-3"> <div class="divide-y">
<ul class="list-disc ms-2"> {% for notification in notifications %}
<li class="py-1"> {% if not notification.read_at %}
<a href="https://wiki.rudernlinz.at/ruderassistent#faq" <div class="relative flex justify-between items-center p-3">
target="_blank" <div class="grow me-4">
class="link-primary">FAQ (extern)</a> <small class="uppercase text-gray-600 dark:text-gray-100">
</li> <strong>{{ notification.category }}</strong> &bullet; {{ notification.created_at | date(format="%d.%m.%Y %H:%M") }}
</ul> </small>
<div class="mt-1">{{ notification.message }}</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> </div>
{% endif %}
{% endfor %}
</div>
<details class="py-3 bg-gray-200 dark:bg-primary-950 rounded-b-md">
<summary class="px-3">Vergangene Nachrichten</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 }}</div>
</div>
{% endif %}
{% endfor %}
</div>
</details>
</div> </div>
{% if loggedin_user.weight and loggedin_user.sex and loggedin_user.dob %} {% if loggedin_user.weight and loggedin_user.sex and loggedin_user.dob %}
<div class="grid gap-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"
role="alert"> role="alert">
<h2 class="h2">Ergo</h2> <h2 class="h2">Ergo</h2>
<div class="text-sm p-3"> <div class="p-3">
<ul class="list-disc ms-2"> <ul class="list-none ms-2">
<li class="py-1"> <li class="py-1">
<a href="/ergo" class="link-primary">Ergo</a> <a href="/ergo" class="block w-100 py-2 hover:text-primary-600">Ergo</a>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
</div>
{% endif %} {% 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="grid gap-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"
role="alert"> role="alert">
<h2 class="h2">Aktives Vereinsmitglied</h2> <h2 class="h2">Aktives Vereinsmitglied</h2>
<div class="text-sm p-3"> <ul class="list-none ms-2 divide-y divide-gray-200 dark:divide-primary-600">
<ul class="list-disc ms-2">
<li class="py-1"> <li class="py-1">
<a href="/planned" class="link-primary">Geplante Ausfahrten</a> <a href="/planned" class="block w-100 py-2 hover:text-primary-600">Geplante Ausfahrten</a>
</li> </li>
<li class="py-1"> <li class="py-1">
<a href="/log" class="link-primary">Ausfahrt eintragen</a> <a href="/log" class="block w-100 py-2 hover:text-primary-600">Ausfahrt eintragen</a>
</li> </li>
<li class="py-1"> <li class="py-1">
<a href="/log/show" class="link-primary">Logbuch</a> <a href="/log/show" class="block w-100 py-2 hover:text-primary-600">Logbuch</a>
</li> </li>
<li class="py-1"> <li class="py-1">
<a href="/stat" class="link-primary">Statistik</a> <a href="/stat" class="block w-100 py-2 hover:text-primary-600">Statistik</a>
</li> </li>
<li class="py-1"> <li class="py-1">
<a href="/stat/boats" class="link-primary">Bootsauswertung</a> <a href="/stat/boats" class="block w-100 py-2 hover:text-primary-600">Bootsauswertung</a>
</li> </li>
<li class="py-1"> <li class="py-1">
<a href="/boatdamage" class="link-primary">Bootsschaden</a> <a href="/boatdamage" class="block w-100 py-2 hover:text-primary-600">Bootsschaden</a>
</li> </li>
</ul> </ul>
</div> </div>
</div>
</div>
{% endif %} {% endif %}
{% if "scheckbuch" in loggedin_user.roles %} {% if "scheckbuch" in loggedin_user.roles %}
<div class="grid gap-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"
role="alert"> role="alert">
<h2 class="h2">Scheckbuch</h2> <h2 class="h2">Scheckbuch</h2>
<div class="text-sm p-3"> <ul class="list-none ms-2 divide-y divide-gray-200 dark:divide-primary-600">
<ul class="list-disc ms-2">
<li class="py-1"> <li class="py-1">
<a href="/planned" class="link-primary">Geplante Ausfahrten</a> <a href="/planned" class="block w-100 py-2 hover:text-primary-600">Geplante Ausfahrten</a>
</li> </li>
</ul> </ul>
</div> </div>
</div>
</div>
{% endif %} {% endif %}
{% if "schnupper-betreuer" in loggedin_user.roles %} {% if "schnupper-betreuer" in loggedin_user.roles %}
<div class="grid gap-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"
role="alert"> role="alert">
<h2 class="h2">Schnupper-Betreuer</h2> <h2 class="h2">Schnupper-Betreuer</h2>
<div class="text-sm p-3"> <ul class="list-none ms-2 divide-y divide-gray-200 dark:divide-primary-600">
<ul class="list-disc ms-2">
<li class="py-1"> <li class="py-1">
<a href="/admin/schnupper" class="link-primary">Schnuppern</a> <a href="/admin/schnupper"
class="block w-100 py-2 hover:text-primary-600">Schnuppern</a>
</li> </li>
</ul> </ul>
</div> </div>
</div>
</div>
{% endif %} {% endif %}
{% if "Vorstand" in loggedin_user.roles %} {% if "Vorstand" in loggedin_user.roles %}
<div class="grid gap-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"
role="alert"> role="alert">
<h2 class="h2">Vorstand</h2> <h2 class="h2">Vorstand</h2>
<div class="text-sm p-3"> <ul class="list-none ms-2 divide-y divide-gray-200 dark:divide-primary-600">
<ul class="list-disc ms-2">
<li class="py-1"> <li class="py-1">
<a href="/admin/user/fees" class="link-primary">Übersicht User Gebühren</a> <a href="/admin/user/fees"
class="block w-100 py-2 hover:text-primary-600">Übersicht User Gebühren</a>
</li> </li>
<li class="py-1"> <li class="py-1">
<a href="/admin/user/scheckbuch" class="link-primary">Scheckbuch</a> <a href="/admin/user/scheckbuch"
class="block w-100 py-2 hover:text-primary-600">Scheckbuch</a>
</li> </li>
<li class="py-1"> <li class="py-1">
<a href="/admin/user" class="link-primary">User</a> <a href="/admin/user" class="block w-100 py-2 hover:text-primary-600">User</a>
</li> </li>
<li class="py-1"> <li class="py-1">
<a href="/board/boathouse" class="link-primary">Bootshaus</a> <a href="/board/boathouse"
class="block w-100 py-2 hover:text-primary-600">Bootshaus</a>
</li> </li>
</ul> </ul>
</div> </div>
</div>
</div>
{% endif %} {% endif %}
{% if "admin" in loggedin_user.roles %} {% if "admin" in loggedin_user.roles %}
<div class="grid gap-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"
role="alert"> role="alert">
<h2 class="h2">Admin</h2> <h2 class="h2">Admin</h2>
<div class="text-sm p-3"> <ul class="list-none ms-2 divide-y divide-gray-200 dark:divide-primary-600">
<ul class="list-disc ms-2">
<li class="py-1"> <li class="py-1">
<a href="/admin/boat" class="link-primary">Boote</a> <a href="/admin/boat" class="block w-100 py-2 hover:text-primary-600">Boote</a>
</li> </li>
<li class="py-1"> <li class="py-1">
<a href="/admin/user" class="link-primary">User</a> <a href="/admin/user" class="block w-100 py-2 hover:text-primary-600">User</a>
</li> </li>
<li class="py-1"> <li class="py-1">
<a href="/admin/mail" class="link-primary">Mail (beautifully layouted)</a> <a href="/admin/mail" class="block w-100 py-2 hover:text-primary-600">Mail (beautifully layouted)</a>
</li> </li>
<li class="py-1"> <li class="py-1">
<a href="/admin/rss" class="link-primary">Logs</a> <a href="/admin/rss" class="block w-100 py-2 hover:text-primary-600">Logs</a>
</li> </li>
<li class="py-1"> <li class="py-1">
<a href="/admin/list" class="link-primary">Fingerabdruck-Liste überprüfen</a> <a href="/admin/list" class="block w-100 py-2 hover:text-primary-600">Fingerabdruck-Liste überprüfen</a>
</li>
</ul>
</div>
{% endif %}
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"
role="alert">
<h2 class="h2">Allgemein</h2>
<div class="p-3">
<ul class="list-none ms-2">
<li class="py-1">
<a href="https://wiki.rudernlinz.at/ruderassistent#faq"
target="_blank"
class="block w-100 py-2 hover:text-primary-600">FAQ (extern)</a>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>
{% endif %} {% endblock content %}
</div>
{% endblock content %}