rename role to manage_events #556

Merged
philipp merged 1 commits from reanme-to-event into main 2024-05-28 11:18:51 +02:00
7 changed files with 16 additions and 14 deletions
Showing only changes of commit c0d766832e - Show all commits

View File

@ -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');

View File

@ -1190,7 +1190,7 @@ impl<'r> FromRequest<'r> for EventUser {
let db = req.rocket().state::<SqlitePool>().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))

View File

@ -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<Route> {
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
}

View File

@ -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);
}

View File

@ -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'));

View File

@ -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 %}
<form action="/planned/join/{{ event.trip_details_id }}"
method="get" />
{{ macros::input(label='Gast', class="input rounded-t", name='user_note', type='text', required=true) }}
@ -208,7 +208,7 @@
{% if event.allow_guests %}
<div class="text-primary-900 bg-primary-50 text-center p-1 mb-4">Gäste willkommen!</div>
{% endif %}
{% if "event" in loggedin_user.roles %}
{% if "manage_events" in loggedin_user.roles %}
{# --- START Edit Form --- #}
<div class="bg-gray-100 dark:bg-primary-900 p-3 mt-4 rounded-md">
<h3 class="text-primary-950 dark:text-white font-bold uppercase tracking-wide mb-2">Ausfahrt bearbeiten</h3>
@ -389,9 +389,9 @@
{% endif %}
</div>
{# --- START Add Buttons --- #}
{% if "event" in loggedin_user.roles or "cox" in loggedin_user.roles %}
<div class="grid {% if "event" in loggedin_user.roles %}grid-cols-2{% endif %} text-center">
{% if "event" in loggedin_user.roles %}
{% if "manage_events" in loggedin_user.roles or "cox" in loggedin_user.roles %}
<div class="grid {% if "manage_events" in loggedin_user.roles %}grid-cols-2{% endif %} text-center">
{% if "manage_events" in loggedin_user.roles %}
<a href="#"
data-sidebar="true"
data-trigger="sidebar"
@ -405,7 +405,7 @@
{% endif %}
{% if "cox" in loggedin_user.roles %}
<a href="#" data-sidebar="true" data-trigger="sidebar" data-header="<strong>Ausfahrt</strong> am {{ day.day| date(format='%d.%m.%Y') }} erstellen" data-day="{{ day.day }}" data-body="#sidebarForm" class="relative inline-block w-full py-2 text-primary-900 hover:text-primary-950 dark:bg-primary-600 dark:text-white dark:hover:bg-primary-500 dark:hover:text-white focus:text-primary-950 text-sm font-semibold bg-gray-100 hover:bg-gray-200 focus:bg-gray-200
{% if "event" in loggedin_user.roles %}
{% if "manage_events" in loggedin_user.roles %}
rounded-br-md
{% else %}
rounded-b-md
@ -425,7 +425,7 @@
{% if "cox" in loggedin_user.roles %}
{% include "forms/trip" %}
{% endif %}
{% if "event" in loggedin_user.roles %}
{% if "manage_events" in loggedin_user.roles %}
{% include "forms/event" %}
{% endif %}
{% endblock content %}