add planned mod #1053
@ -1,8 +1,8 @@
|
||||
use std::ops::DerefMut;
|
||||
|
||||
use chrono::NaiveDateTime;
|
||||
use rocket::serde::{Deserialize, Serialize};
|
||||
use rocket::FromForm;
|
||||
use rocket::serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||
|
||||
use crate::model::boathouse::Boathouse;
|
||||
|
@ -1,9 +1,9 @@
|
||||
use std::{error::Error, fs};
|
||||
|
||||
use lettre::{
|
||||
message::{header::ContentType, Attachment, MultiPart, SinglePart},
|
||||
transport::smtp::authentication::Credentials,
|
||||
Address, Message, SmtpTransport, Transport,
|
||||
message::{Attachment, MultiPart, SinglePart, header::ContentType},
|
||||
transport::smtp::authentication::Credentials,
|
||||
};
|
||||
use sqlx::{Sqlite, SqlitePool, Transaction};
|
||||
|
||||
|
@ -5,13 +5,12 @@ use waterlevel::WaterlevelDay;
|
||||
|
||||
use crate::AMOUNT_DAYS_TO_SHOW_TRIPS_AHEAD;
|
||||
|
||||
use self::{
|
||||
use self::{waterlevel::Waterlevel, weather::Weather};
|
||||
use boatreservation::{BoatReservation, BoatReservationWithDetails};
|
||||
use planned::{
|
||||
event::{Event, EventWithDetails},
|
||||
trip::{Trip, TripWithDetails},
|
||||
waterlevel::Waterlevel,
|
||||
weather::Weather,
|
||||
};
|
||||
use boatreservation::{BoatReservation, BoatReservationWithDetails};
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub mod activity;
|
||||
@ -20,7 +19,6 @@ pub mod boatdamage;
|
||||
pub mod boathouse;
|
||||
pub mod boatreservation;
|
||||
pub mod distance;
|
||||
pub mod event;
|
||||
pub mod family;
|
||||
pub mod location;
|
||||
pub mod log;
|
||||
@ -29,16 +27,13 @@ pub mod logtype;
|
||||
pub mod mail;
|
||||
pub mod notification;
|
||||
pub mod personal;
|
||||
pub mod planned;
|
||||
pub mod role;
|
||||
pub mod rower;
|
||||
pub mod stat;
|
||||
pub mod trailer;
|
||||
pub mod trailerreservation;
|
||||
pub mod trip;
|
||||
pub mod tripdetails;
|
||||
pub mod triptype;
|
||||
pub mod user;
|
||||
pub mod usertrip;
|
||||
pub mod waterlevel;
|
||||
pub mod weather;
|
||||
|
||||
|
@ -5,7 +5,7 @@ use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||
|
||||
use super::{role::Role, user::User, usertrip::UserTrip};
|
||||
use super::{planned::usertrip::UserTrip, role::Role, user::User};
|
||||
|
||||
#[derive(FromRow, Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Notification {
|
||||
@ -226,13 +226,15 @@ ORDER BY read_at DESC, created_at DESC;
|
||||
mod test {
|
||||
use crate::{
|
||||
model::{
|
||||
event::{Event, EventUpdate, Registration},
|
||||
notification::Notification,
|
||||
planned::{
|
||||
event::{Event, EventUpdate, Registration},
|
||||
trip::Trip,
|
||||
tripdetails::{TripDetails, TripDetailsToAdd},
|
||||
user::{EventUser, SteeringUser, User},
|
||||
usertrip::UserTrip,
|
||||
},
|
||||
user::{EventUser, SteeringUser, User},
|
||||
},
|
||||
testdb,
|
||||
};
|
||||
|
||||
|
@ -1,13 +1,16 @@
|
||||
use std::io::Write;
|
||||
|
||||
use ics::{
|
||||
ICalendar,
|
||||
components::Property,
|
||||
properties::{DtEnd, DtStart, Summary},
|
||||
ICalendar,
|
||||
};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::{event::Event, trip::Trip, user::User};
|
||||
use crate::model::{
|
||||
planned::{event::Event, trip::Trip},
|
||||
user::User,
|
||||
};
|
||||
use chrono::{Duration, NaiveTime};
|
||||
|
||||
pub(crate) async fn get_personal_cal(db: &SqlitePool, user: &User) -> String {
|
||||
|
@ -5,12 +5,11 @@ use ics::ICalendar;
|
||||
use serde::Serialize;
|
||||
use sqlx::{FromRow, Row, SqlitePool};
|
||||
|
||||
use super::{
|
||||
use super::{tripdetails::TripDetails, triptype::TripType};
|
||||
use crate::model::{
|
||||
log::Log,
|
||||
notification::Notification,
|
||||
role::Role,
|
||||
tripdetails::TripDetails,
|
||||
triptype::TripType,
|
||||
user::{EventUser, User},
|
||||
};
|
||||
|
||||
@ -482,7 +481,7 @@ WHERE trip_details.id=?
|
||||
mod test {
|
||||
use crate::{
|
||||
model::{
|
||||
tripdetails::TripDetails,
|
||||
planned::tripdetails::TripDetails,
|
||||
user::{EventUser, User},
|
||||
},
|
||||
testdb,
|
5
src/model/planned/mod.rs
Normal file
5
src/model/planned/mod.rs
Normal file
@ -0,0 +1,5 @@
|
||||
pub mod event;
|
||||
pub mod trip;
|
||||
pub mod tripdetails;
|
||||
pub mod triptype;
|
||||
pub mod usertrip;
|
@ -1,8 +1,7 @@
|
||||
use super::Trip;
|
||||
use crate::model::{
|
||||
notification::Notification,
|
||||
tripdetails::TripDetails,
|
||||
triptype::TripType,
|
||||
planned::{tripdetails::TripDetails, triptype::TripType},
|
||||
user::{ErgoUser, SteeringUser, User},
|
||||
};
|
||||
use sqlx::SqlitePool;
|
@ -6,13 +6,15 @@ mod create;
|
||||
|
||||
use super::{
|
||||
event::{Event, Registration},
|
||||
log::Log,
|
||||
notification::Notification,
|
||||
tripdetails::TripDetails,
|
||||
triptype::TripType,
|
||||
user::{SteeringUser, User},
|
||||
usertrip::UserTrip,
|
||||
};
|
||||
use crate::model::{
|
||||
log::Log,
|
||||
notification::Notification,
|
||||
user::{SteeringUser, User},
|
||||
};
|
||||
|
||||
#[derive(Serialize, Clone, Debug)]
|
||||
pub struct Trip {
|
||||
@ -411,13 +413,15 @@ pub enum TripUpdateError {
|
||||
mod test {
|
||||
use crate::{
|
||||
model::{
|
||||
event::Event,
|
||||
notification::Notification,
|
||||
planned::{
|
||||
event::Event,
|
||||
trip::{self, TripDeleteError},
|
||||
tripdetails::TripDetails,
|
||||
user::{SteeringUser, User},
|
||||
usertrip::UserTrip,
|
||||
},
|
||||
user::{SteeringUser, User},
|
||||
},
|
||||
testdb,
|
||||
};
|
||||
|
||||
@ -467,9 +471,11 @@ mod test {
|
||||
|
||||
let last_notification = &Notification::for_user(&pool, &cox).await[0];
|
||||
|
||||
assert!(last_notification
|
||||
assert!(
|
||||
last_notification
|
||||
.message
|
||||
.starts_with("cox2 hat eine Ausfahrt zur selben Zeit"));
|
||||
.starts_with("cox2 hat eine Ausfahrt zur selben Zeit")
|
||||
);
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
@ -1,11 +1,10 @@
|
||||
use crate::model::user::User;
|
||||
use crate::model::{notification::Notification, user::User};
|
||||
use chrono::{Local, NaiveDate};
|
||||
use rocket::FromForm;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, SqlitePool};
|
||||
|
||||
use super::{
|
||||
notification::Notification,
|
||||
trip::{Trip, TripWithDetails},
|
||||
triptype::TripType,
|
||||
};
|
||||
@ -303,7 +302,7 @@ pub(crate) enum Action {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::{model::tripdetails::TripDetailsToAdd, testdb};
|
||||
use crate::{model::planned::tripdetails::TripDetailsToAdd, testdb};
|
||||
|
||||
use super::TripDetails;
|
||||
use sqlx::SqlitePool;
|
@ -2,12 +2,14 @@ use serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, SqlitePool};
|
||||
|
||||
use super::{
|
||||
notification::Notification,
|
||||
trip::{Trip, TripWithDetails},
|
||||
tripdetails::TripDetails,
|
||||
};
|
||||
use crate::model::{
|
||||
notification::Notification,
|
||||
planned::tripdetails::{Action, CoxAtTrip::Yes},
|
||||
user::{SteeringUser, User},
|
||||
};
|
||||
use crate::model::tripdetails::{Action, CoxAtTrip::Yes};
|
||||
|
||||
#[derive(FromRow, Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct UserTrip {
|
||||
@ -270,8 +272,10 @@ pub enum UserTripDeleteError {
|
||||
mod test {
|
||||
use crate::{
|
||||
model::{
|
||||
event::Event, trip::Trip, tripdetails::TripDetails, user::SteeringUser,
|
||||
usertrip::UserTripError,
|
||||
planned::{
|
||||
event::Event, trip::Trip, tripdetails::TripDetails, usertrip::UserTripError,
|
||||
},
|
||||
user::SteeringUser,
|
||||
},
|
||||
testdb,
|
||||
};
|
@ -1,8 +1,8 @@
|
||||
use super::User;
|
||||
use crate::{
|
||||
model::family::Family, BOAT_STORAGE, DUAL_MEMBERSHIP, EINSCHREIBGEBUEHR, FAMILY_THREE_OR_MORE,
|
||||
FAMILY_TWO, FOERDERND, REGULAR, RENNRUDERBEITRAG, SCHECKBUCH, STUDENT_OR_PUPIL, TRIAL_ROWING,
|
||||
TRIAL_ROWING_REDUCED, UNTERSTUETZEND,
|
||||
BOAT_STORAGE, DUAL_MEMBERSHIP, EINSCHREIBGEBUEHR, FAMILY_THREE_OR_MORE, FAMILY_TWO, FOERDERND,
|
||||
REGULAR, RENNRUDERBEITRAG, SCHECKBUCH, STUDENT_OR_PUPIL, TRIAL_ROWING, TRIAL_ROWING_REDUCED,
|
||||
UNTERSTUETZEND, model::family::Family,
|
||||
};
|
||||
use chrono::{Datelike, Local, NaiveDate};
|
||||
use serde::Serialize;
|
||||
|
@ -1,7 +1,8 @@
|
||||
use super::{regular::ClubMember, ManageUserUser, User};
|
||||
use super::{ManageUserUser, User, regular::ClubMember};
|
||||
use crate::{
|
||||
NonEmptyString,
|
||||
model::{activity::ActivityBuilder, mail::Mail, notification::Notification, role::Role},
|
||||
special_user, NonEmptyString,
|
||||
special_user,
|
||||
};
|
||||
use chrono::NaiveDate;
|
||||
use rocket::{async_trait, fs::TempFile};
|
||||
|
@ -1,29 +1,29 @@
|
||||
use std::{fmt::Display, ops::DerefMut};
|
||||
|
||||
use argon2::{password_hash::SaltString, Argon2, PasswordHasher};
|
||||
use argon2::{Argon2, PasswordHasher, password_hash::SaltString};
|
||||
use chrono::{Datelike, Local, NaiveDate};
|
||||
use log::info;
|
||||
use rocket::async_trait;
|
||||
use rocket::{
|
||||
Request,
|
||||
http::{Cookie, Status},
|
||||
request::{FromRequest, Outcome},
|
||||
time::{Duration, OffsetDateTime},
|
||||
Request,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||
|
||||
use super::activity::{ActivityBuilder, ReasonAuth};
|
||||
use super::{
|
||||
Day,
|
||||
log::Log,
|
||||
logbook::Logbook,
|
||||
mail::Mail,
|
||||
notification::Notification,
|
||||
personal::{equatorprice, rowingbadge},
|
||||
planned::tripdetails::TripDetails,
|
||||
role::Role,
|
||||
stat::Stat,
|
||||
tripdetails::TripDetails,
|
||||
Day,
|
||||
};
|
||||
use crate::AMOUNT_DAYS_TO_SHOW_TRIPS_AHEAD;
|
||||
use scheckbuch::ScheckbuchUser;
|
||||
@ -965,17 +965,21 @@ mod test {
|
||||
#[sqlx::test]
|
||||
fn wrong_pw() {
|
||||
let pool = testdb!();
|
||||
assert!(User::login(&pool, "admin".into(), "admi".into())
|
||||
assert!(
|
||||
User::login(&pool, "admin".into(), "admi".into())
|
||||
.await
|
||||
.is_err());
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
fn wrong_username() {
|
||||
let pool = testdb!();
|
||||
assert!(User::login(&pool, "admi".into(), "admin".into())
|
||||
assert!(
|
||||
User::login(&pool, "admi".into(), "admin".into())
|
||||
.await
|
||||
.is_err());
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
@ -995,9 +999,11 @@ mod test {
|
||||
let pool = testdb!();
|
||||
let user = User::find_by_id(&pool, 1).await.unwrap();
|
||||
|
||||
assert!(User::login(&pool, "admin".into(), "abc".into())
|
||||
assert!(
|
||||
User::login(&pool, "admin".into(), "abc".into())
|
||||
.await
|
||||
.is_err());
|
||||
.is_err()
|
||||
);
|
||||
|
||||
user.update_pw(&pool, "abc".into()).await;
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
use super::{ManageUserUser, User};
|
||||
use crate::{
|
||||
NonEmptyString,
|
||||
model::{activity::ActivityBuilder, mail::Mail, notification::Notification, role::Role},
|
||||
special_user, NonEmptyString,
|
||||
special_user,
|
||||
};
|
||||
use chrono::NaiveDate;
|
||||
use rocket::{async_trait, fs::TempFile, tokio::io::AsyncReadExt};
|
||||
|
@ -2,12 +2,13 @@ use super::foerdernd::FoerderndUser;
|
||||
use super::regular::RegularUser;
|
||||
use super::unterstuetzend::UnterstuetzendUser;
|
||||
use super::{ManageUserUser, User};
|
||||
use crate::NonEmptyString;
|
||||
use crate::model::activity::ActivityBuilder;
|
||||
use crate::model::role::Role;
|
||||
use crate::NonEmptyString;
|
||||
use crate::{
|
||||
SCHECKBUCH,
|
||||
model::{mail::Mail, notification::Notification},
|
||||
special_user, SCHECKBUCH,
|
||||
special_user,
|
||||
};
|
||||
use chrono::NaiveDate;
|
||||
use rocket::async_trait;
|
||||
|
@ -4,9 +4,9 @@ use super::scheckbuch::ScheckbuchUser;
|
||||
use super::schnupperinterest::SchnupperInterestUser;
|
||||
use super::unterstuetzend::UnterstuetzendUser;
|
||||
use super::{ManageUserUser, User};
|
||||
use crate::NonEmptyString;
|
||||
use crate::model::activity::ActivityBuilder;
|
||||
use crate::model::role::Role;
|
||||
use crate::NonEmptyString;
|
||||
use crate::{
|
||||
model::{mail::Mail, notification::Notification},
|
||||
special_user,
|
||||
|
@ -1,9 +1,9 @@
|
||||
use super::scheckbuch::ScheckbuchUser;
|
||||
use super::schnupperant::SchnupperantUser;
|
||||
use super::{ManageUserUser, User};
|
||||
use crate::NonEmptyString;
|
||||
use crate::model::activity::ActivityBuilder;
|
||||
use crate::model::role::Role;
|
||||
use crate::NonEmptyString;
|
||||
use crate::{model::notification::Notification, special_user};
|
||||
use rocket::async_trait;
|
||||
use sqlx::SqlitePool;
|
||||
|
@ -1,7 +1,8 @@
|
||||
use super::{regular::ClubMember, ManageUserUser, User};
|
||||
use super::{ManageUserUser, User, regular::ClubMember};
|
||||
use crate::{
|
||||
NonEmptyString,
|
||||
model::{activity::ActivityBuilder, mail::Mail, notification::Notification, role::Role},
|
||||
special_user, NonEmptyString,
|
||||
special_user,
|
||||
};
|
||||
use chrono::NaiveDate;
|
||||
use rocket::{async_trait, fs::TempFile};
|
||||
|
@ -9,8 +9,10 @@ use serde::Serialize;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::{
|
||||
planned::{
|
||||
event::{self, Event},
|
||||
tripdetails::{TripDetails, TripDetailsToAdd},
|
||||
},
|
||||
user::EventUser,
|
||||
};
|
||||
|
||||
|
@ -1,16 +1,19 @@
|
||||
use rocket::{
|
||||
FromForm, Route, State,
|
||||
form::Form,
|
||||
get, post,
|
||||
response::{Flash, Redirect},
|
||||
routes, FromForm, Route, State,
|
||||
routes,
|
||||
};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::{
|
||||
event::Event,
|
||||
log::Log,
|
||||
planned::{
|
||||
event::Event,
|
||||
trip::{self, CoxHelpError, Trip, TripDeleteError, TripHelpDeleteError, TripUpdateError},
|
||||
tripdetails::{TripDetails, TripDetailsToAdd},
|
||||
},
|
||||
user::{AllowedToUpdateTripToAlwaysBeShownUser, ErgoUser, SteeringUser, User},
|
||||
};
|
||||
|
||||
@ -216,7 +219,7 @@ mod test {
|
||||
};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::{model::trip::Trip, testdb};
|
||||
use crate::{model::planned::trip::Trip, testdb};
|
||||
|
||||
#[sqlx::test]
|
||||
fn test_trip_create() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
use std::net::IpAddr;
|
||||
|
||||
use rocket::{
|
||||
Request, Route, State,
|
||||
form::Form,
|
||||
get,
|
||||
http::{Cookie, CookieJar},
|
||||
@ -9,9 +10,8 @@ use rocket::{
|
||||
response::{Flash, Redirect},
|
||||
routes,
|
||||
time::{Duration, OffsetDateTime},
|
||||
Request, Route, State,
|
||||
};
|
||||
use rocket_dyn_templates::{context, Template};
|
||||
use rocket_dyn_templates::{Template, context};
|
||||
use sqlx::SqlitePool;
|
||||
use tera::Context;
|
||||
|
||||
@ -26,7 +26,7 @@ use crate::{
|
||||
LogbookCreateError, LogbookDeleteError, LogbookUpdateError,
|
||||
},
|
||||
logtype::LogType,
|
||||
trip::Trip,
|
||||
planned::trip::Trip,
|
||||
user::{DonauLinzUser, User, UserWithDetails, VorstandUser},
|
||||
},
|
||||
tera::Config,
|
||||
@ -606,7 +606,7 @@ mod test {
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::logbook::Logbook;
|
||||
use crate::tera::{log::Boat, User};
|
||||
use crate::tera::{User, log::Boat};
|
||||
use crate::testdb;
|
||||
|
||||
#[sqlx::test]
|
||||
|
@ -1,7 +1,7 @@
|
||||
use rocket::{Route, State, get, http::ContentType, routes};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::{event::Event, personal::cal::get_personal_cal, user::User};
|
||||
use crate::model::{personal::cal::get_personal_cal, planned::event::Event, user::User};
|
||||
|
||||
#[get("/cal")]
|
||||
async fn cal(db: &State<SqlitePool>) -> (ContentType, String) {
|
||||
|
@ -12,11 +12,13 @@ use crate::{
|
||||
AMOUNT_DAYS_TO_SHOW_TRIPS_AHEAD,
|
||||
model::{
|
||||
log::Log,
|
||||
planned::{
|
||||
tripdetails::TripDetails,
|
||||
triptype::TripType,
|
||||
user::{AllowedForPlannedTripsUser, User, UserWithDetails},
|
||||
usertrip::{UserTrip, UserTripDeleteError, UserTripError},
|
||||
},
|
||||
user::{AllowedForPlannedTripsUser, User, UserWithDetails},
|
||||
},
|
||||
};
|
||||
|
||||
#[get("/")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user