feat: add function to db and event

This commit is contained in:
Max Hohlfeld 2024-12-06 21:30:38 +01:00
parent 7bf892207a
commit b27bdb6daa
6 changed files with 22 additions and 18 deletions

View File

@ -50,6 +50,7 @@ CREATE TABLE event
name TEXT NOT NULL,
locationId INTEGER NOT NULL REFERENCES location (id) ON DELETE CASCADE,
voluntaryWachhabender BOOLEAN NOT NULL,
voluntaryFuehrungsassistent BOOLEAN NOT NULL,
amountOfPosten SMALLINT NOT NULL CHECK (amountOfPosten >= 0),
clothing TEXT NOT NULL,
note TEXT,

View File

@ -3,17 +3,22 @@ use askama::Template;
use askama_actix::TemplateToResponse;
use sqlx::PgPool;
use crate::models::{Area, Function, Role, User};
use crate::{
filters,
models::{Area, Role, User},
};
#[derive(Template)]
#[template(path = "user/profile.html")]
struct ProfileTemplate {
user: User
user: User,
}
#[actix_web::get("/profile")]
pub async fn get(user: web::ReqData<User>, pool: web::Data<PgPool>) -> impl Responder {
let area = Area::read_by_id(pool.get_ref(), user.area_id).await.unwrap();
let area = Area::read_by_id(pool.get_ref(), user.area_id)
.await
.unwrap();
let mut user = user.into_inner();
user.area = area;

View File

@ -51,13 +51,6 @@
<div class="box">
<h5 class="title is-5">Einteilung Personal</h5>
<div class="icon-text">
<svg class="icon has-text-success">
<use href="/static/feather-sprite.svg#check" />
</svg>
<span>Alle Plätze verplant!</span>
</div>
{% include "plan_personal_table.html" %}
</div>

View File

@ -1,3 +1,12 @@
{% if !further_posten_required && !further_fuehrungsassistent_required && !further_wachhabender_required %}
<div class="icon-text">
<svg class="icon has-text-success">
<use href="/static/feather-sprite.svg#check" />
</svg>
<span>Alle Plätze verplant!</span>
</div>
{% endif %}
<table class="table is-fullwidth">
<thead>
<tr>

View File

@ -69,6 +69,8 @@
<div class="select is-fullwidth">
<select name="function">
<option value="1" {{ function|is_some_and_eq(1|as_ref)|cond_show("selected") }}>Posten</option>
<option value="1" {{ function|is_some_and_eq(5|as_ref)|cond_show("selected") }}>Führungsassistent
</option>
<option value="10" {{ function|is_some_and_eq(10|as_ref)|cond_show("selected") }}>Wachhabender
</option>
</select>

View File

@ -62,13 +62,7 @@
<div class="field-body">
<div class="field">
<div class="control">
{% match user.function %}
{% when Function::Posten %}
<span class="tag is-primary is-light">Posten</span>
{% when Function::Wachhabender %}
<span class="tag is-primary">Wachhabender</span>
{% else %}
{% endmatch %}
{{ user.function|show_tree|safe }}
</div>
</div>
</div>