notification-badge #400
@ -101,7 +101,8 @@ CREATE TABLE IF NOT EXISTS "boat" (
|
|||||||
"default_shipmaster_only_steering" boolean default false not null,
|
"default_shipmaster_only_steering" boolean default false not null,
|
||||||
"default_destination" text,
|
"default_destination" text,
|
||||||
"skull" boolean default true NOT NULL, -- false => riemen
|
"skull" boolean default true NOT NULL, -- false => riemen
|
||||||
"external" boolean default false NOT NULL -- false => owned by different club
|
"external" boolean default false NOT NULL, -- false => owned by different club
|
||||||
|
"deleted" boolean NOT NULL DEFAULT FALSE
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS "logbook_type" (
|
CREATE TABLE IF NOT EXISTS "logbook_type" (
|
||||||
|
@ -26,6 +26,7 @@ pub struct Boat {
|
|||||||
skull: bool,
|
skull: bool,
|
||||||
#[serde(default = "bool::default")]
|
#[serde(default = "bool::default")]
|
||||||
external: bool,
|
external: bool,
|
||||||
|
pub deleted: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
@ -188,8 +189,9 @@ AND date('now') BETWEEN start_date AND end_date;",
|
|||||||
let boats = sqlx::query_as!(
|
let boats = sqlx::query_as!(
|
||||||
Boat,
|
Boat,
|
||||||
"
|
"
|
||||||
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external
|
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted
|
||||||
FROM boat
|
FROM boat
|
||||||
|
WHERE deleted=false
|
||||||
ORDER BY amount_seats DESC
|
ORDER BY amount_seats DESC
|
||||||
"
|
"
|
||||||
)
|
)
|
||||||
@ -215,12 +217,14 @@ SELECT
|
|||||||
b.default_shipmaster_only_steering,
|
b.default_shipmaster_only_steering,
|
||||||
b.default_destination,
|
b.default_destination,
|
||||||
b.skull,
|
b.skull,
|
||||||
b.external
|
b.external,
|
||||||
|
b.deleted
|
||||||
FROM
|
FROM
|
||||||
boat AS b
|
boat AS b
|
||||||
WHERE
|
WHERE
|
||||||
b.external = false
|
b.external = false
|
||||||
AND b.location_id = (SELECT id FROM location WHERE name = 'Linz')
|
AND b.location_id = (SELECT id FROM location WHERE name = 'Linz')
|
||||||
|
AND b.deleted = false
|
||||||
ORDER BY
|
ORDER BY
|
||||||
b.name DESC;
|
b.name DESC;
|
||||||
"
|
"
|
||||||
@ -240,7 +244,7 @@ ORDER BY
|
|||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
Boat,
|
Boat,
|
||||||
"
|
"
|
||||||
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external
|
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted
|
||||||
FROM boat
|
FROM boat
|
||||||
WHERE owner is null or owner = ?
|
WHERE owner is null or owner = ?
|
||||||
ORDER BY amount_seats DESC
|
ORDER BY amount_seats DESC
|
||||||
@ -254,7 +258,7 @@ ORDER BY amount_seats DESC
|
|||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
Boat,
|
Boat,
|
||||||
"
|
"
|
||||||
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external
|
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted
|
||||||
FROM boat
|
FROM boat
|
||||||
WHERE owner = ? OR (owner is null and amount_seats = 1)
|
WHERE owner = ? OR (owner is null and amount_seats = 1)
|
||||||
ORDER BY amount_seats DESC
|
ORDER BY amount_seats DESC
|
||||||
@ -272,7 +276,7 @@ ORDER BY amount_seats DESC
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
let boats_in_ottensheim = sqlx::query_as!(
|
let boats_in_ottensheim = sqlx::query_as!(
|
||||||
Boat,
|
Boat,
|
||||||
"SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external
|
"SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted
|
||||||
FROM boat
|
FROM boat
|
||||||
WHERE owner is null and location_id = ?
|
WHERE owner is null and location_id = ?
|
||||||
ORDER BY amount_seats DESC
|
ORDER BY amount_seats DESC
|
||||||
@ -291,7 +295,7 @@ ORDER BY amount_seats DESC
|
|||||||
let boats = sqlx::query_as!(
|
let boats = sqlx::query_as!(
|
||||||
Boat,
|
Boat,
|
||||||
"
|
"
|
||||||
SELECT boat.id, boat.name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external
|
SELECT boat.id, boat.name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted
|
||||||
FROM boat
|
FROM boat
|
||||||
INNER JOIN location ON boat.location_id = location.id
|
INNER JOIN location ON boat.location_id = location.id
|
||||||
WHERE location.name=?
|
WHERE location.name=?
|
||||||
@ -354,7 +358,7 @@ ORDER BY amount_seats DESC
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete(&self, db: &SqlitePool) {
|
pub async fn delete(&self, db: &SqlitePool) {
|
||||||
sqlx::query!("DELETE FROM boat WHERE id=?", self.id)
|
sqlx::query!("UPDATE boat SET deleted=1 WHERE id=?", self.id)
|
||||||
.execute(db)
|
.execute(db)
|
||||||
.await
|
.await
|
||||||
.unwrap(); //Okay, because we can only create a Boat of a valid id
|
.unwrap(); //Okay, because we can only create a Boat of a valid id
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use crate::model::{
|
use crate::model::{
|
||||||
boat::{Boat, BoatToAdd, BoatToUpdate},
|
boat::{Boat, BoatToAdd, BoatToUpdate},
|
||||||
location::Location,
|
location::Location,
|
||||||
|
log::Log,
|
||||||
user::{AdminUser, User, UserWithRolesAndNotificationCount},
|
user::{AdminUser, User, UserWithRolesAndNotificationCount},
|
||||||
};
|
};
|
||||||
use rocket::{
|
use rocket::{
|
||||||
@ -39,8 +40,10 @@ async fn index(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/boat/<boat>/delete")]
|
#[get("/boat/<boat>/delete")]
|
||||||
async fn delete(db: &State<SqlitePool>, _admin: AdminUser, boat: i32) -> Flash<Redirect> {
|
async fn delete(db: &State<SqlitePool>, admin: AdminUser, boat: i32) -> Flash<Redirect> {
|
||||||
let boat = Boat::find_by_id(db, boat).await;
|
let boat = Boat::find_by_id(db, boat).await;
|
||||||
|
Log::create(db, format!("{} deleted boat: {boat:?}", admin.user.name)).await;
|
||||||
|
|
||||||
match boat {
|
match boat {
|
||||||
Some(boat) => {
|
Some(boat) => {
|
||||||
boat.delete(db).await;
|
boat.delete(db).await;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
-- test user
|
||||||
INSERT INTO user(name) VALUES('Marie');
|
INSERT INTO user(name) VALUES('Marie');
|
||||||
INSERT INTO "user_role" (user_id, role_id) VALUES((SELECT id from user where name = 'Marie'),(SELECT id FROM role where name = 'Donau Linz'));
|
INSERT INTO "user_role" (user_id, role_id) VALUES((SELECT id from user where name = 'Marie'),(SELECT id FROM role where name = 'Donau Linz'));
|
||||||
INSERT INTO user(name) VALUES('Philipp');
|
INSERT INTO user(name) VALUES('Philipp');
|
||||||
|
@ -133,12 +133,10 @@
|
|||||||
<a href="/planned/remove/{{ planned_event.trip_details_id }}"
|
<a href="/planned/remove/{{ planned_event.trip_details_id }}"
|
||||||
class="btn btn-attention btn-fw">Abmelden</a>
|
class="btn btn-attention btn-fw">Abmelden</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if planned_event.max_people > planned_event.rower | length %}
|
{% if planned_event.max_people > planned_event.rower | length and cur_user_participates == false %}
|
||||||
{% if cur_user_participates == false %}
|
<a href="/planned/join/{{ planned_event.trip_details_id }}"
|
||||||
<a href="/planned/join/{{ planned_event.trip_details_id }}"
|
class="btn btn-primary btn-fw"
|
||||||
class="btn btn-primary btn-fw"
|
{% if planned_event.trip_type %}onclick="return confirm('{{ planned_event.trip_type.question }}');"{% endif %}>Mitrudern</a>
|
||||||
{% if planned_event.trip_type %}onclick="return confirm('{{ planned_event.trip_type.question }}');"{% endif %}>Mitrudern</a>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{# --- END Row Buttons --- #}
|
{# --- END Row Buttons --- #}
|
||||||
{# --- START Cox Buttons --- #}
|
{# --- START Cox Buttons --- #}
|
||||||
@ -155,7 +153,7 @@
|
|||||||
{% include "includes/cox-icon" %}
|
{% include "includes/cox-icon" %}
|
||||||
Abmelden
|
Abmelden
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% elif planned_event.planned_amount_cox > 0 %}
|
||||||
<a href="/cox/join/{{ planned_event.id }}"
|
<a href="/cox/join/{{ planned_event.id }}"
|
||||||
class="block btn {% if amount_cox_missing > 0 %} btn-dark {% else %} btn-gray {% endif %} btn-fw"
|
class="block btn {% if amount_cox_missing > 0 %} btn-dark {% else %} btn-gray {% endif %} btn-fw"
|
||||||
{% if planned_event.trip_type %}onclick="return confirm('{{ planned_event.trip_type.question }}');"{% endif %}>
|
{% if planned_event.trip_type %}onclick="return confirm('{{ planned_event.trip_type.question }}');"{% endif %}>
|
||||||
|
Loading…
Reference in New Issue
Block a user