parent
7b0dd543b1
commit
34eed9680b
BIN
database.sqlite
BIN
database.sqlite
Binary file not shown.
35
src/main.rs
35
src/main.rs
@ -127,12 +127,23 @@ fn klasse_view(conn: DbConn, class_id: i32) -> Template {
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct AddKlasseContext<'a> {
|
||||
klassen: Vec<Klasse>,
|
||||
parent: &'a str,
|
||||
}
|
||||
|
||||
#[get("/add/klasse")]
|
||||
fn get_klasse_form() -> Template {
|
||||
Template::render("add_klasse_form", AddKlasseContext { parent: "base" })
|
||||
fn get_klasse_form(conn: DbConn) -> Template {
|
||||
let klassen = klassen::table
|
||||
.order(klassen::ordnung.asc())
|
||||
.load::<Klasse>(&*conn)
|
||||
.expect("could not load stunden");
|
||||
Template::render(
|
||||
"add_klasse_form",
|
||||
AddKlasseContext {
|
||||
klassen,
|
||||
parent: "base",
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(FromForm, Insertable)]
|
||||
@ -155,9 +166,25 @@ fn post_klasse_form(klasse: Form<KlasseForm>, conn: DbConn) -> Result<Redirect,
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct AddStundeContext<'a> {
|
||||
stunden: Vec<Stunde>,
|
||||
parent: &'a str,
|
||||
}
|
||||
|
||||
#[get("/add/stunde")]
|
||||
fn get_stunde_form() -> Template {
|
||||
Template::render("add_stunde_form", AddKlasseContext { parent: "base" })
|
||||
fn get_stunde_form(conn: DbConn) -> Template {
|
||||
let stunden = stunden::table
|
||||
.order(stunden::ordinal.asc())
|
||||
.load::<Stunde>(&*conn)
|
||||
.expect("could not load stunden");
|
||||
Template::render(
|
||||
"add_stunde_form",
|
||||
AddStundeContext {
|
||||
stunden,
|
||||
parent: "base",
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(FromForm, Insertable)]
|
||||
|
@ -1,4 +1,19 @@
|
||||
{{#* inline "page"}}
|
||||
<h1>Klassen</h1>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Klasse</th>
|
||||
<th>Titel</th>
|
||||
<th>Priorität</th>
|
||||
</tr>
|
||||
{{#each klassen}}
|
||||
<tr>
|
||||
<td>{{ this.stufe }}{{this.gruppe}}</td>
|
||||
<td>{{this.titel}}</td>
|
||||
<td>{{this.ordnung}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
<h1>Klasse hinzu fügen</h1>
|
||||
<form action="/admin/add/klasse" method="post" accept-charset="utf-8">
|
||||
<table>
|
||||
|
@ -1,9 +1,24 @@
|
||||
{{#* inline "page"}}
|
||||
<h1>Stunden</h1>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Abkürzung</th>
|
||||
<th>Priorität</th>
|
||||
</tr>
|
||||
{{#each stunden}}
|
||||
<tr>
|
||||
<td>{{ this.title }}</td>
|
||||
<td>{{this.short}}</td>
|
||||
<td>{{this.ordinal}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
<h1>Stunde hinzu fügen</h1>
|
||||
<form action="/admin/add/stunde" method="post" accept-charset="utf-8">
|
||||
<table>
|
||||
<tr>
|
||||
<th>Titel:</th>
|
||||
<th>Name:</th>
|
||||
<td><input type="text" name="title"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -11,7 +26,7 @@
|
||||
<td><input type="text" name="short"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Ordnung:</th>
|
||||
<th>Priorität:</th>
|
||||
<td><input type="number" name="ordinal"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
Loading…
Reference in New Issue
Block a user