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
42a269ae
Commit
42a269ae
authored
Jul 07, 2020
by
Robert Czechowski
Browse files
Admin page: Contest overview page that makes contest export possible. Fixes
#82
parent
e49a08ba
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/core.rs
View file @
42a269ae
...
...
@@ -1277,6 +1277,25 @@ pub fn admin_delete_participation<T: MedalConnection>(conn: &T, user_id: i32, co
Ok
((
"profile"
.to_string
(),
data
))
}
pub
fn
admin_show_contests
<
T
:
MedalConnection
>
(
conn
:
&
T
,
session_token
:
&
str
)
->
MedalValueResult
{
let
session
=
conn
.get_session
(
&
session_token
)
.ensure_logged_in
()
.ok_or
(
MedalError
::
NotLoggedIn
)
?
.ensure_admin
()
.ok_or
(
MedalError
::
AccessDenied
)
?
;
let
mut
data
=
json_val
::
Map
::
new
();
// TODO: This returns the contests ordered by 'positionalnumber'
// Should this ordering be changed?
let
contests
:
Vec
<
_
>
=
conn
.get_contest_list
()
.into_iter
()
.map
(|
contest
|
(
contest
.id
,
contest
.name
))
.collect
();
data
.insert
(
"contests"
.to_string
(),
to_json
(
&
contests
));
Ok
((
"admin_contests"
.to_string
(),
data
))
}
pub
fn
admin_contest_export
<
T
:
MedalConnection
>
(
conn
:
&
T
,
contest_id
:
i32
,
session_token
:
&
str
)
->
MedalResult
<
String
>
{
conn
.get_session
(
&
session_token
)
.ensure_logged_in
()
...
...
src/webfw_iron.rs
View file @
42a269ae
...
...
@@ -1004,6 +1004,17 @@ fn admin_participation<C>(req: &mut Request) -> IronResult<Response>
Ok
(
resp
)
}
fn
admin_contests
<
C
>
(
req
:
&
mut
Request
)
->
IronResult
<
Response
>
where
C
:
MedalConnection
+
std
::
marker
::
Send
+
'static
{
let
session_token
=
req
.expect_session_token
()
?
;
let
(
template
,
data
)
=
with_conn!
[
core
::
admin_show_contests
,
C
,
req
,
&
session_token
]
.aug
(
req
)
?
;
let
mut
resp
=
Response
::
new
();
resp
.set_mut
(
Template
::
new
(
&
template
,
data
))
.set_mut
(
status
::
Ok
);
Ok
(
resp
)
}
fn
admin_export_contest
<
C
>
(
req
:
&
mut
Request
)
->
IronResult
<
Response
>
where
C
:
MedalConnection
+
std
::
marker
::
Send
+
'static
{
let
contest_id
=
req
.expect_int
::
<
i32
>
(
"contestid"
)
?
;
...
...
@@ -1249,6 +1260,7 @@ pub fn start_server<C>(conn: C, config: Config) -> iron::error::HttpResult<iron:
admin_group_post
:
post
"/admin/group/:groupid"
=>
admin_group
::
<
C
>
,
admin_participation
:
get
"/admin/user/:userid/:contestid"
=>
admin_participation
::
<
C
>
,
admin_participation_post
:
post
"/admin/user/:userid/:contestid"
=>
admin_participation
::
<
C
>
,
admin_contests
:
get
"/admin/contest/"
=>
admin_contests
::
<
C
>
,
admin_export_contest
:
get
"/admin/contest/:contestid/export"
=>
admin_export_contest
::
<
C
>
,
oauth
:
get
"/oauth/:oauthid"
=>
oauth
::
<
C
>
,
check_cookie
:
get
"/cookie"
=>
cookie_warning
,
...
...
templates/default/admin.hbs
View file @
42a269ae
<h1>
Admin-Suche
</h1>
<h1>
Administration
</h1>
<h2>
Admin-Suche
</h2>
<p>
Suche beachtet Groß-/Kleinschreibung. Das Prozentzeichen % ist ein Wildcart in der Namenssuche. Die Suche gibt nur bis zu 30 Ergebnisse aus, auch wenn es mehr gibt!
</p>
<p>
...
...
@@ -48,3 +49,5 @@
<input
type=
"submit"
value=
"search"
>
</form>
</p>
<h2>
Wettbewerbs-Export
</h2>
<a
href=
"/admin/contest/"
>
Wettbewerbsübersicht
</a>
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