Compare commits
No commits in common. "a68c423fdb8f8db189be8050599c89073105aee9" and "01fdfcae99a4412e59d145f7c284b022370ea878" have entirely different histories.
a68c423fdb
...
01fdfcae99
@ -119,7 +119,7 @@ impl Boat {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.allowed_to_steer(db).await
|
user.has_role(db, "cox").await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn shipmaster_allowed_tx(
|
pub async fn shipmaster_allowed_tx(
|
||||||
@ -135,7 +135,7 @@ impl Boat {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.allowed_to_steer_tx(db).await
|
user.has_role_tx(db, "cox").await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn is_locked(&self, db: &SqlitePool) -> bool {
|
pub async fn is_locked(&self, db: &SqlitePool) -> bool {
|
||||||
@ -260,7 +260,7 @@ ORDER BY
|
|||||||
if user.has_role(db, "admin").await {
|
if user.has_role(db, "admin").await {
|
||||||
return Self::all(db).await;
|
return Self::all(db).await;
|
||||||
}
|
}
|
||||||
let mut boats = if user.allowed_to_steer(db).await {
|
let mut boats = if user.has_role(db, "cox").await {
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
Boat,
|
Boat,
|
||||||
"
|
"
|
||||||
|
@ -136,7 +136,8 @@ ORDER BY created_at DESC
|
|||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
if !was_unusable_before && boat.is_locked(db).await {
|
if !was_unusable_before && boat.is_locked(db).await {
|
||||||
Notification::create_for_steering_people(db, &format!("Liebe Steuerberechtigte, bitte beachten, dass {} bis auf weiteres aufgrund von Reparaturarbeiten gesperrt ist.", boat.name), "Boot gesperrt", None, None).await;
|
let cox = Role::find_by_name(db, "cox").await.unwrap();
|
||||||
|
Notification::create_for_role(db, &cox, &format!("Liebe Steuerberechtigte, bitte beachten, dass {} bis auf weiteres aufgrund von Reparaturarbeiten gesperrt ist.", boat.name), "Boot gesperrt", None, None).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
let technicals =
|
let technicals =
|
||||||
|
@ -89,32 +89,6 @@ impl Notification {
|
|||||||
tx.commit().await.unwrap();
|
tx.commit().await.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_for_steering_people_tx(
|
|
||||||
db: &mut Transaction<'_, Sqlite>,
|
|
||||||
message: &str,
|
|
||||||
category: &str,
|
|
||||||
link: Option<&str>,
|
|
||||||
action_after_reading: Option<&str>,
|
|
||||||
) {
|
|
||||||
let cox = Role::find_by_name_tx(db, "cox").await.unwrap();
|
|
||||||
Self::create_for_role_tx(db, &cox, message, category, link, action_after_reading).await;
|
|
||||||
let bootsf = Role::find_by_name_tx(db, "Bootsführer").await.unwrap();
|
|
||||||
Self::create_for_role_tx(db, &bootsf, message, category, link, action_after_reading).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn create_for_steering_people(
|
|
||||||
db: &SqlitePool,
|
|
||||||
message: &str,
|
|
||||||
category: &str,
|
|
||||||
link: Option<&str>,
|
|
||||||
action_after_reading: Option<&str>,
|
|
||||||
) {
|
|
||||||
let cox = Role::find_by_name(db, "cox").await.unwrap();
|
|
||||||
Self::create_for_role(db, &cox, message, category, link, action_after_reading).await;
|
|
||||||
let bootsf = Role::find_by_name(db, "Bootsführer").await.unwrap();
|
|
||||||
Self::create_for_role(db, &bootsf, message, category, link, action_after_reading).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn for_user(db: &SqlitePool, user: &User) -> Vec<Self> {
|
pub async fn for_user(db: &SqlitePool, user: &User) -> Vec<Self> {
|
||||||
let rows = sqlx::query!(
|
let rows = sqlx::query!(
|
||||||
"
|
"
|
||||||
@ -221,7 +195,7 @@ mod test {
|
|||||||
notification::Notification,
|
notification::Notification,
|
||||||
trip::Trip,
|
trip::Trip,
|
||||||
tripdetails::{TripDetails, TripDetailsToAdd},
|
tripdetails::{TripDetails, TripDetailsToAdd},
|
||||||
user::{SteeringUser, User},
|
user::{CoxUser, User},
|
||||||
usertrip::UserTrip,
|
usertrip::UserTrip,
|
||||||
},
|
},
|
||||||
testdb,
|
testdb,
|
||||||
@ -257,7 +231,7 @@ mod test {
|
|||||||
UserTrip::create(&pool, &rower, &trip_details, None)
|
UserTrip::create(&pool, &rower, &trip_details, None)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let cox = SteeringUser::new(&pool, User::find_by_name(&pool, "cox").await.unwrap())
|
let cox = CoxUser::new(&pool, User::find_by_name(&pool, "cox").await.unwrap())
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
Trip::new_join(&pool, &cox, &event).await.unwrap();
|
Trip::new_join(&pool, &cox, &event).await.unwrap();
|
||||||
|
@ -9,7 +9,7 @@ use super::{
|
|||||||
notification::Notification,
|
notification::Notification,
|
||||||
tripdetails::TripDetails,
|
tripdetails::TripDetails,
|
||||||
triptype::TripType,
|
triptype::TripType,
|
||||||
user::{SteeringUser, User},
|
user::{CoxUser, User},
|
||||||
usertrip::UserTrip,
|
usertrip::UserTrip,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ pub struct TripWithUserAndType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct TripUpdate<'a> {
|
pub struct TripUpdate<'a> {
|
||||||
pub cox: &'a SteeringUser,
|
pub cox: &'a CoxUser,
|
||||||
pub trip: &'a Trip,
|
pub trip: &'a Trip,
|
||||||
pub max_people: i32,
|
pub max_people: i32,
|
||||||
pub notes: Option<&'a str>,
|
pub notes: Option<&'a str>,
|
||||||
@ -62,7 +62,7 @@ impl TripWithUserAndType {
|
|||||||
|
|
||||||
impl Trip {
|
impl Trip {
|
||||||
/// Cox decides to create own trip.
|
/// Cox decides to create own trip.
|
||||||
pub async fn new_own(db: &SqlitePool, cox: &SteeringUser, trip_details: TripDetails) {
|
pub async fn new_own(db: &SqlitePool, cox: &CoxUser, trip_details: TripDetails) {
|
||||||
let _ = sqlx::query!(
|
let _ = sqlx::query!(
|
||||||
"INSERT INTO trip (cox_id, trip_details_id) VALUES(?, ?)",
|
"INSERT INTO trip (cox_id, trip_details_id) VALUES(?, ?)",
|
||||||
cox.id,
|
cox.id,
|
||||||
@ -207,7 +207,7 @@ WHERE trip.id=?
|
|||||||
/// Cox decides to help in a event.
|
/// Cox decides to help in a event.
|
||||||
pub async fn new_join(
|
pub async fn new_join(
|
||||||
db: &SqlitePool,
|
db: &SqlitePool,
|
||||||
cox: &SteeringUser,
|
cox: &CoxUser,
|
||||||
event: &Event,
|
event: &Event,
|
||||||
) -> Result<(), CoxHelpError> {
|
) -> Result<(), CoxHelpError> {
|
||||||
if event.is_rower_registered(db, cox).await {
|
if event.is_rower_registered(db, cox).await {
|
||||||
@ -360,7 +360,7 @@ WHERE day=?
|
|||||||
|
|
||||||
pub async fn delete_by_planned_event(
|
pub async fn delete_by_planned_event(
|
||||||
db: &SqlitePool,
|
db: &SqlitePool,
|
||||||
cox: &SteeringUser,
|
cox: &CoxUser,
|
||||||
event: &Event,
|
event: &Event,
|
||||||
) -> Result<(), TripHelpDeleteError> {
|
) -> Result<(), TripHelpDeleteError> {
|
||||||
if event.trip_details(db).await.is_locked {
|
if event.trip_details(db).await.is_locked {
|
||||||
@ -387,7 +387,7 @@ WHERE day=?
|
|||||||
pub(crate) async fn delete(
|
pub(crate) async fn delete(
|
||||||
&self,
|
&self,
|
||||||
db: &SqlitePool,
|
db: &SqlitePool,
|
||||||
user: &SteeringUser,
|
user: &CoxUser,
|
||||||
) -> Result<(), TripDeleteError> {
|
) -> Result<(), TripDeleteError> {
|
||||||
let registered_rower = Registration::all_rower(db, self.trip_details_id.unwrap()).await;
|
let registered_rower = Registration::all_rower(db, self.trip_details_id.unwrap()).await;
|
||||||
if !registered_rower.is_empty() {
|
if !registered_rower.is_empty() {
|
||||||
@ -473,7 +473,7 @@ mod test {
|
|||||||
event::Event,
|
event::Event,
|
||||||
trip::{self, TripDeleteError},
|
trip::{self, TripDeleteError},
|
||||||
tripdetails::TripDetails,
|
tripdetails::TripDetails,
|
||||||
user::{SteeringUser, User},
|
user::{CoxUser, User},
|
||||||
usertrip::UserTrip,
|
usertrip::UserTrip,
|
||||||
},
|
},
|
||||||
testdb,
|
testdb,
|
||||||
@ -488,7 +488,7 @@ mod test {
|
|||||||
fn test_new_own() {
|
fn test_new_own() {
|
||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
|
|
||||||
let cox = SteeringUser::new(
|
let cox = CoxUser::new(
|
||||||
&pool,
|
&pool,
|
||||||
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||||
)
|
)
|
||||||
@ -515,7 +515,7 @@ mod test {
|
|||||||
fn test_new_succ_join() {
|
fn test_new_succ_join() {
|
||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
|
|
||||||
let cox = SteeringUser::new(
|
let cox = CoxUser::new(
|
||||||
&pool,
|
&pool,
|
||||||
User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
||||||
)
|
)
|
||||||
@ -531,7 +531,7 @@ mod test {
|
|||||||
fn test_new_failed_join_already_cox() {
|
fn test_new_failed_join_already_cox() {
|
||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
|
|
||||||
let cox = SteeringUser::new(
|
let cox = CoxUser::new(
|
||||||
&pool,
|
&pool,
|
||||||
User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
||||||
)
|
)
|
||||||
@ -548,7 +548,7 @@ mod test {
|
|||||||
fn test_succ_update_own() {
|
fn test_succ_update_own() {
|
||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
|
|
||||||
let cox = SteeringUser::new(
|
let cox = CoxUser::new(
|
||||||
&pool,
|
&pool,
|
||||||
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||||
)
|
)
|
||||||
@ -576,7 +576,7 @@ mod test {
|
|||||||
fn test_succ_update_own_with_triptype() {
|
fn test_succ_update_own_with_triptype() {
|
||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
|
|
||||||
let cox = SteeringUser::new(
|
let cox = CoxUser::new(
|
||||||
&pool,
|
&pool,
|
||||||
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||||
)
|
)
|
||||||
@ -604,7 +604,7 @@ mod test {
|
|||||||
fn test_fail_update_own_not_your_trip() {
|
fn test_fail_update_own_not_your_trip() {
|
||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
|
|
||||||
let cox = SteeringUser::new(
|
let cox = CoxUser::new(
|
||||||
&pool,
|
&pool,
|
||||||
User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
||||||
)
|
)
|
||||||
@ -629,7 +629,7 @@ mod test {
|
|||||||
fn test_succ_delete_by_planned_event() {
|
fn test_succ_delete_by_planned_event() {
|
||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
|
|
||||||
let cox = SteeringUser::new(
|
let cox = CoxUser::new(
|
||||||
&pool,
|
&pool,
|
||||||
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||||
)
|
)
|
||||||
@ -652,7 +652,7 @@ mod test {
|
|||||||
fn test_succ_delete() {
|
fn test_succ_delete() {
|
||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
|
|
||||||
let cox = SteeringUser::new(
|
let cox = CoxUser::new(
|
||||||
&pool,
|
&pool,
|
||||||
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||||
)
|
)
|
||||||
@ -670,7 +670,7 @@ mod test {
|
|||||||
fn test_fail_delete_diff_cox() {
|
fn test_fail_delete_diff_cox() {
|
||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
|
|
||||||
let cox = SteeringUser::new(
|
let cox = CoxUser::new(
|
||||||
&pool,
|
&pool,
|
||||||
User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
||||||
)
|
)
|
||||||
@ -692,7 +692,7 @@ mod test {
|
|||||||
fn test_fail_delete_someone_registered() {
|
fn test_fail_delete_someone_registered() {
|
||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
|
|
||||||
let cox = SteeringUser::new(
|
let cox = CoxUser::new(
|
||||||
&pool,
|
&pool,
|
||||||
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||||
)
|
)
|
||||||
|
@ -146,7 +146,7 @@ WHERE day = ? AND planned_starting_time = ?
|
|||||||
// User is a guest, no need to bother.
|
// User is a guest, no need to bother.
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
if !user.allowed_to_steer(db).await {
|
if !user.has_role(db, "cox").await {
|
||||||
// User is no cox, no need to bother
|
// User is no cox, no need to bother
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -50,20 +50,16 @@ pub struct UserWithDetails {
|
|||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub user: User,
|
pub user: User,
|
||||||
pub amount_unread_notifications: i32,
|
pub amount_unread_notifications: i32,
|
||||||
pub allowed_to_steer: bool,
|
|
||||||
pub on_water: bool,
|
pub on_water: bool,
|
||||||
pub roles: Vec<String>,
|
pub roles: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UserWithDetails {
|
impl UserWithDetails {
|
||||||
pub async fn from_user(user: User, db: &SqlitePool) -> Self {
|
pub async fn from_user(user: User, db: &SqlitePool) -> Self {
|
||||||
let allowed_to_steer = user.allowed_to_steer(db).await;
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
on_water: user.on_water(db).await,
|
on_water: user.on_water(db).await,
|
||||||
roles: user.roles(db).await,
|
roles: user.roles(db).await,
|
||||||
amount_unread_notifications: user.amount_unread_notifications(db).await,
|
amount_unread_notifications: user.amount_unread_notifications(db).await,
|
||||||
allowed_to_steer,
|
|
||||||
user,
|
user,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,14 +136,6 @@ impl Fee {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl User {
|
impl User {
|
||||||
pub async fn allowed_to_steer(&self, db: &SqlitePool) -> bool {
|
|
||||||
self.has_role(db, "cox").await || self.has_role(db, "Bootsführer").await
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn allowed_to_steer_tx(&self, db: &mut Transaction<'_, Sqlite>) -> bool {
|
|
||||||
self.has_role_tx(db, "cox").await || self.has_role_tx(db, "Bootsführer").await
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn send_welcome_email(&self, db: &SqlitePool, smtp_pw: &str) -> Result<(), String> {
|
pub async fn send_welcome_email(&self, db: &SqlitePool, smtp_pw: &str) -> Result<(), String> {
|
||||||
let Some(mail) = &self.mail else {
|
let Some(mail) = &self.mail else {
|
||||||
return Err(format!(
|
return Err(format!(
|
||||||
@ -247,8 +235,10 @@ ASKÖ Ruderverein Donau Linz", self.name, SCHECKBUCH/100),
|
|||||||
).await?;
|
).await?;
|
||||||
|
|
||||||
// 2. Notify all coxes
|
// 2. Notify all coxes
|
||||||
Notification::create_for_steering_people(
|
let coxes = Role::find_by_name(db, "cox").await.unwrap();
|
||||||
|
Notification::create_for_role(
|
||||||
db,
|
db,
|
||||||
|
&coxes,
|
||||||
&format!(
|
&format!(
|
||||||
"Liebe Steuerberechtigte, {} hat nun ein Scheckbuch. Wie immer, freuen wir uns wenn du uns beim A+F Rudern unterstützt oder selber Ausfahrten ausschreibst. Bitte beachte, dass Scheckbuch-Personen nur Ausfahrten sehen, bei denen 'Scheckbuch-Anmeldungen erlauben' ausgewählt wurde.",
|
"Liebe Steuerberechtigte, {} hat nun ein Scheckbuch. Wie immer, freuen wir uns wenn du uns beim A+F Rudern unterstützt oder selber Ausfahrten ausschreibst. Bitte beachte, dass Scheckbuch-Personen nur Ausfahrten sehen, bei denen 'Scheckbuch-Anmeldungen erlauben' ausgewählt wurde.",
|
||||||
self.name
|
self.name
|
||||||
@ -325,8 +315,10 @@ ASKÖ Ruderverein Donau Linz", self.name),
|
|||||||
).await?;
|
).await?;
|
||||||
|
|
||||||
// 2. Notify all coxes
|
// 2. Notify all coxes
|
||||||
Notification::create_for_steering_people(
|
let coxes = Role::find_by_name(db, "cox").await.unwrap();
|
||||||
|
Notification::create_for_role(
|
||||||
db,
|
db,
|
||||||
|
&coxes,
|
||||||
&format!(
|
&format!(
|
||||||
"Liebe Steuerberechtigte, seit {} gibt es ein neues Mitglied: {}",
|
"Liebe Steuerberechtigte, seit {} gibt es ein neues Mitglied: {}",
|
||||||
self.member_since_date.clone().unwrap(),
|
self.member_since_date.clone().unwrap(),
|
||||||
@ -382,11 +374,7 @@ ASKÖ Ruderverein Donau Linz", self.name),
|
|||||||
return fee;
|
return fee;
|
||||||
}
|
}
|
||||||
if self.has_role(db, "Rennrudern").await {
|
if self.has_role(db, "Rennrudern").await {
|
||||||
if self.has_role(db, "half-rennrudern").await {
|
fee.add("Rennruderbeitrag".into(), RENNRUDERBEITRAG);
|
||||||
fee.add("Rennruderbeitrag (1/2 Preis) ".into(), RENNRUDERBEITRAG / 2);
|
|
||||||
} else {
|
|
||||||
fee.add("Rennruderbeitrag".into(), RENNRUDERBEITRAG);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let amount_boats = self.amount_boats(db).await;
|
let amount_boats = self.amount_boats(db).await;
|
||||||
@ -986,7 +974,7 @@ ORDER BY last_access DESC
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn amount_days_to_show(&self, db: &SqlitePool) -> i64 {
|
pub(crate) async fn amount_days_to_show(&self, db: &SqlitePool) -> i64 {
|
||||||
if self.allowed_to_steer(db).await {
|
if self.has_role(db, "cox").await {
|
||||||
let end_of_year = NaiveDate::from_ymd_opt(Local::now().year(), 12, 31).unwrap(); //Ok,
|
let end_of_year = NaiveDate::from_ymd_opt(Local::now().year(), 12, 31).unwrap(); //Ok,
|
||||||
//december
|
//december
|
||||||
//has 31
|
//has 31
|
||||||
@ -1038,8 +1026,10 @@ ORDER BY last_access DESC
|
|||||||
if let Some(mail) = &self.mail {
|
if let Some(mail) = &self.mail {
|
||||||
let _ = self.send_end_mail_scheckbuch(db, mail, smtp_pw).await;
|
let _ = self.send_end_mail_scheckbuch(db, mail, smtp_pw).await;
|
||||||
}
|
}
|
||||||
Notification::create_for_steering_people_tx(
|
let coxes = Role::find_by_name_tx(db, "cox").await.unwrap();
|
||||||
|
Notification::create_for_role_tx(
|
||||||
db,
|
db,
|
||||||
|
&coxes,
|
||||||
&format!(
|
&format!(
|
||||||
"Liebe Steuerberechtigte, {} hat alle Ausfahrten des Scheckbuchs absolviert. Hoffentlich können wir uns bald über ein neues Mitglied freuen :-)",
|
"Liebe Steuerberechtigte, {} hat alle Ausfahrten des Scheckbuchs absolviert. Hoffentlich können wir uns bald über ein neues Mitglied freuen :-)",
|
||||||
self.name
|
self.name
|
||||||
@ -1166,7 +1156,7 @@ macro_rules! special_user {
|
|||||||
}
|
}
|
||||||
|
|
||||||
special_user!(TechUser, +"tech");
|
special_user!(TechUser, +"tech");
|
||||||
special_user!(SteeringUser, +"cox", +"Bootsführer");
|
special_user!(CoxUser, +"cox");
|
||||||
special_user!(AdminUser, +"admin");
|
special_user!(AdminUser, +"admin");
|
||||||
special_user!(AllowedForPlannedTripsUser, +"Donau Linz", +"scheckbuch");
|
special_user!(AllowedForPlannedTripsUser, +"Donau Linz", +"scheckbuch");
|
||||||
special_user!(DonauLinzUser, +"Donau Linz", -"Unterstützend", -"Förderndes Mitglied");
|
special_user!(DonauLinzUser, +"Donau Linz", -"Unterstützend", -"Förderndes Mitglied");
|
||||||
|
@ -5,7 +5,7 @@ use super::{
|
|||||||
notification::Notification,
|
notification::Notification,
|
||||||
trip::{Trip, TripWithUserAndType},
|
trip::{Trip, TripWithUserAndType},
|
||||||
tripdetails::TripDetails,
|
tripdetails::TripDetails,
|
||||||
user::{SteeringUser, User},
|
user::{CoxUser, User},
|
||||||
};
|
};
|
||||||
use crate::model::tripdetails::{Action, CoxAtTrip::Yes};
|
use crate::model::tripdetails::{Action, CoxAtTrip::Yes};
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ impl UserTrip {
|
|||||||
let mut add_info = "";
|
let mut add_info = "";
|
||||||
if let Some(trip) = &trip_to_delete {
|
if let Some(trip) = &trip_to_delete {
|
||||||
let cox = User::find_by_id(db, trip.cox_id as i32).await.unwrap();
|
let cox = User::find_by_id(db, trip.cox_id as i32).await.unwrap();
|
||||||
trip.delete(db, &SteeringUser::new(db, cox).await.unwrap())
|
trip.delete(db, &CoxUser::new(db, cox).await.unwrap())
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
add_info = " Das war die letzte angemeldete Person. Nachdem nun alle Bescheid wissen, wird die Ausfahrt ab sofort nicht mehr angezeigt.";
|
add_info = " Das war die letzte angemeldete Person. Nachdem nun alle Bescheid wissen, wird die Ausfahrt ab sofort nicht mehr angezeigt.";
|
||||||
@ -270,7 +270,7 @@ pub enum UserTripDeleteError {
|
|||||||
mod test {
|
mod test {
|
||||||
use crate::{
|
use crate::{
|
||||||
model::{
|
model::{
|
||||||
event::Event, trip::Trip, tripdetails::TripDetails, user::SteeringUser,
|
event::Event, trip::Trip, tripdetails::TripDetails, user::CoxUser,
|
||||||
usertrip::UserTripError,
|
usertrip::UserTripError,
|
||||||
},
|
},
|
||||||
testdb,
|
testdb,
|
||||||
@ -353,7 +353,7 @@ mod test {
|
|||||||
fn test_fail_create_is_cox_planned_event() {
|
fn test_fail_create_is_cox_planned_event() {
|
||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
|
|
||||||
let cox = SteeringUser::new(
|
let cox = CoxUser::new(
|
||||||
&pool,
|
&pool,
|
||||||
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||||
)
|
)
|
||||||
|
@ -13,7 +13,7 @@ use crate::{
|
|||||||
model::{
|
model::{
|
||||||
boat::Boat,
|
boat::Boat,
|
||||||
boatdamage::{BoatDamage, BoatDamageFixed, BoatDamageToAdd, BoatDamageVerified},
|
boatdamage::{BoatDamage, BoatDamageFixed, BoatDamageToAdd, BoatDamageVerified},
|
||||||
user::{DonauLinzUser, SteeringUser, TechUser, User, UserWithDetails},
|
user::{CoxUser, DonauLinzUser, TechUser, User, UserWithDetails},
|
||||||
},
|
},
|
||||||
tera::log::KioskCookie,
|
tera::log::KioskCookie,
|
||||||
};
|
};
|
||||||
@ -133,7 +133,7 @@ async fn fixed<'r>(
|
|||||||
db: &State<SqlitePool>,
|
db: &State<SqlitePool>,
|
||||||
data: Form<FormBoatDamageFixed<'r>>,
|
data: Form<FormBoatDamageFixed<'r>>,
|
||||||
boatdamage_id: i32,
|
boatdamage_id: i32,
|
||||||
coxuser: SteeringUser,
|
coxuser: CoxUser,
|
||||||
) -> Flash<Redirect> {
|
) -> Flash<Redirect> {
|
||||||
let boatdamage = BoatDamage::find_by_id(db, boatdamage_id).await.unwrap(); //TODO: Fix
|
let boatdamage = BoatDamage::find_by_id(db, boatdamage_id).await.unwrap(); //TODO: Fix
|
||||||
let boatdamage_fixed = BoatDamageFixed {
|
let boatdamage_fixed = BoatDamageFixed {
|
||||||
|
@ -11,14 +11,14 @@ use crate::model::{
|
|||||||
log::Log,
|
log::Log,
|
||||||
trip::{self, CoxHelpError, Trip, TripDeleteError, TripHelpDeleteError, TripUpdateError},
|
trip::{self, CoxHelpError, Trip, TripDeleteError, TripHelpDeleteError, TripUpdateError},
|
||||||
tripdetails::{TripDetails, TripDetailsToAdd},
|
tripdetails::{TripDetails, TripDetailsToAdd},
|
||||||
user::{AllowedToUpdateTripToAlwaysBeShownUser, SteeringUser},
|
user::{AllowedToUpdateTripToAlwaysBeShownUser, CoxUser},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[post("/trip", data = "<data>")]
|
#[post("/trip", data = "<data>")]
|
||||||
async fn create(
|
async fn create(
|
||||||
db: &State<SqlitePool>,
|
db: &State<SqlitePool>,
|
||||||
data: Form<TripDetailsToAdd<'_>>,
|
data: Form<TripDetailsToAdd<'_>>,
|
||||||
cox: SteeringUser,
|
cox: CoxUser,
|
||||||
) -> Flash<Redirect> {
|
) -> Flash<Redirect> {
|
||||||
let trip_details_id = TripDetails::create(db, data.into_inner()).await;
|
let trip_details_id = TripDetails::create(db, data.into_inner()).await;
|
||||||
let trip_details = TripDetails::find_by_id(db, trip_details_id).await.unwrap(); //Okay, bc just
|
let trip_details = TripDetails::find_by_id(db, trip_details_id).await.unwrap(); //Okay, bc just
|
||||||
@ -50,7 +50,7 @@ async fn update(
|
|||||||
db: &State<SqlitePool>,
|
db: &State<SqlitePool>,
|
||||||
data: Form<EditTripForm<'_>>,
|
data: Form<EditTripForm<'_>>,
|
||||||
trip_id: i64,
|
trip_id: i64,
|
||||||
cox: SteeringUser,
|
cox: CoxUser,
|
||||||
) -> Flash<Redirect> {
|
) -> Flash<Redirect> {
|
||||||
if let Some(trip) = Trip::find_by_id(db, trip_id).await {
|
if let Some(trip) = Trip::find_by_id(db, trip_id).await {
|
||||||
let update = trip::TripUpdate {
|
let update = trip::TripUpdate {
|
||||||
@ -96,7 +96,7 @@ async fn toggle_always_show(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/join/<planned_event_id>")]
|
#[get("/join/<planned_event_id>")]
|
||||||
async fn join(db: &State<SqlitePool>, planned_event_id: i64, cox: SteeringUser) -> Flash<Redirect> {
|
async fn join(db: &State<SqlitePool>, planned_event_id: i64, cox: CoxUser) -> Flash<Redirect> {
|
||||||
if let Some(planned_event) = Event::find_by_id(db, planned_event_id).await {
|
if let Some(planned_event) = Event::find_by_id(db, planned_event_id).await {
|
||||||
match Trip::new_join(db, &cox, &planned_event).await {
|
match Trip::new_join(db, &cox, &planned_event).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
@ -130,7 +130,7 @@ async fn join(db: &State<SqlitePool>, planned_event_id: i64, cox: SteeringUser)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/remove/trip/<trip_id>")]
|
#[get("/remove/trip/<trip_id>")]
|
||||||
async fn remove_trip(db: &State<SqlitePool>, trip_id: i64, cox: SteeringUser) -> Flash<Redirect> {
|
async fn remove_trip(db: &State<SqlitePool>, trip_id: i64, cox: CoxUser) -> Flash<Redirect> {
|
||||||
let trip = Trip::find_by_id(db, trip_id).await;
|
let trip = Trip::find_by_id(db, trip_id).await;
|
||||||
match trip {
|
match trip {
|
||||||
None => Flash::error(Redirect::to("/planned"), "Trip gibt's nicht!"),
|
None => Flash::error(Redirect::to("/planned"), "Trip gibt's nicht!"),
|
||||||
@ -151,11 +151,7 @@ async fn remove_trip(db: &State<SqlitePool>, trip_id: i64, cox: SteeringUser) ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/remove/<planned_event_id>")]
|
#[get("/remove/<planned_event_id>")]
|
||||||
async fn remove(
|
async fn remove(db: &State<SqlitePool>, planned_event_id: i64, cox: CoxUser) -> Flash<Redirect> {
|
||||||
db: &State<SqlitePool>,
|
|
||||||
planned_event_id: i64,
|
|
||||||
cox: SteeringUser,
|
|
||||||
) -> Flash<Redirect> {
|
|
||||||
if let Some(planned_event) = Event::find_by_id(db, planned_event_id).await {
|
if let Some(planned_event) = Event::find_by_id(db, planned_event_id).await {
|
||||||
match Trip::delete_by_planned_event(db, &cox, &planned_event).await {
|
match Trip::delete_by_planned_event(db, &cox, &planned_event).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
@ -98,6 +98,8 @@ async fn steering(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage
|
|||||||
User::all_with_role(db, &Role::find_by_name(db, "Bootsführer").await.unwrap()).await;
|
User::all_with_role(db, &Role::find_by_name(db, "Bootsführer").await.unwrap()).await;
|
||||||
|
|
||||||
let mut coxes = User::all_with_role(db, &Role::find_by_name(db, "cox").await.unwrap()).await;
|
let mut coxes = User::all_with_role(db, &Role::find_by_name(db, "cox").await.unwrap()).await;
|
||||||
|
|
||||||
|
coxes.retain(|user| !bootskundige.contains(user)); // Remove bootskundige from coxes list
|
||||||
coxes.retain(|user| user.name != "Externe Steuerperson");
|
coxes.retain(|user| user.name != "Externe Steuerperson");
|
||||||
|
|
||||||
context.insert("coxes", &coxes);
|
context.insert("coxes", &coxes);
|
||||||
|
@ -29,7 +29,7 @@ async fn index(
|
|||||||
|
|
||||||
let mut context = Context::new();
|
let mut context = Context::new();
|
||||||
|
|
||||||
if user.allowed_to_steer(db).await || user.has_role(db, "manage_events").await {
|
if user.has_role(db, "cox").await || user.has_role(db, "manage_events").await {
|
||||||
let triptypes = TripType::all(db).await;
|
let triptypes = TripType::all(db).await;
|
||||||
context.insert("trip_types", &triptypes);
|
context.insert("trip_types", &triptypes);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
{% if boatdamage.fixed_at %}
|
{% if boatdamage.fixed_at %}
|
||||||
<small class="block text-gray-600 dark:text-gray-100">Repariert von {{ boatdamage.user_fixed.name }} am/um {{ boatdamage.fixed_at | date(format='%d.%m.%Y (%H:%M)') }}</small>
|
<small class="block text-gray-600 dark:text-gray-100">Repariert von {{ boatdamage.user_fixed.name }} am/um {{ boatdamage.fixed_at | date(format='%d.%m.%Y (%H:%M)') }}</small>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if loggedin_user and loggedin_user.allowed_to_steer %}
|
{% if loggedin_user and "cox" in loggedin_user.roles %}
|
||||||
<form action="/boatdamage/{{ boatdamage.id }}/fixed"
|
<form action="/boatdamage/{{ boatdamage.id }}/fixed"
|
||||||
method="post"
|
method="post"
|
||||||
class="flex justify-between mt-3">
|
class="flex justify-between mt-3">
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% if loggedin_user.allowed_to_steer %}
|
{% if "cox" in loggedin_user.roles %}
|
||||||
<div class="sm:col-span-2 lg:col-span-3 grid md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-3">
|
<div class="sm:col-span-2 lg:col-span-3 grid md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-3">
|
||||||
<button type="button"
|
<button type="button"
|
||||||
title="Toggle View"
|
title="Toggle View"
|
||||||
|
@ -93,7 +93,7 @@
|
|||||||
<option value="{{ user.id }}"
|
<option value="{{ user.id }}"
|
||||||
{% if sel %}selected{% endif %}
|
{% if sel %}selected{% endif %}
|
||||||
{% if user.on_water %}disabled="disabled"{% endif %}
|
{% if user.on_water %}disabled="disabled"{% endif %}
|
||||||
data-custom-properties='{"is_cox": {{ user.allowed_to_steer }}, "is_racing": {{ "Rennrudern" in user.roles }}, "steers": {{ user.id == steering_person_id }}, "cox_on_boat": {{ user.id == cox_on_boat }}, "searchableText": "{{ user.nickname }}"}'>
|
data-custom-properties='{"is_cox": {{ "cox" in user.roles }}, "is_racing": {{ "Rennrudern" in user.roles }}, "steers": {{ user.id == steering_person_id }}, "cox_on_boat": {{ user.id == cox_on_boat }}, "searchableText": "{{ user.nickname }}"}'>
|
||||||
{{ user.name }}
|
{{ user.name }}
|
||||||
{% if user.on_water %}(am Wasser){% endif %}
|
{% if user.on_water %}(am Wasser){% endif %}
|
||||||
</option>
|
</option>
|
||||||
|
@ -23,9 +23,9 @@
|
|||||||
{% if on_water | length > 0 %}
|
{% if on_water | length > 0 %}
|
||||||
{% for log in on_water %}
|
{% for log in on_water %}
|
||||||
{% if log.shipmaster == loggedin_user.id %}
|
{% if log.shipmaster == loggedin_user.id %}
|
||||||
{{ log::show(log=log, state="on_water", allowed_to_close=true, only_ones=not loggedin_user.allowed_to_steer) }}
|
{{ log::show(log=log, state="on_water", allowed_to_close=true, only_ones="cox" not in loggedin_user.roles) }}
|
||||||
{% elif "Vorstand" in loggedin_user.roles %}
|
{% elif "Vorstand" in loggedin_user.roles %}
|
||||||
{{ log::show(log=log, state="on_water", allowed_to_close=true, only_ones=not loggedin_user.allowed_to_steer) }}
|
{{ log::show(log=log, state="on_water", allowed_to_close=true, only_ones="cox" not in loggedin_user.roles) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ log::show(log=log, state="on_water", only_ones=true) }}
|
{{ log::show(log=log, state="on_water", only_ones=true) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -151,7 +151,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{# --- END Row Buttons --- #}
|
{# --- END Row Buttons --- #}
|
||||||
{# --- START Cox Buttons --- #}
|
{# --- START Cox Buttons --- #}
|
||||||
{% if loggedin_user.allowed_to_steer %}
|
{% if "cox" in loggedin_user.roles %}
|
||||||
{% set_global cur_user_participates = false %}
|
{% set_global cur_user_participates = false %}
|
||||||
{% for cox in event.cox %}
|
{% for cox in event.cox %}
|
||||||
{% if cox.name == loggedin_user.name %}
|
{% if cox.name == loggedin_user.name %}
|
||||||
@ -421,11 +421,11 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{# --- START Add Buttons --- #}
|
{# --- START Add Buttons --- #}
|
||||||
{% if "manage_events" in loggedin_user.roles or loggedin_user.allowed_to_steer %}
|
{% if "manage_events" in loggedin_user.roles or "cox" in loggedin_user.roles %}
|
||||||
<div class="grid {% if "manage_events" in loggedin_user.roles and loggedin_user.allowed_to_steer %}grid-cols-2{% endif %} text-center">
|
<div class="grid {% if "manage_events" in loggedin_user.roles and "cox" in loggedin_user.roles %}grid-cols-2{% endif %} text-center">
|
||||||
{% if "manage_events" in loggedin_user.roles %}
|
{% if "manage_events" in loggedin_user.roles %}
|
||||||
<a href="#" data-sidebar="true" data-trigger="sidebar" data-header="<strong>Event</strong> am {{ day.day| date(format='%d.%m.%Y') }} erstellen" data-day="{{ day.day }}" data-body="#addEventForm" class="relative inline-block w-full bg-primary-900 hover:bg-primary-950 focus:bg-primary-950 dark:bg-primary-950 text-white py-2 text-sm font-semibold
|
<a href="#" data-sidebar="true" data-trigger="sidebar" data-header="<strong>Event</strong> am {{ day.day| date(format='%d.%m.%Y') }} erstellen" data-day="{{ day.day }}" data-body="#addEventForm" class="relative inline-block w-full bg-primary-900 hover:bg-primary-950 focus:bg-primary-950 dark:bg-primary-950 text-white py-2 text-sm font-semibold
|
||||||
{% if loggedin_user.allowed_to_steer %}
|
{% if "cox" in loggedin_user.roles %}
|
||||||
rounded-bl-md
|
rounded-bl-md
|
||||||
{% else %}
|
{% else %}
|
||||||
rounded-b-md
|
rounded-b-md
|
||||||
@ -435,7 +435,7 @@
|
|||||||
Event
|
Event
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if loggedin_user.allowed_to_steer %}
|
{% if "cox" in loggedin_user.roles %}
|
||||||
<a href="#" data-sidebar="true" data-trigger="sidebar" data-header="<strong>Ausfahrt</strong> am {{ day.day| date(format='%d.%m.%Y') }} erstellen" data-day="{{ day.day }}" data-body="#sidebarForm" class="relative inline-block w-full py-2 text-primary-900 hover:text-primary-950 dark:bg-primary-600 dark:text-white dark:hover:bg-primary-500 dark:hover:text-white focus:text-primary-950 text-sm font-semibold bg-gray-100 hover:bg-gray-200 focus:bg-gray-200
|
<a href="#" data-sidebar="true" data-trigger="sidebar" data-header="<strong>Ausfahrt</strong> am {{ day.day| date(format='%d.%m.%Y') }} erstellen" data-day="{{ day.day }}" data-body="#sidebarForm" class="relative inline-block w-full py-2 text-primary-900 hover:text-primary-950 dark:bg-primary-600 dark:text-white dark:hover:bg-primary-500 dark:hover:text-white focus:text-primary-950 text-sm font-semibold bg-gray-100 hover:bg-gray-200 focus:bg-gray-200
|
||||||
{% if "manage_events" in loggedin_user.roles %}
|
{% if "manage_events" in loggedin_user.roles %}
|
||||||
rounded-br-md
|
rounded-br-md
|
||||||
@ -454,7 +454,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if loggedin_user.allowed_to_steer %}
|
{% if "cox" in loggedin_user.roles %}
|
||||||
{% include "forms/trip" %}
|
{% include "forms/trip" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if "manage_events" in loggedin_user.roles %}
|
{% if "manage_events" in loggedin_user.roles %}
|
||||||
|
Loading…
Reference in New Issue
Block a user