Merge pull request 'allow vorstand to edit boats' (#860) from allow-secretary-to-edit-boats 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: #860
This commit is contained in:
philipp 2025-02-11 09:23:28 +01:00
commit 32800b1897
4 changed files with 6 additions and 22 deletions

View File

@ -1172,7 +1172,6 @@ special_user!(VorstandUser, +"Vorstand");
special_user!(EventUser, +"manage_events");
special_user!(AllowedToEditPaymentStatusUser, +"kassier", +"admin");
special_user!(ManageUserUser, +"admin", +"schriftfuehrer");
special_user!(AdminAndSchriftfuehrerUser, +"admin", +"schriftfuehrer");
special_user!(AllowedToUpdateTripToAlwaysBeShownUser, +"admin");
#[derive(FromRow, Serialize, Deserialize, Clone, Debug)]

View File

@ -2,7 +2,7 @@ use crate::model::{
boat::{Boat, BoatToAdd, BoatToUpdate},
location::Location,
log::Log,
user::{AdminAndSchriftfuehrerUser, AdminUser, User, UserWithDetails},
user::{User, UserWithDetails, VorstandUser},
};
use rocket::{
form::Form,
@ -17,7 +17,7 @@ use sqlx::SqlitePool;
#[get("/boat")]
async fn index(
db: &State<SqlitePool>,
admin: AdminAndSchriftfuehrerUser,
admin: VorstandUser,
flash: Option<FlashMessage<'_>>,
) -> Template {
let boats = Boat::all(db).await;
@ -40,11 +40,7 @@ async fn index(
}
#[get("/boat/<boat>/delete")]
async fn delete(
db: &State<SqlitePool>,
admin: AdminAndSchriftfuehrerUser,
boat: i32,
) -> Flash<Redirect> {
async fn delete(db: &State<SqlitePool>, admin: VorstandUser, boat: i32) -> Flash<Redirect> {
let boat = Boat::find_by_id(db, boat).await;
Log::create(db, format!("{} deleted boat: {boat:?}", admin.user.name)).await;
@ -65,7 +61,7 @@ async fn update(
db: &State<SqlitePool>,
data: Form<BoatToUpdate<'_>>,
boat_id: i32,
_admin: AdminAndSchriftfuehrerUser,
_admin: VorstandUser,
) -> Flash<Redirect> {
let boat = Boat::find_by_id(db, boat_id).await;
let Some(boat) = boat else {
@ -82,7 +78,7 @@ async fn update(
async fn create(
db: &State<SqlitePool>,
data: Form<BoatToAdd<'_>>,
_admin: AdminAndSchriftfuehrerUser,
_admin: VorstandUser,
) -> Flash<Redirect> {
match Boat::create(db, data.into_inner()).await {
Ok(_) => Flash::success(Redirect::to("/admin/boat"), "Boot hinzugefügt"),

View File

@ -128,7 +128,7 @@ function setChoiceByLabel(choicesInstance, label) {
<a href="/admin/user"
class="block w-100 py-2 hover:text-primary-600 border-t">Userverwaltung</a>
{% endif %}
{% if "admin" in loggedin_user.roles or "schriftfuehrer" in loggedin_user.roles %}
{% if "admin" in loggedin_user.roles or "Vorstand" in loggedin_user.roles %}
<a href="/admin/boat"
class="block w-100 py-2 hover:text-primary-600 border-t">Boote</a>
{% endif %}

View File

@ -418,14 +418,6 @@
<a href="/board/achievement"
class="block w-100 py-2 hover:text-primary-600">Abzeichen</a>
</li>
</ul>
</div>
{% 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>
@ -437,9 +429,6 @@
role="alert">
<h2 class="h2">Admin</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>
<li class="py-1">
<a href="/admin/user" class="block w-100 py-2 hover:text-primary-600">User</a>
</li>