Browse Source

FIX: Show active event on all pages

master
Keanu D?lle 11 months ago
parent
commit
a22a417639
  1. 5
      src/app_settings/eventselector.rs
  2. 6
      src/app_settings/model.rs
  3. 8
      src/app_settings/setting_page.rs

5
src/app_settings/eventselector.rs

@ -6,6 +6,7 @@ use crate::database::event_selector::{get_events, add_event, get_active_events};
use crate::helper::settings::Settings;
use rocket::State;
use rocket::request::Form;
use crate::helper::uuid_option_to_string::uuid_option_to_string;
#[get("/portal/einsatzauswahl")]
pub fn eventselector(cookie: SessionCookie, settings: State<Settings>) -> Template {
@ -18,7 +19,7 @@ pub fn eventselector(cookie: SessionCookie, settings: State<Settings>) -> Templa
username: cookie.user.username,
events,
active_events: get_active_events(&settings),
active_event: cookie.active_event
active_event: uuid_option_to_string(cookie.active_event)
};
Template::render("event_selector", &context)
}
@ -36,7 +37,7 @@ pub fn eventselector_add_new(cookie: SessionCookie, settings: State<Settings>, n
username: cookie.user.username,
events,
active_events: get_active_events(&settings),
active_event: cookie.active_event
active_event: uuid_option_to_string(cookie.active_event)
};
Template::render("event_selector", &context)
}

6
src/app_settings/model.rs

@ -8,7 +8,8 @@ pub struct SettingsTemplate {
pub header: Header,
pub events: Vec<Event>,
pub username : String,
pub active_events: Vec<Event>
pub active_events: Vec<Event>,
pub active_event: String,
}
#[derive(Serialize)]
@ -19,6 +20,7 @@ pub struct UserSettingsTemplate {
pub alerts: Vec<Alert>,
pub events: Vec<Event>,
pub active_events: Vec<Event>,
pub active_event: String,
pub admin_view: bool,
}
@ -38,7 +40,7 @@ pub struct EventSelectionTemplate {
pub username : String,
pub events: Vec<Event>,
pub active_events: Vec<Event>,
pub active_event: Option<uuid::Uuid>,
pub active_event: String,
}
#[derive(Serialize)]

8
src/app_settings/setting_page.rs

@ -11,6 +11,7 @@ use crate::helper::template_models::errors::Alert;
use crate::database::event_selector::{get_events, get_active_events};
use crate::helper::api_error::{ApiError, ApiResult};
use rocket_contrib::json::Json;
use crate::helper::uuid_option_to_string::uuid_option_to_string;
#[get("/portal/einstellungen")]
pub fn settings(cookie: SessionCookie, settings: State<Settings>) -> Template {
@ -21,7 +22,8 @@ pub fn settings(cookie: SessionCookie, settings: State<Settings>) -> Template {
},
events: get_events(&settings),
username: cookie.user.username,
active_events: get_active_events(&settings)
active_events: get_active_events(&settings),
active_event: uuid_option_to_string(cookie.active_event)
};
Template::render("settings", &context)
}
@ -40,7 +42,8 @@ pub fn settings_users(cookie: SessionCookie, settings: State<Settings>) -> Templ
alerts: vec![],
events: get_events(&settings),
admin_view: cookie.user.is_admin,
active_events: get_active_events(&settings)
active_events: get_active_events(&settings),
active_event: uuid_option_to_string(cookie.active_event)
};
Template::render("settings-users", &context)
}
@ -76,6 +79,7 @@ pub fn settings_users_post(cookie: SessionCookie, settings: State<Settings>, use
alerts,
events: get_events(&settings),
active_events: get_active_events(&settings),
active_event: uuid_option_to_string(cookie.active_event),
admin_view: cookie.user.is_admin
};
Template::render("settings-users", &context)

Loading…
Cancel
Save