Commit 6bfc27d5 authored by Robert Czechowski's avatar Robert Czechowski

Make server message configurable in config file

parent 59d1e42b
Pipeline #455 passed with stages
in 27 minutes and 5 seconds
......@@ -17,6 +17,7 @@ pub struct Config {
pub open_browser: Option<bool>,
pub cookie_signing_secret: Option<String>,
pub disable_results_page: Option<bool>,
pub server_message: Option<String>,
}
#[derive(StructOpt, Debug)]
......
......@@ -285,7 +285,7 @@ fn greet_personal<C>(req: &mut Request) -> IronResult<Response>
let config = req.get::<Read<SharedConfiguration>>().unwrap();
let (self_url, oauth_providers) = (config.self_url.clone(), config.oauth_providers.clone());
let (template, data) = {
let (template, mut data) = {
// hier ggf. Daten aus dem Request holen
let mutex = req.get::<Write<SharedDatabaseConnection<C>>>().unwrap();
let conn = mutex.lock().unwrap_or_else(|e| e.into_inner());
......@@ -294,6 +294,11 @@ fn greet_personal<C>(req: &mut Request) -> IronResult<Response>
core::index(&*conn, session_token, (self_url, oauth_providers))
};
/*if let Some(server_message) = &config.server_message {
data.insert("server_message".to_string(), to_json(&server_message));
}*/
config.server_message.as_ref().map(|sm| data.insert("server_message".to_string(), to_json(&sm)));
// Antwort erstellen und zurücksenden
let mut resp = Response::new();
resp.set_mut(Template::new(&template, data)).set_mut(status::Ok);
......@@ -370,12 +375,14 @@ fn contests<C>(req: &mut Request) -> IronResult<Response>
let config = req.get::<Read<SharedConfiguration>>().unwrap();
let (self_url, oauth_providers) = (config.self_url.clone(), config.oauth_providers.clone());
let (template, data) = with_conn![core::show_contests,
C,
req,
&session_token,
(self_url, oauth_providers),
core::ContestVisibility::All];
let (template, mut data) = with_conn![core::show_contests,
C,
req,
&session_token,
(self_url, oauth_providers),
core::ContestVisibility::All];
config.server_message.as_ref().map(|sm| data.insert("server_message".to_string(), to_json(&sm)));
let mut resp = Response::new();
resp.set_mut(Template::new(&template, data)).set_mut(status::Ok);
......@@ -389,12 +396,14 @@ fn opencontests<C>(req: &mut Request) -> IronResult<Response>
let config = req.get::<Read<SharedConfiguration>>().unwrap();
let (self_url, oauth_providers) = (config.self_url.clone(), config.oauth_providers.clone());
let (template, data) = with_conn![core::show_contests,
C,
req,
&session_token,
(self_url, oauth_providers),
core::ContestVisibility::Open];
let (template, mut data) = with_conn![core::show_contests,
C,
req,
&session_token,
(self_url, oauth_providers),
core::ContestVisibility::Open];
config.server_message.as_ref().map(|sm| data.insert("server_message".to_string(), to_json(&sm)));
let mut resp = Response::new();
resp.set_mut(Template::new(&template, data)).set_mut(status::Ok);
......@@ -408,12 +417,14 @@ fn currentcontests<C>(req: &mut Request) -> IronResult<Response>
let config = req.get::<Read<SharedConfiguration>>().unwrap();
let (self_url, oauth_providers) = (config.self_url.clone(), config.oauth_providers.clone());
let (template, data) = with_conn![core::show_contests,
C,
req,
&session_token,
(self_url, oauth_providers),
core::ContestVisibility::Current];
let (template, mut data) = with_conn![core::show_contests,
C,
req,
&session_token,
(self_url, oauth_providers),
core::ContestVisibility::Current];
config.server_message.as_ref().map(|sm| data.insert("server_message".to_string(), to_json(&sm)));
let mut resp = Response::new();
resp.set_mut(Template::new(&template, data)).set_mut(status::Ok);
......
......@@ -82,15 +82,16 @@
</div>
</div>
{{#if firstlogin }}{{else}}
<div class="columns alogin">
<div class="column is-8 is-offset-2">
<div class="notification is-danger">
<h3 class="title is-5">Achtung Testplattform!</h3>
<p>Diese Wettbewerbsplattform ist noch in der Erprobungsphase. Bitten benutzen Sie für die Teilnahme am Jugendwettbewerb Informatik 2020 <a href="https://wettbewerb.jwinf.de">die aktuelle Wettbewerbsplattform</a> unter <a href="https://wettbewerb.jwinf.de">wettbewerb.jwinf.de</a>.</p>
{{#if server_message}}
{{#if firstlogin }}{{else}}
<div class="columns alogin">
<div class="column is-8 is-offset-2">
<div class="notification is-danger">
{{{ server_message }}}
</div>
</div>
</div>
</div>
</div>
{{/if}}
{{/if}}
{{~> page}}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment