Commit 4e16dca1 authored by Robert Czechowski's avatar Robert Czechowski

Allow starting an empty contest if it has a secret (useful for empty...

Allow starting an empty contest if it has a secret (useful for empty participation for qualification in other contests)
parent 2155780e
......@@ -357,8 +357,9 @@ pub fn show_contest<T: MedalConnection>(conn: &T, contest_id: i32, session_token
return Err(MedalError::AccessDenied);
}
let has_secret = contest.secret.is_some();
let mut require_secret = false;
if contest.secret.is_some() {
if has_secret {
data.insert("secret_field".to_string(), to_json(&true));
if secret.is_some() {
......@@ -371,18 +372,19 @@ pub fn show_contest<T: MedalConnection>(conn: &T, contest_id: i32, session_token
let constraints = check_contest_constraints(&session, &contest);
let is_qualified = check_contest_qualification(conn, &session, &contest).unwrap_or(true);
let has_tasks = contest.taskgroups.len() > 0;
let can_start = constraints.contest_running
&& constraints.grade_matching
&& is_qualified
&& (has_tasks || has_secret)
&& (session.is_logged_in() || contest.secret.is_some() && !contest.requires_login.unwrap_or(false));
let has_duration = contest.duration > 0;
data.insert("constraints".to_string(), to_json(&constraints));
data.insert("is_qualified".to_string(), to_json(&is_qualified));
data.insert("has_duration".to_string(), to_json(&has_duration));
data.insert("can_start".to_string(), to_json(&can_start));
let has_tasks = contest.taskgroups.len() > 0;
data.insert("has_tasks".to_string(), to_json(&has_tasks));
data.insert("no_tasks".to_string(), to_json(&!has_tasks));
......
......@@ -40,7 +40,6 @@
<div class="column is-6 is-offset-3">
<div style="min-height: 400px; margin-bottom:100px;" class="content">
{{#if has_tasks}}
{{#if is_started}}
<p>
{{#if has_duration}}
......@@ -120,20 +119,15 @@
Der Wettbewerb kann nach dem Starten nicht mehr pausiert werden!
</p>
{{/if}}
{{#if time_until_end}}
<p>Der Wettbewerb kann noch gestartet werden: {{ time_until_end.0 }} Tage, {{ time_until_end.1 }} Stunden, {{ time_until_end.2 }} Minuten.</p>
{{/if}}
{{else}}
<p>Du kannst diesen Wettbewerb nicht starten.</p>
{{#if has_tasks}}
<p>Du kannst diesen Wettbewerb nicht starten.</p>
{{/if}}
{{#if constraints.contest_over}}
<p>Der Wettbewerb ist bereits beendet.</p>
{{else}}
{{#if constraints.contest_not_begun}}
<p>Der Wettbewerb hat noch nicht begonnen.</p>
{{#if time_until_start}}
<p>Der Wettbewerb wird geöffnet in: {{ time_until_start.0 }} Tagen, {{ time_until_start.1 }} Stunden, {{ time_until_start.2 }} Minuten.</p>
{{/if}}
{{else}}
{{#if logged_in}}
{{#if is_qualified}}
......@@ -153,21 +147,18 @@
{{/if}}
{{/if}}
{{/if}}
{{/if}}
{{else}}
{{#if time_until_start}}
<p>Der Wettbewerb beginnt in: {{ time_until_start.0 }} Tagen, {{ time_until_start.1 }} Stunden, {{ time_until_start.2 }} Minuten.</p>
{{/if}}
{{#if time_until_end}}
<p>Der Wettbewerb läuft noch: {{ time_until_end.0 }} Tage, {{ time_until_end.1 }} Stunden, {{ time_until_end.2 }} Minuten.</p>
{{else}}
{{#if time_until_end}}
<p>Der Wettbewerb läuft noch: {{ time_until_end.0 }} Tage, {{ time_until_end.1 }} Stunden, {{ time_until_end.2 }} Minuten.</p>
{{/if}}
{{/if}}
{{/if}}
</div>
</div>
{{#if not_bare}}
</div>
......
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