Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bwinf
medal
Commits
333b7ba1
Commit
333b7ba1
authored
May 11, 2020
by
Robert Czechowski
Browse files
Add teacher page and link to teacher page for teachers
parent
faa9099d
Pipeline
#630
passed with stage
in 10 minutes
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/core.rs
View file @
333b7ba1
...
...
@@ -1030,6 +1030,18 @@ 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
{
let
session
=
conn
.get_session
(
&
session_token
)
.ensure_logged_in
()
.ok_or
(
MedalError
::
NotLoggedIn
)
?
;
if
!
session
.is_teacher
{
return
Err
(
MedalError
::
AccessDenied
);
}
let
mut
data
=
json_val
::
Map
::
new
();
fill_user_data
(
&
session
,
&
mut
data
);
Ok
((
"teacher"
.to_string
(),
data
))
}
pub
fn
admin_index
<
T
:
MedalConnection
>
(
conn
:
&
T
,
session_token
:
&
str
)
->
MedalValueResult
{
let
session
=
conn
.get_session
(
&
session_token
)
.ensure_logged_in
()
.ok_or
(
MedalError
::
NotLoggedIn
)
?
;
if
session
.id
!=
1
{
...
...
src/webfw_iron.rs
View file @
333b7ba1
...
...
@@ -871,6 +871,17 @@ fn user_post<C>(req: &mut Request) -> IronResult<Response>
//old: Ok(Response::with((status::Found, Redirect(url_for!(req, "user", "userid" => format!("{}",user_id))))))
}
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
mut
resp
=
Response
::
new
();
resp
.set_mut
(
Template
::
new
(
&
template
,
data
))
.set_mut
(
status
::
Ok
);
Ok
(
resp
)
}
fn
admin
<
C
>
(
req
:
&
mut
Request
)
->
IronResult
<
Response
>
where
C
:
MedalConnection
+
std
::
marker
::
Send
+
'static
{
let
session_token
=
req
.expect_session_token
()
?
;
...
...
@@ -1200,6 +1211,7 @@ pub fn start_server<C>(conn: C, config: Config) -> iron::error::HttpResult<iron:
user
:
get
"/user/:userid"
=>
user
::
<
C
>
,
user_post
:
post
"/user/:userid"
=>
user_post
::
<
C
>
,
task
:
get
"/task/:taskid"
=>
task
::
<
C
>
,
teacher
:
get
"/teacher"
=>
teacherinfos
::
<
C
>
,
admin
:
get
"/admin"
=>
admin
::
<
C
>
,
admin_users
:
post
"/admin/user/"
=>
admin_users
::
<
C
>
,
admin_user
:
get
"/admin/user/:userid"
=>
admin_user
::
<
C
>
,
...
...
templates/default/teacher.hbs
0 → 100644
View file @
333b7ba1
<iframe
src=
"/tasks/teacher/index.html"
></iframe>
templates/jwinf/base.hbs
View file @
333b7ba1
...
...
@@ -34,7 +34,7 @@
{{#if
logged_in
}}
{{#if
firstlogin
}}{{else}}
<div
class=
"columns alogin"
>
<div
class=
"columns alogin"
style=
"margin-bottom: 0px;"
>
<div
class=
"column is-three-fifths"
>
Eingeloggt als
<em>
{{
username
}}
</em>
{{#if
firstname
}}{{#if
lastname
}}
...
...
@@ -42,17 +42,18 @@
{{/if}}{{/if}}
{{#if
teacher
}}
[Lehrer]
{{/if}}
<br>
{{/if}}
</div>
<div
class=
"column"
><a
href=
"/logout"
class=
"button is-small is-danger"
type=
"submit"
>
⨯
Logout
</a></div>
</div>
<div
class=
"columns alogin"
>
<div
class=
"column"
>
<a
href=
"/profile"
class=
"button is-info is-small"
>
👤
Profil
</a>
{{#if
teacher
}}
<a
href=
"/group/"
class=
"button is-warning is-small"
>
⚙
Gruppenverwaltung
</a>
<a
href=
"/teacher"
class=
"button is-primary is-small"
>
👨🏫
Lehrer-Informationen
</a>
{{/if}}
</div>
<div
class=
"column"
><a
href=
"/logout"
class=
"button is-small is-danger"
type=
"submit"
>
⨯
Logout
</a></div>
</div>
<div
class=
"columns alogin"
>
<div
class=
"column"
></div>
</div>
{{/if}}
{{else}}
...
...
templates/jwinf/teacher.hbs
0 → 100644
View file @
333b7ba1
{{#
*
inline
"page"
}}
<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>
</div>
</div>
{{/
inline
}}
{{~>
(
parent
)
~}}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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