forked from Ruderverein-Donau-Linz/rowt
format
This commit is contained in:
parent
374fed9e3b
commit
5fb9e0fbba
@ -1,20 +1,21 @@
|
|||||||
use std::{fmt::Display, ops::DerefMut};
|
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 chrono::{Datelike, Local, NaiveDate};
|
||||||
use log::info;
|
use log::info;
|
||||||
use rocket::async_trait;
|
use rocket::async_trait;
|
||||||
use rocket::{
|
use rocket::{
|
||||||
|
Request,
|
||||||
http::{Cookie, Status},
|
http::{Cookie, Status},
|
||||||
request::{FromRequest, Outcome},
|
request::{FromRequest, Outcome},
|
||||||
time::{Duration, OffsetDateTime},
|
time::{Duration, OffsetDateTime},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||||
|
|
||||||
use super::activity::ActivityBuilder;
|
use super::activity::ActivityBuilder;
|
||||||
use super::{
|
use super::{
|
||||||
|
Day,
|
||||||
log::Log,
|
log::Log,
|
||||||
logbook::Logbook,
|
logbook::Logbook,
|
||||||
mail::Mail,
|
mail::Mail,
|
||||||
@ -23,7 +24,6 @@ use super::{
|
|||||||
role::Role,
|
role::Role,
|
||||||
stat::Stat,
|
stat::Stat,
|
||||||
tripdetails::TripDetails,
|
tripdetails::TripDetails,
|
||||||
Day,
|
|
||||||
};
|
};
|
||||||
use crate::AMOUNT_DAYS_TO_SHOW_TRIPS_AHEAD;
|
use crate::AMOUNT_DAYS_TO_SHOW_TRIPS_AHEAD;
|
||||||
use scheckbuch::ScheckbuchUser;
|
use scheckbuch::ScheckbuchUser;
|
||||||
@ -978,17 +978,21 @@ mod test {
|
|||||||
#[sqlx::test]
|
#[sqlx::test]
|
||||||
fn wrong_pw() {
|
fn wrong_pw() {
|
||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
assert!(User::login(&pool, "admin".into(), "admi".into())
|
assert!(
|
||||||
|
User::login(&pool, "admin".into(), "admi".into())
|
||||||
.await
|
.await
|
||||||
.is_err());
|
.is_err()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[sqlx::test]
|
#[sqlx::test]
|
||||||
fn wrong_username() {
|
fn wrong_username() {
|
||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
assert!(User::login(&pool, "admi".into(), "admin".into())
|
assert!(
|
||||||
|
User::login(&pool, "admi".into(), "admin".into())
|
||||||
.await
|
.await
|
||||||
.is_err());
|
.is_err()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[sqlx::test]
|
#[sqlx::test]
|
||||||
@ -1007,9 +1011,11 @@ mod test {
|
|||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
let user = User::find_by_id(&pool, 1).await.unwrap();
|
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
|
.await
|
||||||
.is_err());
|
.is_err()
|
||||||
|
);
|
||||||
|
|
||||||
user.update_pw(&pool, "abc".into()).await;
|
user.update_pw(&pool, "abc".into()).await;
|
||||||
|
|
||||||
|
@ -3,13 +3,14 @@ use crate::model::{
|
|||||||
user::{AdminUser, UserWithDetails, VorstandUser},
|
user::{AdminUser, UserWithDetails, VorstandUser},
|
||||||
};
|
};
|
||||||
use rocket::{
|
use rocket::{
|
||||||
|
FromForm, Route, State,
|
||||||
form::Form,
|
form::Form,
|
||||||
get, post,
|
get, post,
|
||||||
request::FlashMessage,
|
request::FlashMessage,
|
||||||
response::{Flash, Redirect},
|
response::{Flash, Redirect},
|
||||||
routes, FromForm, Route, State,
|
routes,
|
||||||
};
|
};
|
||||||
use rocket_dyn_templates::{tera::Context, Template};
|
use rocket_dyn_templates::{Template, tera::Context};
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
#[get("/role")]
|
#[get("/role")]
|
||||||
|
@ -7,11 +7,11 @@ use crate::{
|
|||||||
mail::valid_mails,
|
mail::valid_mails,
|
||||||
role::Role,
|
role::Role,
|
||||||
user::{
|
user::{
|
||||||
|
AdminUser, AllowedToEditPaymentStatusUser, ManageUserUser, User, UserWithDetails,
|
||||||
|
UserWithMembershipPdf, UserWithRolesAndMembershipPdf, VorstandUser,
|
||||||
clubmember::ClubMemberUser, foerdernd::FoerderndUser, member::Member,
|
clubmember::ClubMemberUser, foerdernd::FoerderndUser, member::Member,
|
||||||
regular::RegularUser, scheckbuch::ScheckbuchUser, schnupperant::SchnupperantUser,
|
regular::RegularUser, scheckbuch::ScheckbuchUser, schnupperant::SchnupperantUser,
|
||||||
schnupperinterest::SchnupperInterestUser, unterstuetzend::UnterstuetzendUser,
|
schnupperinterest::SchnupperInterestUser, unterstuetzend::UnterstuetzendUser,
|
||||||
AdminUser, AllowedToEditPaymentStatusUser, ManageUserUser, User, UserWithDetails,
|
|
||||||
UserWithMembershipPdf, UserWithRolesAndMembershipPdf, VorstandUser,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
tera::Config,
|
tera::Config,
|
||||||
@ -19,6 +19,7 @@ use crate::{
|
|||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
use futures::future::join_all;
|
use futures::future::join_all;
|
||||||
use rocket::{
|
use rocket::{
|
||||||
|
FromForm, Request, Route, State,
|
||||||
form::Form,
|
form::Form,
|
||||||
fs::TempFile,
|
fs::TempFile,
|
||||||
get,
|
get,
|
||||||
@ -26,9 +27,9 @@ use rocket::{
|
|||||||
post,
|
post,
|
||||||
request::{FlashMessage, FromRequest, Outcome},
|
request::{FlashMessage, FromRequest, Outcome},
|
||||||
response::{Flash, Redirect},
|
response::{Flash, Redirect},
|
||||||
routes, FromForm, Request, Route, State,
|
routes,
|
||||||
};
|
};
|
||||||
use rocket_dyn_templates::{tera::Context, Template};
|
use rocket_dyn_templates::{Template, tera::Context};
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
// Custom request guard to extract the Referer header
|
// Custom request guard to extract the Referer header
|
||||||
@ -135,7 +136,7 @@ async fn view(
|
|||||||
if user.name == "Externe Steuerperson" {
|
if user.name == "Externe Steuerperson" {
|
||||||
return Err(Flash::error(
|
return Err(Flash::error(
|
||||||
Redirect::to("/admin/user"),
|
Redirect::to("/admin/user"),
|
||||||
"Diese besondere Person kannst du dir leider nicht anschauen, mein lieber neugieriger Ruderant!"
|
"Diese besondere Person kannst du dir leider nicht anschauen, mein lieber neugieriger Ruderant!",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use rocket::{
|
use rocket::{
|
||||||
|
FromForm, Request, Route, State,
|
||||||
form::Form,
|
form::Form,
|
||||||
get,
|
get,
|
||||||
http::{Cookie, CookieJar},
|
http::{Cookie, CookieJar},
|
||||||
@ -8,9 +9,8 @@ use rocket::{
|
|||||||
response::{Flash, Redirect},
|
response::{Flash, Redirect},
|
||||||
routes,
|
routes,
|
||||||
time::{Duration, OffsetDateTime},
|
time::{Duration, OffsetDateTime},
|
||||||
FromForm, Request, Route, State,
|
|
||||||
};
|
};
|
||||||
use rocket_dyn_templates::{context, tera, Template};
|
use rocket_dyn_templates::{Template, context, tera};
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
use crate::model::{
|
use crate::model::{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
|
|
||||||
use rocket::{
|
use rocket::{
|
||||||
|
Request, Route, State,
|
||||||
form::Form,
|
form::Form,
|
||||||
get,
|
get,
|
||||||
http::{Cookie, CookieJar},
|
http::{Cookie, CookieJar},
|
||||||
@ -9,9 +10,8 @@ use rocket::{
|
|||||||
response::{Flash, Redirect},
|
response::{Flash, Redirect},
|
||||||
routes,
|
routes,
|
||||||
time::{Duration, OffsetDateTime},
|
time::{Duration, OffsetDateTime},
|
||||||
Request, Route, State,
|
|
||||||
};
|
};
|
||||||
use rocket_dyn_templates::{context, Template};
|
use rocket_dyn_templates::{Template, context};
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
use tera::Context;
|
use tera::Context;
|
||||||
|
|
||||||
@ -585,7 +585,7 @@ mod test {
|
|||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
use crate::model::logbook::Logbook;
|
use crate::model::logbook::Logbook;
|
||||||
use crate::tera::{log::Boat, User};
|
use crate::tera::{User, log::Boat};
|
||||||
use crate::testdb;
|
use crate::testdb;
|
||||||
|
|
||||||
#[sqlx::test]
|
#[sqlx::test]
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
<summary class="px-3 cursor-pointer text-md font-bold text-primary-950 dark:text-white">
|
<summary class="px-3 cursor-pointer text-md font-bold text-primary-950 dark:text-white">
|
||||||
Neue Person hinzufügen
|
Neue Person hinzufügen
|
||||||
</summary>
|
</summary>
|
||||||
|
|
||||||
<div class="grid sm:grid-cols-3 gap-3 mt-3">
|
<div class="grid sm:grid-cols-3 gap-3 mt-3">
|
||||||
<button type="button"
|
<button type="button"
|
||||||
onclick="document.getElementById('add-clubuser').showModal()"
|
onclick="document.getElementById('add-clubuser').showModal()"
|
||||||
@ -19,8 +18,6 @@
|
|||||||
<button type="button"
|
<button type="button"
|
||||||
onclick="document.getElementById('add-schnupperkurs').showModal()"
|
onclick="document.getElementById('add-schnupperkurs').showModal()"
|
||||||
class="btn btn-dark">👨🎓 Schnupperkurs</button>
|
class="btn btn-dark">👨🎓 Schnupperkurs</button>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<dialog id="add-clubuser"
|
<dialog id="add-clubuser"
|
||||||
class="max-w-screen-sm w-full dark:bg-primary-900 dark:text-white rounded-md"
|
class="max-w-screen-sm w-full dark:bg-primary-900 dark:text-white rounded-md"
|
||||||
@ -67,7 +64,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|
||||||
<dialog id="add-scheckbuch"
|
<dialog id="add-scheckbuch"
|
||||||
class="max-w-screen-sm w-full dark:bg-primary-900 dark:text-white rounded-md"
|
class="max-w-screen-sm w-full dark:bg-primary-900 dark:text-white rounded-md"
|
||||||
onclick="document.getElementById('add-scheckbuch').close()">
|
onclick="document.getElementById('add-scheckbuch').close()">
|
||||||
@ -99,7 +95,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|
||||||
<dialog id="add-schnupperkurs"
|
<dialog id="add-schnupperkurs"
|
||||||
class="max-w-screen-sm w-full dark:bg-primary-900 dark:text-white rounded-md"
|
class="max-w-screen-sm w-full dark:bg-primary-900 dark:text-white rounded-md"
|
||||||
onclick="document.getElementById('add-schnupperkurs').close()">
|
onclick="document.getElementById('add-schnupperkurs').close()">
|
||||||
@ -122,7 +117,6 @@
|
|||||||
enctype="multipart/form-data"
|
enctype="multipart/form-data"
|
||||||
class="grid gap-3">
|
class="grid gap-3">
|
||||||
<h2 class="h3 mb-3">Neuer Schnupperant</h2>
|
<h2 class="h3 mb-3">Neuer Schnupperant</h2>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for="schnupper_type" class="text-sm text-gray-600 dark:text-gray-100">Typ</label>
|
<label for="schnupper_type" class="text-sm text-gray-600 dark:text-gray-100">Typ</label>
|
||||||
<select name="schnupper_type" id="schnupper_type" class="input rounded-md ">
|
<select name="schnupper_type" id="schnupper_type" class="input rounded-md ">
|
||||||
|
@ -385,9 +385,11 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if "paid" in user.roles %}
|
{% if "paid" in user.roles %}
|
||||||
✅ {% for key, value in member %}
|
✅
|
||||||
|
{% for key, value in member %}
|
||||||
{% if loop.first %}{{ key }}{% endif %}
|
{% if loop.first %}{{ key }}{% endif %}
|
||||||
{% endfor %} hat schon bezahlt
|
{% endfor %}
|
||||||
|
hat schon bezahlt
|
||||||
{% else %}
|
{% else %}
|
||||||
❌
|
❌
|
||||||
{% for key, value in member %}
|
{% for key, value in member %}
|
||||||
@ -406,7 +408,9 @@
|
|||||||
<div class="py-3">
|
<div class="py-3">
|
||||||
<ul class="list-disc ms-4">
|
<ul class="list-disc ms-4">
|
||||||
{% for activity in activities %}
|
{% for activity in activities %}
|
||||||
<li><strong>{{ activity.created_at | date(format="%d. %m. %Y") }}:</strong> <small>{{ activity.text }}</small></li>
|
<li>
|
||||||
|
<strong>{{ activity.created_at | date(format="%d. %m. %Y") }}:</strong> <small>{{ activity.text }}</small>
|
||||||
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li>Noch keine Aktivität... Stay tuned 😆</li>
|
<li>Noch keine Aktivität... Stay tuned 😆</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -202,9 +202,7 @@
|
|||||||
onclick="document.getElementById('change-{{ log.id }}').showModal()"
|
onclick="document.getElementById('change-{{ log.id }}').showModal()"
|
||||||
class="link link-black font-bold">{{ log.boat.name }}</a>
|
class="link link-black font-bold">{{ log.boat.name }}</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<strong class="text-black dark:text-white">
|
<strong class="text-black dark:text-white">{{ log.boat.name }}</strong>
|
||||||
{{ log.boat.name }}
|
|
||||||
</strong>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<small class="text-gray-600 dark:text-gray-100">({{ log.shipmaster_user.name -}}
|
<small class="text-gray-600 dark:text-gray-100">({{ log.shipmaster_user.name -}}
|
||||||
{% if log.shipmaster_only_steering %}
|
{% if log.shipmaster_only_steering %}
|
||||||
@ -286,8 +284,14 @@
|
|||||||
name="steering_person"
|
name="steering_person"
|
||||||
value="{{ log.steering_person }}" />
|
value="{{ log.steering_person }}" />
|
||||||
{{ macros::checkbox(label='Handgesteuert', name='shipmaster_only_steering', id=log.shipmaster_only_steering,checked=log.shipmaster_only_steering) }}
|
{{ macros::checkbox(label='Handgesteuert', name='shipmaster_only_steering', id=log.shipmaster_only_steering,checked=log.shipmaster_only_steering) }}
|
||||||
<input type="datetime-local" class="input rounded-md" name="departure" value="{{ log.departure }}" />
|
<input type="datetime-local"
|
||||||
<input type="datetime-local" class="input rounded-md" name="arrival" value="{{ log.arrival }}" />
|
class="input rounded-md"
|
||||||
|
name="departure"
|
||||||
|
value="{{ log.departure }}" />
|
||||||
|
<input type="datetime-local"
|
||||||
|
class="input rounded-md"
|
||||||
|
name="arrival"
|
||||||
|
value="{{ log.arrival }}" />
|
||||||
<input type="hidden" name="destination" value="{{ log.destination }}" />
|
<input type="hidden" name="destination" value="{{ log.destination }}" />
|
||||||
<input type="hidden" name="distance_in_km" value="{{ log.distance_in_km }}" />
|
<input type="hidden" name="distance_in_km" value="{{ log.distance_in_km }}" />
|
||||||
<input type="hidden" name="comments" value="{{ log.comments }}" />
|
<input type="hidden" name="comments" value="{{ log.comments }}" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user