Add style and prepare relationships
This commit is contained in:
parent
d303232201
commit
a315bb84a4
45
.vscode/launch.json
vendored
Normal file
45
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "lldb",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Debug executable 'rocket_page'",
|
||||||
|
"cargo": {
|
||||||
|
"args": [
|
||||||
|
"build",
|
||||||
|
"--bin=rocket_page",
|
||||||
|
"--package=rocket_page"
|
||||||
|
],
|
||||||
|
"filter": {
|
||||||
|
"name": "rocket_page",
|
||||||
|
"kind": "bin"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "lldb",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Debug unit tests in executable 'rocket_page'",
|
||||||
|
"cargo": {
|
||||||
|
"args": [
|
||||||
|
"test",
|
||||||
|
"--no-run",
|
||||||
|
"--bin=rocket_page",
|
||||||
|
"--package=rocket_page"
|
||||||
|
],
|
||||||
|
"filter": {
|
||||||
|
"name": "rocket_page",
|
||||||
|
"kind": "bin"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
10
Cargo.toml
10
Cargo.toml
@ -8,11 +8,11 @@ edition = "2018"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rocket = "0.4.5"
|
rocket = "0.4.5"
|
||||||
diesel = { version = "1.4.0", features = ["sqlite"] }
|
diesel = { version = "1.4", features = ["sqlite"] }
|
||||||
serde_derive = "*"
|
serde_derive = "1.0"
|
||||||
serde = "*"
|
serde = "1.0"
|
||||||
|
|
||||||
[dependencies.rocket_contrib]
|
[dependencies.rocket_contrib]
|
||||||
version = "0.4.5"
|
version = "0.4"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["diesel_sqlite_pool", "handlebars_templates"]
|
features = ["diesel_sqlite_pool", "handlebars_templates", "serve"]
|
||||||
|
BIN
database.sqlite
BIN
database.sqlite
Binary file not shown.
@ -1,5 +1,6 @@
|
|||||||
-- Your SQL goes here
|
-- Your SQL goes here
|
||||||
CREATE TABLE stunden (
|
CREATE TABLE stunden
|
||||||
|
(
|
||||||
id Integer PRIMARY KEY NOT NULL,
|
id Integer PRIMARY KEY NOT NULL,
|
||||||
title Text NOT NULL,
|
title Text NOT NULL,
|
||||||
short Text NOT NULL,
|
short Text NOT NULL,
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
-- Your SQL goes here
|
-- Your SQL goes here
|
||||||
CREATE TABLE klassen (
|
|
||||||
id Integer PRIMARY KEY NOT NULL,
|
CREATE TABLE klassen
|
||||||
stufe Integer not null,
|
(
|
||||||
gruppe Text NOT NULL,
|
id Integer PRIMARY KEY NOT NULL,
|
||||||
titel Text,
|
stufe Integer NOT NULL,
|
||||||
ordinal Integer NOT NULL
|
gruppe Text NOT NULL,
|
||||||
|
titel Text,
|
||||||
|
ordinal Integer NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
-- This file should undo anything in `up.sql`
|
-- This file should undo anything in `up.sql`
|
||||||
Alter Table klassen Rename Column ordnung to ordinal;
|
|
||||||
|
ALTER TABLE klassen RENAME COLUMN ordnung TO ordinal;
|
||||||
|
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
-- Your SQL goes here
|
-- Your SQL goes here
|
||||||
Alter Table klassen Rename Column ordinal to ordnung;
|
|
||||||
|
ALTER TABLE klassen RENAME COLUMN ordinal TO ordnung;
|
||||||
|
|
||||||
|
@ -1 +1,4 @@
|
|||||||
-- This file should undo anything in `up.sql`
|
-- This file should undo anything in `up.sql`
|
||||||
|
|
||||||
|
DROP TABLE Vertretungen;
|
||||||
|
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
-- Your SQL
|
-- Your SQL
|
||||||
CREATE TABLE Vertretungen (
|
|
||||||
id Integer PRIMARY KEY NOT NULL,
|
CREATE TABLE Vertretungen
|
||||||
klasse Integer not null,
|
(
|
||||||
stunde Integer not null,
|
id Integer PRIMARY KEY NOT NULL,
|
||||||
fehlend Text NOT NULL,
|
klassen_id Integer NOT NULL,
|
||||||
vertretung Text NOT NULL,
|
stunden_id Integer NOT NULL,
|
||||||
kommentar Text NOT NULL,
|
fehlend Text NOT NULL,
|
||||||
FOREIGN KEY(klasse) REFERENCES klasse(id),
|
vertretung Text NOT NULL,
|
||||||
FOREIGN KEY(stunde) REFERENCES stunde(id)
|
kommentar Text NOT NULL,
|
||||||
|
FOREIGN KEY(klasse_id) REFERENCES klasse(id),
|
||||||
|
FOREIGN KEY(stunde_id) REFERENCES stunde(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use diesel::RunQueryDsl;
|
|||||||
use rocket::request::{Form, FromParam};
|
use rocket::request::{Form, FromParam};
|
||||||
use rocket::response::Redirect;
|
use rocket::response::Redirect;
|
||||||
use rocket_contrib::databases;
|
use rocket_contrib::databases;
|
||||||
|
use rocket_contrib::serve::StaticFiles;
|
||||||
use rocket_contrib::templates::Template;
|
use rocket_contrib::templates::Template;
|
||||||
|
|
||||||
struct StundenByID(i32);
|
struct StundenByID(i32);
|
||||||
@ -86,6 +86,10 @@ fn main() {
|
|||||||
rocket::ignite()
|
rocket::ignite()
|
||||||
.attach(DbConn::fairing())
|
.attach(DbConn::fairing())
|
||||||
.attach(Template::fairing())
|
.attach(Template::fairing())
|
||||||
|
.mount(
|
||||||
|
"/static",
|
||||||
|
StaticFiles::from(concat!(env!("CARGO_MANIFEST_DIR"), "/static")),
|
||||||
|
)
|
||||||
.mount("/", routes![index])
|
.mount("/", routes![index])
|
||||||
.mount("/admin/", routes![get_klasse_form])
|
.mount("/admin/", routes![get_klasse_form])
|
||||||
.mount("/admin/", routes![post_klasse_form])
|
.mount("/admin/", routes![post_klasse_form])
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use super::schema::klassen;
|
use super::schema::{klassen, vertretungen};
|
||||||
|
|
||||||
#[derive(Queryable, Debug, Serialize)]
|
#[derive(Queryable, Debug, Serialize)]
|
||||||
pub struct Stunden {
|
pub struct Stunden {
|
||||||
@ -8,17 +8,21 @@ pub struct Stunden {
|
|||||||
pub ordinal: i32,
|
pub ordinal: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Queryable, Debug, Serialize)]
|
#[derive(Identifiable, Queryable, Debug, Serialize, Associations)]
|
||||||
|
#[belongs_to(Klassen)]
|
||||||
|
#[belongs_to(Stunden)]
|
||||||
|
#[table_name = "vertretungen"]
|
||||||
pub struct Vertretungen {
|
pub struct Vertretungen {
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
pub klasse_link: i32,
|
pub klassen_id: i32,
|
||||||
pub stunde_link: i32,
|
pub stunden_id: i32,
|
||||||
pub fehlend: String,
|
pub fehlend: String,
|
||||||
pub vertretung: String,
|
pub vertretung: String,
|
||||||
pub kommentar: String,
|
pub kommentar: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Queryable, Debug, Serialize)]
|
#[derive(Identifiable, Queryable, Debug, Serialize)]
|
||||||
|
#[table_name = "klassen"]
|
||||||
pub struct Klassen {
|
pub struct Klassen {
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
pub stufe: i32,
|
pub stufe: i32,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
table! {
|
table! {
|
||||||
vertretungen (id) {
|
vertretungen (id) {
|
||||||
id -> Integer,
|
id -> Integer,
|
||||||
klasse -> Integer,
|
klassen_id -> Integer,
|
||||||
stunde -> Integer,
|
stunden_id -> Integer,
|
||||||
fehlend -> Text,
|
fehlend -> Text,
|
||||||
vertretung -> Text,
|
vertretung -> Text,
|
||||||
kommentar -> Text,
|
kommentar -> Text,
|
||||||
|
88
static/style.css
Normal file
88
static/style.css
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
|
||||||
|
|
||||||
|
body{
|
||||||
|
background-color: #23272a;
|
||||||
|
max-width: 880px;
|
||||||
|
margin: auto;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: #16e0b8;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:visited {
|
||||||
|
color: #fcb6b6;
|
||||||
|
}
|
||||||
|
.grid-container {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: auto auto auto auto;
|
||||||
|
grid-gap: 30px;
|
||||||
|
padding: 10px;
|
||||||
|
background-color: #23272a;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid-item div {
|
||||||
|
display: table-cell;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
font-size: 48px;
|
||||||
|
box-shadow: 2px 2px 6px 0px rgba(0, 0, 0, 0.2);
|
||||||
|
max-width: 100%;
|
||||||
|
width: 215px;
|
||||||
|
height: 200px;
|
||||||
|
margin: auto;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 200px;
|
||||||
|
background-color: #2c2f33;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
||||||
|
grid-gap: 20px;
|
||||||
|
align-items: stretch;
|
||||||
|
max-width: 500px;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid div {
|
||||||
|
display: table-cell;
|
||||||
|
border: 3px solid #ccc;
|
||||||
|
font-size: 16px;
|
||||||
|
box-shadow: 2px 2px 6px 0px rgba(0, 0, 0, 0.5);
|
||||||
|
max-width: 100%;
|
||||||
|
width: 200px;
|
||||||
|
height: 100px;
|
||||||
|
margin: center;
|
||||||
|
text-align: center;
|
||||||
|
padding: 10px;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 20px;
|
||||||
|
font-family: Helvetica;
|
||||||
|
font-weight: bold;
|
||||||
|
background-color: #2c2f33;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.Fach {
|
||||||
|
display: table-cell;
|
||||||
|
border: 3px solid #ccc;
|
||||||
|
font-size: 16px;
|
||||||
|
box-shadow: 2px 2px 6px 0px rgba(0, 0, 0, 0.5);
|
||||||
|
max-width: 100%;
|
||||||
|
width: 200px;
|
||||||
|
height: 100px;
|
||||||
|
margin: center;
|
||||||
|
text-align: center;
|
||||||
|
padding: 10px;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 20px;
|
||||||
|
font-family: Helvetica;
|
||||||
|
font-weight: bold;
|
||||||
|
background-color: #081B33;
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
{{#* inline "page"}}
|
{{#* inline "page"}}
|
||||||
<h1>Login</h1>
|
<h1>Klasse hinzu fügen</h1>
|
||||||
<form action="/admin/add/klasse" method="post" accept-charset="utf-8">
|
<form action="/admin/add/klasse" method="post" accept-charset="utf-8">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{{#* inline "page"}}
|
{{#* inline "page"}}
|
||||||
<h1>Stundenplan</h1>
|
<h1>Vertretungen</h1>
|
||||||
<ul>
|
<ul>
|
||||||
{{#each klassen}}
|
{{#each klassen}}
|
||||||
<li>{{this.id}}. {{this.stufe}}{{this.gruppe}}</li>
|
<li>{{this.id}}. {{this.stufe}}{{this.gruppe}}</li>
|
||||||
|
Loading…
Reference in New Issue
Block a user