always use your own name for registrations; except if the user has the add_different_user permission
This commit is contained in:
parent
de35247c76
commit
cde862f97f
2
db.txt
2
db.txt
@ -1,4 +1,4 @@
|
||||
CREATE TABLE IF NOT EXISTS "day" ( "day" text NOT NULL PRIMARY KEY, "planned_amount_cox" integer NOT NULL DEFAULT 0, "planned_starting_time" text, "open_registration" boolean NOT NULL DEFAULT TRUE );
|
||||
CREATE TABLE IF NOT EXISTS "user" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" text NOT NULL UNIQUE, "pw" text, "is_cox" boolean NOT NULL DEFAULT FALSE, "is_admin" boolean NOT NULL DEFAULT FALSE );
|
||||
CREATE TABLE IF NOT EXISTS "user" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" text NOT NULL UNIQUE, "pw" text, "is_cox" boolean NOT NULL DEFAULT FALSE, "add_different_user" boolean NOT NULL DEFAULT FALSE, "is_admin" boolean NOT NULL DEFAULT FALSE );
|
||||
CREATE TABLE IF NOT EXISTS "trip" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "day" text NOT NULL, "user_id" integer NOT NULL, "cox_id" integer, "begin" text, "created" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("day") REFERENCES "day" ("day"), FOREIGN KEY ("user_id") REFERENCES "user" ("id"), FOREIGN KEY ("cox_id") REFERENCES "trip" ("id") );
|
||||
create unique index UNIQ_trip on trip("day", "user_id", IFNULL(cox_id, ''), IFNULL(begin,''));
|
||||
|
@ -16,6 +16,7 @@ pub struct Model {
|
||||
pub name: String,
|
||||
pub pw: Option<String>,
|
||||
pub is_cox: bool,
|
||||
pub add_different_user: bool,
|
||||
pub is_admin: bool,
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,8 @@ async fn register(
|
||||
);
|
||||
}
|
||||
|
||||
let user = user::Model::find_or_create_user(®ister.name, db.inner()).await;
|
||||
|
||||
if let Some(cox_id) = register.cox_id {
|
||||
let trip = trip::Entity::find_by_id(cox_id)
|
||||
.one(db.inner())
|
||||
@ -57,8 +59,6 @@ async fn register(
|
||||
}
|
||||
}
|
||||
|
||||
let user = user::Model::find_or_create_user(®ister.name, db.inner()).await;
|
||||
|
||||
let day = format!("{}", day.day.format("%Y-%m-%d"));
|
||||
let trip = trip::ActiveModel {
|
||||
day: Set(day.clone()),
|
||||
|
@ -16,6 +16,7 @@ async fn index(db: &State<DatabaseConnection>, user: user::AdminUser) -> Templat
|
||||
struct UserEditForm {
|
||||
pw: Option<String>,
|
||||
is_cox: bool,
|
||||
add_different_user: bool,
|
||||
is_admin: bool,
|
||||
}
|
||||
|
||||
@ -30,6 +31,7 @@ async fn update(
|
||||
id: Set(id),
|
||||
is_cox: Set(data.is_cox),
|
||||
is_admin: Set(data.is_admin),
|
||||
add_different_user: Set(data.add_different_user),
|
||||
..Default::default()
|
||||
};
|
||||
if let Some(pw) = &data.pw {
|
||||
|
@ -76,9 +76,11 @@
|
||||
{% set cox_left = day.planned_amount_cox - amount_cox %}
|
||||
<div class="block text-red">Es {{ cox_left | pluralize(singular="wird", plural="werden")}} noch {{ cox_left }} Steuerperson{{ cox_left | pluralize(plural="en")}} gesucht!</div>
|
||||
{% endif %}
|
||||
{% set_global user_registered = false %}
|
||||
<strong class="block mt-1">Abfahrtszeit: {{ day.planned_starting_time }} Uhr</strong>
|
||||
|
||||
<div style="max-width: 75%">{{ default_trips | length }} angemeldete Person{{ default_trips | length | pluralize(plural="en") }}: {{ cox | length }} Steuerperson{{ cox | length | pluralize(plural="en") }} ({% for c in cox %}{{ c.user.name }} {% if c.user.name == user.name %}
|
||||
{% set_global user_registered = true %}
|
||||
<form method="post" action="/register">
|
||||
<input type="hidden" name="_method" value="delete" />
|
||||
<input type="hidden" name="id" value="{{ c.trip.id }}" />
|
||||
@ -91,6 +93,7 @@
|
||||
<li>
|
||||
{{ r.user.name }} (angemeldet seit {{ r.trip.created | date(format="%d.%m. %H:%M", timezone="Europe/Vienna") }})
|
||||
{% if r.user.name == user.name %}
|
||||
{% set_global user_registered = true %}
|
||||
<form method="post" action="/register">
|
||||
<input type="hidden" name="_method" value="delete" />
|
||||
<input type="hidden" name="id" value="{{ r.trip.id }}" />
|
||||
@ -103,31 +106,40 @@
|
||||
</ol>
|
||||
|
||||
{% if day.open_registration or user.is_cox %}
|
||||
<details class="text-right" style="margin-top: -6rem;">
|
||||
<summary class="button">+</summary>
|
||||
<form method="post" class="text-left" action="/register">
|
||||
<input type="hidden" name="_method" value="put" />
|
||||
<input type="hidden" name="day" value="{{ day_string }}" />
|
||||
<div class="row content-align-bottom">
|
||||
<div class="six columns">
|
||||
<label for="name">Name</label>
|
||||
<input class="u-full-width" type="text" id="name" name="name" value="{{ user.name }}" />
|
||||
</div>
|
||||
<div class="six columns">
|
||||
<input class="button-primary" type="submit" value="Speichern">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</details>
|
||||
{% if not user_registered or user.add_different_user %}
|
||||
<details class="text-right" style="margin-top: -6rem;">
|
||||
<summary class="button">+</summary>
|
||||
<form method="post" class="text-left" action="/register">
|
||||
<input type="hidden" name="_method" value="put" />
|
||||
<input type="hidden" name="day" value="{{ day_string }}" />
|
||||
<div class="row content-align-bottom">
|
||||
<div class="six columns">
|
||||
{% if user.add_different_user %}
|
||||
<label for="name">Name</label>
|
||||
<input class="u-full-width" type="text" id="name" name="name" value="{{ user.name }}" />
|
||||
{% else %}
|
||||
<input class="u-full-width" type="hidden" id="name" name="name" value="{{ user.name }}" />
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="six columns">
|
||||
<input class="button-primary" type="submit" value="Speichern">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</details>
|
||||
{% else %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
Anmeldung an diesem Tag leider nicht möglich (zB bei USI Kursen)
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% for trip in indep_trips %}
|
||||
{% set_global user_registered = false %}
|
||||
{% if trip.trip.begin %}
|
||||
{{trip.user.name}} @ {{trip.trip.begin}}
|
||||
{% set rowers = indep_trips | filter(attribute="trip.cox_id", value=trip.trip.id) %}
|
||||
{% set rowers = indep_trips | filter(attribute="trip.cox_id", value=trip.trip.id) | sort(attribute="trip.created")%}
|
||||
{% if trip.user.name == user.name and rowers | length == 0 %}
|
||||
{% set_global user_registered = true %}
|
||||
<form method="post" action="/register">
|
||||
<input type="hidden" name="_method" value="delete" />
|
||||
<input type="hidden" name="id" value="{{ trip.trip.id }}" />
|
||||
@ -140,6 +152,7 @@
|
||||
<li>
|
||||
{{ r.user.name }} (angemeldet seit {{ r.trip.created | date(format="%d.%m. %H:%M", timezone="Europe/Vienna") }})
|
||||
{% if r.user.name == user.name %}
|
||||
{% set_global user_registered = true %}
|
||||
<form method="post" action="/register">
|
||||
<input type="hidden" name="_method" value="delete" />
|
||||
<input type="hidden" name="id" value="{{ r.trip.id }}" />
|
||||
@ -150,6 +163,7 @@
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
{% if not user_registered or user.add_different_user %}
|
||||
<details class="text-right">
|
||||
<summary class="button">+</summary>
|
||||
<form method="post" class="text-left" action="/register">
|
||||
@ -158,8 +172,13 @@
|
||||
<input type="hidden" name="cox_id" value="{{ trip.trip.id }}" />
|
||||
<div class="row content-align-bottom">
|
||||
<div class="six columns">
|
||||
<label for="name">Name</label>
|
||||
<input class="u-full-width" type="text" id="name" name="name" value="{{ user.name }}" />
|
||||
|
||||
{% if user.add_different_user %}
|
||||
<label for="name">Name</label>
|
||||
<input class="u-full-width" type="text" id="name" name="name" value="{{ user.name }}" />
|
||||
{% else %}
|
||||
<input class="u-full-width" type="hidden" id="name" name="name" value="{{ user.name }}" />
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="six columns">
|
||||
<input class="button-primary" type="submit" value="Speichern">
|
||||
@ -167,6 +186,7 @@
|
||||
</div>
|
||||
</form>
|
||||
</details>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Pw</th>
|
||||
<th>Add Different User</th>
|
||||
<th>Cox</th>
|
||||
<th>Admin</th>
|
||||
<th>Action</th>
|
||||
@ -23,6 +24,9 @@
|
||||
{% endif %}
|
||||
<input type="password" name="pw" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" name="add_different_user" {% if user.add_different_user %} checked="true"{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" name="is_cox" {% if user.is_cox %} checked="true"{% endif %}
|
||||
</td>
|
||||
|
Loading…
Reference in New Issue
Block a user