Compare commits

...

2 Commits

Author SHA1 Message Date
76c8456380 Merge pull request 'rename role to manage_events' (#555) from reanme-to-event into staging
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m43s
CI/CD Pipeline / deploy-staging (push) Successful in 7m26s
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #555
2024-05-28 10:56:04 +02:00
c0d766832e rename role to manage_events
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m44s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
2024-05-28 10:46:21 +02:00
7 changed files with 16 additions and 14 deletions

View File

@ -3,7 +3,7 @@ INSERT INTO "role" (name) VALUES ('cox');
INSERT INTO "role" (name) VALUES ('scheckbuch'); INSERT INTO "role" (name) VALUES ('scheckbuch');
INSERT INTO "role" (name) VALUES ('tech'); INSERT INTO "role" (name) VALUES ('tech');
INSERT INTO "role" (name) VALUES ('Donau Linz'); 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 ('Rennrudern');
INSERT INTO "role" (name) VALUES ('paid'); INSERT INTO "role" (name) VALUES ('paid');
INSERT INTO "role" (name) VALUES ('Vorstand'); 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(); let db = req.rocket().state::<SqlitePool>().unwrap();
match User::from_request(req).await { match User::from_request(req).await {
Outcome::Success(user) => { Outcome::Success(user) => {
if user.has_role(db, "planned_event").await { if user.has_role(db, "manage_events").await {
Outcome::Success(EventUser(user)) Outcome::Success(EventUser(user))
} else { } else {
Outcome::Error((Status::Forbidden, LoginError::NotACox)) Outcome::Error((Status::Forbidden, LoginError::NotACox))

View File

@ -9,9 +9,9 @@ use crate::{
}; };
pub mod boat; pub mod boat;
pub mod event;
pub mod mail; pub mod mail;
pub mod notification; pub mod notification;
pub mod planned_event;
pub mod schnupper; pub mod schnupper;
pub mod user; pub mod user;
@ -80,7 +80,7 @@ pub fn routes() -> Vec<Route> {
ret.append(&mut boat::routes()); ret.append(&mut boat::routes());
ret.append(&mut notification::routes()); ret.append(&mut notification::routes());
ret.append(&mut mail::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.append(&mut routes![rss, show_rss, show_list, list]);
ret ret
} }

View File

@ -26,7 +26,7 @@ async fn index(
let mut context = Context::new(); 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; let triptypes = TripType::all(db).await;
context.insert("trip_types", &triptypes); context.insert("trip_types", &triptypes);
} }

View File

@ -1,3 +1,5 @@
update role set name='manage_events' where id=19;
-- test user -- test user
INSERT INTO user(name) VALUES('Marie'); 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')); 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 --- #} {# --- START List Rowers --- #}
{% set amount_cur_rower = event.rower | length %} {% set amount_cur_rower = event.rower | length %}
{% if event.max_people == 0 %} {% 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 %} {% 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 %} {% endif %}
{# --- END List Rowers --- #} {# --- END List Rowers --- #}
{% if "event" in loggedin_user.roles %} {% if "manage_events" in loggedin_user.roles %}
<form action="/planned/join/{{ event.trip_details_id }}" <form action="/planned/join/{{ event.trip_details_id }}"
method="get" /> method="get" />
{{ macros::input(label='Gast', class="input rounded-t", name='user_note', type='text', required=true) }} {{ macros::input(label='Gast', class="input rounded-t", name='user_note', type='text', required=true) }}
@ -208,7 +208,7 @@
{% if event.allow_guests %} {% if event.allow_guests %}
<div class="text-primary-900 bg-primary-50 text-center p-1 mb-4">Gäste willkommen!</div> <div class="text-primary-900 bg-primary-50 text-center p-1 mb-4">Gäste willkommen!</div>
{% endif %} {% endif %}
{% if "event" in loggedin_user.roles %} {% if "manage_events" in loggedin_user.roles %}
{# --- START Edit Form --- #} {# --- START Edit Form --- #}
<div class="bg-gray-100 dark:bg-primary-900 p-3 mt-4 rounded-md"> <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> <h3 class="text-primary-950 dark:text-white font-bold uppercase tracking-wide mb-2">Ausfahrt bearbeiten</h3>
@ -389,9 +389,9 @@
{% endif %} {% endif %}
</div> </div>
{# --- START Add Buttons --- #} {# --- START Add Buttons --- #}
{% if "event" in loggedin_user.roles or "cox" in loggedin_user.roles %} {% if "manage_events" 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"> <div class="grid {% if "manage_events" in loggedin_user.roles %}grid-cols-2{% endif %} text-center">
{% if "event" in loggedin_user.roles %} {% if "manage_events" in loggedin_user.roles %}
<a href="#" <a href="#"
data-sidebar="true" data-sidebar="true"
data-trigger="sidebar" data-trigger="sidebar"
@ -405,7 +405,7 @@
{% endif %} {% endif %}
{% if "cox" in loggedin_user.roles %} {% 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 <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 rounded-br-md
{% else %} {% else %}
rounded-b-md rounded-b-md
@ -425,7 +425,7 @@
{% if "cox" in loggedin_user.roles %} {% if "cox" in loggedin_user.roles %}
{% include "forms/trip" %} {% include "forms/trip" %}
{% endif %} {% endif %}
{% if "event" in loggedin_user.roles %} {% if "manage_events" in loggedin_user.roles %}
{% include "forms/event" %} {% include "forms/event" %}
{% endif %} {% endif %}
{% endblock content %} {% endblock content %}