Commit 4cde6d98 authored by Robert Czechowski's avatar Robert Czechowski
Browse files

Add page that shows open-for-all contests only

parent 0b15defc
......@@ -121,7 +121,7 @@ pub fn debug_create_session<T: MedalConnection>(conn: &T, session_token: Option<
}
}
pub fn show_contests<T: MedalConnection>(conn: &T) -> MedalValue {
pub fn show_contests<T: MedalConnection>(conn: &T, only_open: bool) -> MedalValue {
let mut data = json_val::Map::new();
let v: Vec<ContestInfo> = conn.get_contest_list()
......@@ -133,6 +133,7 @@ pub fn show_contests<T: MedalConnection>(conn: &T) -> MedalValue {
duration: c.duration,
public: c.public,
tasks: Vec::new() })
.filter(|ci| ci.duration == 0 || only_open == false)
.collect();
data.insert("contest".to_string(), to_json(&v));
......
......@@ -329,7 +329,16 @@ fn debug_create_session<C>(req: &mut Request) -> IronResult<Response>
fn contests<C>(req: &mut Request) -> IronResult<Response>
where C: MedalConnection + std::marker::Send + 'static {
let (template, data) = with_conn![core::show_contests, C, req,];
let (template, data) = with_conn![core::show_contests, C, req, false];
let mut resp = Response::new();
resp.set_mut(Template::new(&template, data)).set_mut(status::Ok);
Ok(resp)
}
fn opencontests<C>(req: &mut Request) -> IronResult<Response>
where C: MedalConnection + std::marker::Send + 'static {
let (template, data) = with_conn![core::show_contests, C, req, true];
let mut resp = Response::new();
resp.set_mut(Template::new(&template, data)).set_mut(status::Ok);
......@@ -887,6 +896,7 @@ pub fn start_server<C>(conn: C, config: Config) -> iron::error::HttpResult<iron:
let router = router!(
greet: get "/" => greet_personal::<C>,
contests: get "/contest/" => contests::<C>,
contestsopen: get "/contest/open" => opencontests::<C>,
contest: get "/contest/:contestid" => contest::<C>,
contestresults: get "/contest/:contestid/result/" => contestresults::<C>,
contest_post: post "/contest/:contestid" => contest_post::<C>,
......
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