Commit 8a4af9c7 authored by Robert Czechowski's avatar Robert Czechowski
Browse files

Set removed contests to hidden (public = false) and only show public contests

parent 01a1be83
......@@ -152,6 +152,7 @@ pub fn show_contests<T: MedalConnection>(conn: &T, session_token: &str, visibili
duration: c.duration,
public: c.public,
tasks: Vec::new() })
.filter(|ci| ci.public)
.filter(|ci| ci.duration == 0 || visibility != ContestVisibility::Open)
.filter(|ci| ci.duration != 0 || visibility != ContestVisibility::Current)
.collect();
......@@ -309,7 +310,11 @@ pub fn show_contest_results<T: MedalConnection>(conn: &T, contest_id: i32, sessi
userresults[0] = format!("{}", summe);
groupresults.push((format!("{} {}", user.firstname.unwrap_or_default(), user.lastname.unwrap_or_else(|| "–".to_string())), user.id, userresults))
groupresults.push((format!("{} {}",
user.firstname.unwrap_or_default(),
user.lastname.unwrap_or_else(|| "–".to_string())),
user.id,
userresults))
}
results.push((format!("{}", group.name), group.id.unwrap_or(0), groupresults));
......
......@@ -48,6 +48,8 @@ pub trait MedalConnection {
fn get_groups(&self, session_id: i32) -> Vec<Group>;
fn get_groups_complete(&self, session_id: i32) -> Vec<Group>;
fn get_group_complete(&self, group_id: i32) -> Option<Group>;
fn reset_all_contest_visibilities(&self);
}
pub trait MedalObject<T: MedalConnection> {
......
......@@ -778,6 +778,8 @@ impl MedalConnection for Connection {
}
Some(group)
}
fn reset_all_contest_visibilities(&self) { self.execute("UPDATE contest SET public = ?1", &[&false]).unwrap(); }
}
impl MedalObject<Connection> for Task {
......
......@@ -762,6 +762,8 @@ impl MedalConnection for Connection {
}
Some(group)
}
fn reset_all_contest_visibilities(&self) { self.execute("UPDATE contest SET public = ?1", &[&false]).unwrap(); }
}
impl MedalObject<Connection> for Task {
......
......@@ -95,6 +95,7 @@ fn refresh_all_contests<C>(conn: &mut C)
where C: MedalConnection,
db_objects::Contest: db_conn::MedalObject<C>
{
conn.reset_all_contest_visibilities();
let v = get_all_contest_info("tasks/");
for mut contest_info in v {
......
name: "JwInf 2018 Runde 1"
participation_start: "2009-01-01T12:00:00+01:00"
participation_end: "2009-01-01T12:00:00+01:00"
duration_minutes: 45
public_listing: true
tasks:
"Aufgabe 1": "blub"
"Aufgabe 7": ["blub2", "blub2/", "blub2/index.html"]
"Aufgabe 3":
"blub/": {stars: 1}
"blub/index.html": {stars: 3}
"task3": {stars: 5}
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