Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bwinf
medal
Commits
b826f86a
Commit
b826f86a
authored
Sep 26, 2019
by
Robert Czechowski
Browse files
Add page that shows current time-limited contests only
parent
4cde6d98
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/core.rs
View file @
b826f86a
...
...
@@ -121,7 +121,14 @@ pub fn debug_create_session<T: MedalConnection>(conn: &T, session_token: Option<
}
}
pub
fn
show_contests
<
T
:
MedalConnection
>
(
conn
:
&
T
,
only_open
:
bool
)
->
MedalValue
{
#[derive(PartialEq,
Eq)]
pub
enum
ContestVisibility
{
All
,
Open
,
Current
}
pub
fn
show_contests
<
T
:
MedalConnection
>
(
conn
:
&
T
,
visibility
:
ContestVisibility
)
->
MedalValue
{
let
mut
data
=
json_val
::
Map
::
new
();
let
v
:
Vec
<
ContestInfo
>
=
conn
.get_contest_list
()
...
...
@@ -133,7 +140,8 @@ pub fn show_contests<T: MedalConnection>(conn: &T, only_open: bool) -> MedalValu
duration
:
c
.duration
,
public
:
c
.public
,
tasks
:
Vec
::
new
()
})
.filter
(|
ci
|
ci
.duration
==
0
||
only_open
==
false
)
.filter
(|
ci
|
ci
.duration
==
0
||
visibility
!=
ContestVisibility
::
Open
)
.filter
(|
ci
|
ci
.duration
!=
0
||
visibility
!=
ContestVisibility
::
Current
)
.collect
();
data
.insert
(
"contest"
.to_string
(),
to_json
(
&
v
));
...
...
src/webfw_iron.rs
View file @
b826f86a
...
...
@@ -329,7 +329,7 @@ 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
,
false
];
let
(
template
,
data
)
=
with_conn!
[
core
::
show_contests
,
C
,
req
,
core
::
ContestVisibility
::
All
];
let
mut
resp
=
Response
::
new
();
resp
.set_mut
(
Template
::
new
(
&
template
,
data
))
.set_mut
(
status
::
Ok
);
...
...
@@ -338,7 +338,16 @@ fn contests<C>(req: &mut Request) -> IronResult<Response>
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
(
template
,
data
)
=
with_conn!
[
core
::
show_contests
,
C
,
req
,
core
::
ContestVisibility
::
Open
];
let
mut
resp
=
Response
::
new
();
resp
.set_mut
(
Template
::
new
(
&
template
,
data
))
.set_mut
(
status
::
Ok
);
Ok
(
resp
)
}
fn
currentcontests
<
C
>
(
req
:
&
mut
Request
)
->
IronResult
<
Response
>
where
C
:
MedalConnection
+
std
::
marker
::
Send
+
'static
{
let
(
template
,
data
)
=
with_conn!
[
core
::
show_contests
,
C
,
req
,
core
::
ContestVisibility
::
Current
];
let
mut
resp
=
Response
::
new
();
resp
.set_mut
(
Template
::
new
(
&
template
,
data
))
.set_mut
(
status
::
Ok
);
...
...
@@ -896,7 +905,8 @@ 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
>
,
contestsopen
:
get
"/contest/open/"
=>
opencontests
::
<
C
>
,
contestscurrent
:
get
"/contest/current/"
=>
currentcontests
::
<
C
>
,
contest
:
get
"/contest/:contestid"
=>
contest
::
<
C
>
,
contestresults
:
get
"/contest/:contestid/result/"
=>
contestresults
::
<
C
>
,
contest_post
:
post
"/contest/:contestid"
=>
contest_post
::
<
C
>
,
...
...
templates/jwinf/index.hbs
View file @
b826f86a
...
...
@@ -79,7 +79,7 @@
<div
class=
"columns"
>
<div
class=
"column is-4 is-offset-2"
>
<a
href=
"
https://wettbewerb.jwinf.de/contents/4210%252F4207?sell=1
"
>
<a
href=
"
/contest/open/
"
>
<div
class=
"notification"
style=
"background-color:#e5fae5"
>
<h3
class=
"title is-4"
>
Trainingsaufgaben
</h3>
<h4
class=
"subtitle is-5"
>
Zum Ausprobieren und Üben
</h4>
...
...
@@ -89,12 +89,12 @@
</a>
</div>
<div
class=
"column is-4 is-offset-0"
>
<a
href=
"/contest/
3
"
>
<a
href=
"/contest/
current/
"
>
<div
class=
"notification"
style=
"background-color:#e5f0f8"
>
<h3
class=
"title is-4"
>
Jugendwettbewerb Informatik
</h3>
<h4
class=
"subtitle is-5"
>
Probew
ettbewerb
</h4>
<h4
class=
"subtitle is-5"
>
Aktuelle W
ettbewerb
e
</h4>
<img
src=
"/static/images/white.png"
style=
"width:50%; margin:25px 25%"
>
Zu den Wettbewerb
saufgab
en …
Zu den Wettbewerben …
</div>
</a>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment