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
72dbee11
Commit
72dbee11
authored
May 14, 2020
by
Robert Czechowski
Browse files
Make teacher information page configurable in config file
parent
333b7ba1
Pipeline
#636
passed with stage
in 12 minutes and 40 seconds
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
src/config.rs
View file @
72dbee11
...
...
@@ -18,6 +18,7 @@ pub struct Config {
pub
cookie_signing_secret
:
Option
<
String
>
,
pub
disable_results_page
:
Option
<
bool
>
,
pub
server_message
:
Option
<
String
>
,
pub
teacher_page
:
Option
<
String
>
,
}
#[derive(StructOpt,
Debug)]
...
...
@@ -58,6 +59,10 @@ pub struct Opt {
/// Disable results page to reduce load on the server
#[structopt(long
=
"disable-results-page"
)]
pub
disableresultspage
:
bool
,
/// Teacher page in task directory
#[structopt(short
=
"t"
,
long
=
"teacherpage"
)]
pub
teacherpage
:
Option
<
String
>
,
}
pub
fn
read_config_from_file
(
file
:
&
Path
)
->
Config
{
...
...
src/core.rs
View file @
72dbee11
...
...
@@ -1030,7 +1030,7 @@ pub fn edit_profile<T: MedalConnection>(conn: &T, session_token: &str, user_id:
Ok
(
result
)
}
pub
fn
teacher_infos
<
T
:
MedalConnection
>
(
conn
:
&
T
,
session_token
:
&
str
)
->
MedalValueResult
{
pub
fn
teacher_infos
<
T
:
MedalConnection
>
(
conn
:
&
T
,
session_token
:
&
str
,
teacher_page
:
Option
<&
str
>
)
->
MedalValueResult
{
let
session
=
conn
.get_session
(
&
session_token
)
.ensure_logged_in
()
.ok_or
(
MedalError
::
NotLoggedIn
)
?
;
if
!
session
.is_teacher
{
return
Err
(
MedalError
::
AccessDenied
);
...
...
@@ -1039,6 +1039,10 @@ pub fn teacher_infos<T: MedalConnection>(conn: &T, session_token: &str) -> Medal
let
mut
data
=
json_val
::
Map
::
new
();
fill_user_data
(
&
session
,
&
mut
data
);
if
let
Some
(
teacher_page
)
=
teacher_page
{
data
.insert
(
"teacher_page"
.to_string
(),
to_json
(
&
teacher_page
));
}
Ok
((
"teacher"
.to_string
(),
data
))
}
...
...
src/main.rs
View file @
72dbee11
...
...
@@ -202,6 +202,7 @@ fn main() {
// Let options override config values
opt
.databasefile
.map
(|
x
|
config
.database_file
=
Some
(
x
));
opt
.databaseurl
.map
(|
x
|
config
.database_url
=
Some
(
x
));
opt
.teacherpage
.map
(|
x
|
config
.teacher_page
=
Some
(
x
));
opt
.port
.map
(|
x
|
config
.port
=
Some
(
x
));
config
.no_contest_scan
=
if
opt
.nocontestscan
{
Some
(
true
)
}
else
{
config
.no_contest_scan
};
config
.open_browser
=
if
opt
.openbrowser
{
Some
(
true
)
}
else
{
config
.open_browser
};
...
...
src/webfw_iron.rs
View file @
72dbee11
...
...
@@ -875,7 +875,10 @@ fn teacherinfos<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
::
teacher_infos
,
C
,
req
,
&
session_token
]
.aug
(
req
)
?
;
let
config
=
req
.get
::
<
Read
<
SharedConfiguration
>>
()
.unwrap
();
let
(
template
,
data
)
=
with_conn!
[
core
::
teacher_infos
,
C
,
req
,
&
session_token
,
config
.teacher_page
.as_ref
()
.map
(|
x
|
&**
x
)]
.aug
(
req
)
?
;
// .as_ref().map(|x| &**x) can be written as .as_deref() since rust 1.40
let
mut
resp
=
Response
::
new
();
resp
.set_mut
(
Template
::
new
(
&
template
,
data
))
.set_mut
(
status
::
Ok
);
...
...
templates/jwinf/teacher.hbs
View file @
72dbee11
...
...
@@ -2,7 +2,11 @@
<div
class=
"columns"
>
<div
class=
"column is-8 is-offset-2"
>
<h3
class=
"title is-4"
>
Lehrer-Informationen
</h3>
<iframe
src=
"/tasks/teacher/index.html"
style=
"height: calc(100vh - 550px); min-height:200px;"
></iframe>
{{#if
teacher_page
}}
<iframe
src=
"/tasks/
{{
teacher_page
}}
"
style=
"height: calc(100vh - 550px); min-height:200px;"
></iframe>
{{else}}
<em>
Noch keine Informationen vorhanden
</em>
{{/if}}
</div>
</div>
{{/
inline
}}
...
...
Robert Czechowski
@zgtm
mentioned in issue
#81 (closed)
·
Jun 08, 2020
mentioned in issue
#81 (closed)
mentioned in issue #81
Toggle commit list
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