diff --git a/seeds.sql b/seeds.sql index 39d2513..0f2f70b 100644 --- a/seeds.sql +++ b/seeds.sql @@ -3,7 +3,7 @@ INSERT INTO "role" (name) VALUES ('cox'); INSERT INTO "role" (name) VALUES ('scheckbuch'); INSERT INTO "role" (name) VALUES ('tech'); INSERT INTO "role" (name) VALUES ('Donau Linz'); -INSERT INTO "role" (name) VALUES ('planned_event'); +INSERT INTO "role" (name) VALUES ('manage_events'); INSERT INTO "role" (name) VALUES ('Rennrudern'); INSERT INTO "role" (name) VALUES ('paid'); INSERT INTO "role" (name) VALUES ('Vorstand'); diff --git a/src/model/user.rs b/src/model/user.rs index 026c1d3..4ce2087 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -1190,7 +1190,7 @@ impl<'r> FromRequest<'r> for EventUser { let db = req.rocket().state::().unwrap(); match User::from_request(req).await { Outcome::Success(user) => { - if user.has_role(db, "planned_event").await { + if user.has_role(db, "manage_events").await { Outcome::Success(EventUser(user)) } else { Outcome::Error((Status::Forbidden, LoginError::NotACox)) diff --git a/src/tera/admin/planned_event.rs b/src/tera/admin/event.rs similarity index 100% rename from src/tera/admin/planned_event.rs rename to src/tera/admin/event.rs diff --git a/src/tera/admin/mod.rs b/src/tera/admin/mod.rs index f32a2db..1690f45 100644 --- a/src/tera/admin/mod.rs +++ b/src/tera/admin/mod.rs @@ -9,9 +9,9 @@ use crate::{ }; pub mod boat; +pub mod event; pub mod mail; pub mod notification; -pub mod planned_event; pub mod schnupper; pub mod user; @@ -80,7 +80,7 @@ pub fn routes() -> Vec { ret.append(&mut boat::routes()); ret.append(&mut notification::routes()); ret.append(&mut mail::routes()); - ret.append(&mut planned_event::routes()); + ret.append(&mut event::routes()); ret.append(&mut routes![rss, show_rss, show_list, list]); ret } diff --git a/src/tera/planned.rs b/src/tera/planned.rs index 582cbd9..296d8f5 100644 --- a/src/tera/planned.rs +++ b/src/tera/planned.rs @@ -26,7 +26,7 @@ async fn index( let mut context = Context::new(); - if user.has_role(db, "cox").await || user.has_role(db, "planned_event").await { + if user.has_role(db, "cox").await || user.has_role(db, "manage_events").await { let triptypes = TripType::all(db).await; context.insert("trip_types", &triptypes); } diff --git a/staging-diff.sql b/staging-diff.sql index 6fb21fc..4303b65 100644 --- a/staging-diff.sql +++ b/staging-diff.sql @@ -1,3 +1,5 @@ +update role set name='manage_events' where id=19; + -- test user INSERT INTO user(name) VALUES('Marie'); INSERT INTO "user_role" (user_id, role_id) VALUES((SELECT id from user where name = 'Marie'),(SELECT id FROM role where name = 'Donau Linz')); diff --git a/templates/planned.html.tera b/templates/planned.html.tera index 4188098..8e94636 100644 --- a/templates/planned.html.tera +++ b/templates/planned.html.tera @@ -191,12 +191,12 @@ {# --- START List Rowers --- #} {% set amount_cur_rower = event.rower | length %} {% if event.max_people == 0 %} - {{ macros::box(header='Absage', bg='[#f43f5e]', participants=event.rower, trip_details_id=event.trip_details_id, allow_removing="event" in loggedin_user.roles) }} + {{ macros::box(header='Absage', bg='[#f43f5e]', participants=event.rower, trip_details_id=event.trip_details_id, allow_removing="manage_events" in loggedin_user.roles) }} {% else %} - {{ macros::box(participants=event.rower, empty_seats=event.max_people - amount_cur_rower, bg='primary-100', color='black', trip_details_id=event.trip_details_id, allow_removing="event" in loggedin_user.roles) }} + {{ macros::box(participants=event.rower, empty_seats=event.max_people - amount_cur_rower, bg='primary-100', color='black', trip_details_id=event.trip_details_id, allow_removing="manage_events" in loggedin_user.roles) }} {% endif %} {# --- END List Rowers --- #} - {% if "event" in loggedin_user.roles %} + {% if "manage_events" in loggedin_user.roles %}
{{ macros::input(label='Gast', class="input rounded-t", name='user_note', type='text', required=true) }} @@ -208,7 +208,7 @@ {% if event.allow_guests %}
Gäste willkommen!
{% endif %} - {% if "event" in loggedin_user.roles %} + {% if "manage_events" in loggedin_user.roles %} {# --- START Edit Form --- #}

Ausfahrt bearbeiten

@@ -389,9 +389,9 @@ {% endif %}
{# --- START Add Buttons --- #} - {% if "event" in loggedin_user.roles or "cox" in loggedin_user.roles %} -
- {% if "event" in loggedin_user.roles %} + {% if "manage_events" in loggedin_user.roles or "cox" in loggedin_user.roles %} +
+ {% if "manage_events" in loggedin_user.roles %}