Commit e5785c75 authored by Robert Czechowski's avatar Robert Czechowski
Browse files

Show time until contest opens. Fixes #51

parent 84e321e4
Pipeline #374 passed with stages
in 14 minutes and 48 seconds
...@@ -248,6 +248,17 @@ pub fn show_contest<T: MedalConnection>(conn: &T, contest_id: i32, session_token ...@@ -248,6 +248,17 @@ pub fn show_contest<T: MedalConnection>(conn: &T, contest_id: i32, session_token
} }
} }
if let Some(start_date) = c.start {
if time::get_time() < start_date {
data.insert("can_start".to_string(), to_json(&false));
let time_until = start_date - time::get_time();
data.insert("time_until_d".to_string(), to_json(&(time_until.num_days())));
data.insert("time_until_h".to_string(), to_json(&(time_until.num_hours() % 24)));
data.insert("time_until_m".to_string(), to_json(&(time_until.num_minutes() % 60)));
}
}
// This only checks if a query string is existent, so any query string will // This only checks if a query string is existent, so any query string will
// lead to the assumption that a base page is requested. This is usefull to // lead to the assumption that a base page is requested. This is usefull to
// disable caching (via random token) but should be changed if query string // disable caching (via random token) but should be changed if query string
......
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
{{#if participation_start_date}} {{#if participation_start_date}}
<p> <p>
{{#if duration}} {{#if duration}}
{{#if time_left}} {{#if time_left}}
Verbleibenden Zeit: {{time_left}} Verbleibenden Zeit: {{time_left}}
{{else}} {{else}}
Die Zeit ist abgelaufen. Du kannst nun die Aufgaben nicht mehr öffnen. Die Zeit ist abgelaufen. Du kannst nun die Aufgaben nicht mehr öffnen.
...@@ -150,9 +150,13 @@ ...@@ -150,9 +150,13 @@
{{/if}} {{/if}}
{{else}} {{else}}
<p>Du kannst diesen Wettbewerb im Moment nicht starten.</p> <p>Du kannst diesen Wettbewerb im Moment nicht starten.</p>
{{#if logged_in}} {{#if time_until_d}}
{{else}} <p>Der Wettbewerb wird geöffnet in: {{ time_until_d }} Tagen, {{ time_until_h }} Stunden, {{ time_until_m }} Minuten.
<p>Möglicherweise musst du dich zunächst <a href="/login">einloggen</a>.</p> {{else}}
{{#if logged_in}}
{{else}}
<p>Möglicherweise musst du dich zunächst <a href="/login">einloggen</a>.</p>
{{/if}}
{{/if}} {{/if}}
{{/if}} {{/if}}
{{/if}} {{/if}}
......
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