allow-secretary-to-edit-boats #855
@ -1172,6 +1172,7 @@ special_user!(VorstandUser, +"Vorstand");
|
|||||||
special_user!(EventUser, +"manage_events");
|
special_user!(EventUser, +"manage_events");
|
||||||
special_user!(AllowedToEditPaymentStatusUser, +"kassier", +"admin");
|
special_user!(AllowedToEditPaymentStatusUser, +"kassier", +"admin");
|
||||||
special_user!(ManageUserUser, +"admin", +"schriftfuehrer");
|
special_user!(ManageUserUser, +"admin", +"schriftfuehrer");
|
||||||
|
special_user!(AdminAndSchriftfuehrerUser, +"admin", +"schriftfuehrer");
|
||||||
special_user!(AllowedToUpdateTripToAlwaysBeShownUser, +"admin");
|
special_user!(AllowedToUpdateTripToAlwaysBeShownUser, +"admin");
|
||||||
|
|
||||||
#[derive(FromRow, Serialize, Deserialize, Clone, Debug)]
|
#[derive(FromRow, Serialize, Deserialize, Clone, Debug)]
|
||||||
|
@ -2,7 +2,7 @@ use crate::model::{
|
|||||||
boat::{Boat, BoatToAdd, BoatToUpdate},
|
boat::{Boat, BoatToAdd, BoatToUpdate},
|
||||||
location::Location,
|
location::Location,
|
||||||
log::Log,
|
log::Log,
|
||||||
user::{AdminUser, User, UserWithDetails},
|
user::{AdminAndSchriftfuehrerUser, AdminUser, User, UserWithDetails},
|
||||||
};
|
};
|
||||||
use rocket::{
|
use rocket::{
|
||||||
form::Form,
|
form::Form,
|
||||||
@ -17,7 +17,7 @@ use sqlx::SqlitePool;
|
|||||||
#[get("/boat")]
|
#[get("/boat")]
|
||||||
async fn index(
|
async fn index(
|
||||||
db: &State<SqlitePool>,
|
db: &State<SqlitePool>,
|
||||||
admin: AdminUser,
|
admin: AdminAndSchriftfuehrerUser,
|
||||||
flash: Option<FlashMessage<'_>>,
|
flash: Option<FlashMessage<'_>>,
|
||||||
) -> Template {
|
) -> Template {
|
||||||
let boats = Boat::all(db).await;
|
let boats = Boat::all(db).await;
|
||||||
@ -40,7 +40,11 @@ async fn index(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/boat/<boat>/delete")]
|
#[get("/boat/<boat>/delete")]
|
||||||
async fn delete(db: &State<SqlitePool>, admin: AdminUser, boat: i32) -> Flash<Redirect> {
|
async fn delete(
|
||||||
|
db: &State<SqlitePool>,
|
||||||
|
admin: AdminAndSchriftfuehrerUser,
|
||||||
|
boat: i32,
|
||||||
|
) -> Flash<Redirect> {
|
||||||
let boat = Boat::find_by_id(db, boat).await;
|
let boat = Boat::find_by_id(db, boat).await;
|
||||||
Log::create(db, format!("{} deleted boat: {boat:?}", admin.user.name)).await;
|
Log::create(db, format!("{} deleted boat: {boat:?}", admin.user.name)).await;
|
||||||
|
|
||||||
@ -61,7 +65,7 @@ async fn update(
|
|||||||
db: &State<SqlitePool>,
|
db: &State<SqlitePool>,
|
||||||
data: Form<BoatToUpdate<'_>>,
|
data: Form<BoatToUpdate<'_>>,
|
||||||
boat_id: i32,
|
boat_id: i32,
|
||||||
_admin: AdminUser,
|
_admin: AdminAndSchriftfuehrerUser,
|
||||||
) -> Flash<Redirect> {
|
) -> Flash<Redirect> {
|
||||||
let boat = Boat::find_by_id(db, boat_id).await;
|
let boat = Boat::find_by_id(db, boat_id).await;
|
||||||
let Some(boat) = boat else {
|
let Some(boat) = boat else {
|
||||||
@ -78,7 +82,7 @@ async fn update(
|
|||||||
async fn create(
|
async fn create(
|
||||||
db: &State<SqlitePool>,
|
db: &State<SqlitePool>,
|
||||||
data: Form<BoatToAdd<'_>>,
|
data: Form<BoatToAdd<'_>>,
|
||||||
_admin: AdminUser,
|
_admin: AdminAndSchriftfuehrerUser,
|
||||||
) -> Flash<Redirect> {
|
) -> Flash<Redirect> {
|
||||||
match Boat::create(db, data.into_inner()).await {
|
match Boat::create(db, data.into_inner()).await {
|
||||||
Ok(_) => Flash::success(Redirect::to("/admin/boat"), "Boot hinzugefügt"),
|
Ok(_) => Flash::success(Redirect::to("/admin/boat"), "Boot hinzugefügt"),
|
||||||
|
@ -27,7 +27,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
logtype::LogType,
|
logtype::LogType,
|
||||||
trip::Trip,
|
trip::Trip,
|
||||||
user::{AdminUser, DonauLinzUser, User, UserWithDetails, VorstandUser},
|
user::{DonauLinzUser, User, UserWithDetails, VorstandUser},
|
||||||
},
|
},
|
||||||
tera::Config,
|
tera::Config,
|
||||||
};
|
};
|
||||||
@ -118,7 +118,7 @@ async fn show(db: &State<SqlitePool>, user: DonauLinzUser) -> Template {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/show?<year>", rank = 2)]
|
#[get("/show?<year>", rank = 2)]
|
||||||
async fn show_for_year(db: &State<SqlitePool>, user: AdminUser, year: i32) -> Template {
|
async fn show_for_year(db: &State<SqlitePool>, user: VorstandUser, year: i32) -> Template {
|
||||||
let logs = Logbook::completed_in_year(db, year).await;
|
let logs = Logbook::completed_in_year(db, year).await;
|
||||||
|
|
||||||
Template::render(
|
Template::render(
|
||||||
|
@ -128,7 +128,7 @@ function setChoiceByLabel(choicesInstance, label) {
|
|||||||
<a href="/admin/user"
|
<a href="/admin/user"
|
||||||
class="block w-100 py-2 hover:text-primary-600 border-t">Userverwaltung</a>
|
class="block w-100 py-2 hover:text-primary-600 border-t">Userverwaltung</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if "admin" in loggedin_user.roles %}
|
{% if "admin" in loggedin_user.roles or "schriftfuehrer" in loggedin_user.roles %}
|
||||||
<a href="/admin/boat"
|
<a href="/admin/boat"
|
||||||
class="block w-100 py-2 hover:text-primary-600 border-t">Boote</a>
|
class="block w-100 py-2 hover:text-primary-600 border-t">Boote</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -421,6 +421,17 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if "schriftfuehrer" in loggedin_user.roles %}
|
||||||
|
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"
|
||||||
|
role="alert">
|
||||||
|
<h2 class="h2">Schriftführer</h2>
|
||||||
|
<ul class="list-none ms-2 divide-y divide-gray-200 dark:divide-primary-600">
|
||||||
|
<li class="py-1">
|
||||||
|
<a href="/admin/boat" class="block w-100 py-2 hover:text-primary-600">Boote</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% if "admin" in loggedin_user.roles %}
|
{% if "admin" in loggedin_user.roles %}
|
||||||
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"
|
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"
|
||||||
role="alert">
|
role="alert">
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<div class="max-w-screen-lg w-full">
|
<div class="max-w-screen-lg w-full">
|
||||||
<h1 class="h1">
|
<h1 class="h1">
|
||||||
Logbuch
|
Logbuch
|
||||||
{% if loggedin_user and "admin" in loggedin_user.roles %}
|
{% if loggedin_user and "Vorstand" in loggedin_user.roles %}
|
||||||
<select id="yearSelect"
|
<select id="yearSelect"
|
||||||
onchange="changeYear()"
|
onchange="changeYear()"
|
||||||
style="background: transparent;
|
style="background: transparent;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user