39 Commits

Author SHA1 Message Date
59478a5ee1 Merge pull request 'fix tests' (#1099) from fix-tetss into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 23m18s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #1099
2025-07-17 21:49:20 +02:00
2f5d483bff fix tests
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2025-07-17 21:48:31 +02:00
7be9339645 Merge pull request 'merge functionality of kiosk + logged in -> allow kiosk to have fördernde people as rower in logbook' (#1097) from kiosk-allow-foerdernde into main
Some checks failed
CI/CD Pipeline / test (push) Failing after 25m29s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #1097
2025-07-13 19:52:33 +02:00
837d0febdf merge functionality of kiosk + logged in -> allow kiosk to have fördernde people as rower in logbook
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2025-07-13 19:49:46 +02:00
51c7cf28f8 Merge pull request 'foerderne user can do trips on the water' (#1094) from foerderne-user-can-do-trips into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 27m36s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 35m11s
Reviewed-on: #1094
2025-07-13 09:26:57 +02:00
80eca1a3b2 foerderne user can do trips on the water
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2025-07-13 09:22:47 +02:00
d1341006f7 Merge pull request 'allow to change from 'bootsfuehrer' to 'cox'' (#1090) from bootsman-to-cox into main
Some checks failed
CI/CD Pipeline / test (push) Failing after 32m16s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #1090
2025-07-03 11:03:50 +02:00
a534568a39 allow to change from 'bootsfuehrer' to 'cox'
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2025-07-03 11:02:59 +02:00
b4c04cbdd8 Merge pull request 'updates-meeting' (#1085) from updates-meeting into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 20m54s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #1085
2025-06-17 22:53:40 +02:00
1f0bfb04e4 more updates after meeting
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
2025-06-17 22:52:04 +02:00
86b8d3a30d make clear where note is displayed 2025-06-17 22:29:08 +02:00
da7a303efb Merge pull request 'fix(?) auto ci' (#1080) from fix-ci into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 16m53s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 7m13s
Reviewed-on: #1080
2025-06-13 11:08:03 +02:00
0a31410ca5 fix(?) auto ci
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2025-06-13 11:07:00 +02:00
f793cb4a9a Merge pull request 'log if a cox creates a trip' (#1076) from log-trip-creation into main
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
Reviewed-on: #1076
2025-06-09 08:36:49 +02:00
d3b2d78f9f log if a cox creates a trip
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
2025-06-09 08:33:50 +02:00
155adce2e9 Merge pull request 'add license' Fixes #1064' (#1071) from upd into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 14m4s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 7m0s
Reviewed-on: #1071
2025-05-29 16:06:34 +02:00
9548cb4f0b add license' Fixes #1064
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
2025-05-29 16:05:44 +02:00
c42713b86e Merge pull request 'promote calendar in welcome-mail; even more robust name checking' (#1069) from upd into main
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
Reviewed-on: #1069
2025-05-29 16:02:59 +02:00
d5a92d8f79 promote calendar in welcome-mail; even more robust name checking
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
2025-05-29 16:01:22 +02:00
aa3df2a294 Merge pull request 'use proper role instead of manully validating role' (#1066) from use-proper-role into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 16m17s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 13m21s
Reviewed-on: #1066
2025-05-29 12:12:54 +02:00
7a2743046d fix tests
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
2025-05-29 12:11:48 +02:00
7027145a9a use proper role instead of manully validating role
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2025-05-29 12:10:35 +02:00
782d68cd03 Merge pull request 'allow users name to start with ÄÜÖ' (#1063) from fix-uppercase-non-ascii-name into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 15m3s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 7m7s
Reviewed-on: #1063
2025-05-27 08:54:50 +02:00
c6a2b529c3 allow users name to start with ÄÜÖ
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2025-05-27 08:54:15 +02:00
b0b2ad2148 Merge pull request 'improve text' (#1061) from nicer-text into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 13m47s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 7m12s
Reviewed-on: #1061
2025-05-26 23:42:53 +02:00
09e06017c2 improve text
All checks were successful
CI/CD Pipeline / test (push) Successful in 25m27s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
2025-05-26 23:41:08 +02:00
34ade37f2d Merge pull request 'add docs' (#1057) from docs into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 12m47s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 7m0s
Reviewed-on: #1057
2025-05-22 13:26:01 +02:00
138c0598e6 add docs
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2025-05-22 13:25:14 +02:00
5b75ff5d38 Merge pull request 'add planned mod' (#1054) from restructure into main
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
Reviewed-on: #1054
2025-05-22 13:08:03 +02:00
a42e0b3ed3 add planned mod
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2025-05-22 13:06:26 +02:00
743359904a Merge pull request '[BUGFIX] add border top reservation' (#1052) from reservation-border into main
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #1052
2025-05-22 12:43:20 +02:00
f46ddf249a Merge pull request 'slight restructure of trip' (#1051) from restructure into main
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
Reviewed-on: #1051
2025-05-22 12:41:54 +02:00
bc6244bc03 slight restructure of trip
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2025-05-22 12:41:01 +02:00
Marie Birner
47e3d1b5b3 [BUGFIX] add border top reservation
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
2025-05-22 12:34:05 +02:00
d6b9a2f11b Merge pull request 'board members can delete trips, proper notification + succ message is created' (#1048) from board-can-delete-trips into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 14m11s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 25m27s
Reviewed-on: #1048
2025-05-21 09:58:20 +02:00
4e04b2b082 board members can delete trips, proper notification + succ message is created
All checks were successful
CI/CD Pipeline / test (push) Successful in 24m26s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
2025-05-21 09:56:45 +02:00
73a7abd418 Merge pull request 'allow scheckbuch finances editing via /user/fees' (#1046) from consistent-user-management into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 15m33s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 7m47s
Reviewed-on: #1046
2025-05-17 16:36:04 +02:00
abd58766d8 allow scheckbuch finances editing via /user/fees
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2025-05-17 16:34:50 +02:00
58a357fdb5 Merge pull request 'ernst + board got rowingbadge notification on every trip of ernst, bc last 'wanderfahrt' was removed' (#1044) from dont-repeatedly-get-price into main
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
Reviewed-on: #1044
2025-05-17 16:24:22 +02:00
37 changed files with 1000 additions and 531 deletions

View File

@@ -31,7 +31,7 @@ jobs:
- Run `cargo upgrade` to update version requirements in Cargo.toml
- Run `cargo update` to update Cargo.lock
branch: update-cargo-dependencies
delete-branch: true
delete-branch: false
- name: Create Pull Request Main
uses: https://git.hofer.link/philipp/create-pull-request@18ef1fdad70eec569ab10292c1fa79c1b5296370

287
LICENSE Normal file
View File

@@ -0,0 +1,287 @@
EUROPEAN UNION PUBLIC LICENCE v. 1.2
EUPL © the European Union 2007, 2016
This European Union Public Licence (the EUPL) applies to the Work (as defined
below) which is provided under the terms of this Licence. Any use of the Work,
other than as authorised under this Licence is prohibited (to the extent such
use is covered by a right of the copyright holder of the Work).
The Work is provided under the terms of this Licence when the Licensor (as
defined below) has placed the following notice immediately following the
copyright notice for the Work:
Licensed under the EUPL
or has expressed by any other means his willingness to license under the EUPL.
1. Definitions
In this Licence, the following terms have the following meaning:
- The Licence: this Licence.
- The Original Work: the work or software distributed or communicated by the
Licensor under this Licence, available as Source Code and also as Executable
Code as the case may be.
- Derivative Works: the works or software that could be created by the
Licensee, based upon the Original Work or modifications thereof. This Licence
does not define the extent of modification or dependence on the Original Work
required in order to classify a work as a Derivative Work; this extent is
determined by copyright law applicable in the country mentioned in Article 15.
- The Work: the Original Work or its Derivative Works.
- The Source Code: the human-readable form of the Work which is the most
convenient for people to study and modify.
- The Executable Code: any code which has generally been compiled and which is
meant to be interpreted by a computer as a program.
- The Licensor: the natural or legal person that distributes or communicates
the Work under the Licence.
- Contributor(s): any natural or legal person who modifies the Work under the
Licence, or otherwise contributes to the creation of a Derivative Work.
- The Licensee or You: any natural or legal person who makes any usage of
the Work under the terms of the Licence.
- Distribution or Communication: any act of selling, giving, lending,
renting, distributing, communicating, transmitting, or otherwise making
available, online or offline, copies of the Work or providing access to its
essential functionalities at the disposal of any other natural or legal
person.
2. Scope of the rights granted by the Licence
The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
sublicensable licence to do the following, for the duration of copyright vested
in the Original Work:
- use the Work in any circumstance and for all usage,
- reproduce the Work,
- modify the Work, and make Derivative Works based upon the Work,
- communicate to the public, including the right to make available or display
the Work or copies thereof to the public and perform publicly, as the case may
be, the Work,
- distribute the Work or copies thereof,
- lend and rent the Work or copies thereof,
- sublicense rights in the Work or copies thereof.
Those rights can be exercised on any media, supports and formats, whether now
known or later invented, as far as the applicable law permits so.
In the countries where moral rights apply, the Licensor waives his right to
exercise his moral right to the extent allowed by law in order to make effective
the licence of the economic rights here above listed.
The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to
any patents held by the Licensor, to the extent necessary to make use of the
rights granted on the Work under this Licence.
3. Communication of the Source Code
The Licensor may provide the Work either in its Source Code form, or as
Executable Code. If the Work is provided as Executable Code, the Licensor
provides in addition a machine-readable copy of the Source Code of the Work
along with each copy of the Work that the Licensor distributes or indicates, in
a notice following the copyright notice attached to the Work, a repository where
the Source Code is easily and freely accessible for as long as the Licensor
continues to distribute or communicate the Work.
4. Limitations on copyright
Nothing in this Licence is intended to deprive the Licensee of the benefits from
any exception or limitation to the exclusive rights of the rights owners in the
Work, of the exhaustion of those rights or of other applicable limitations
thereto.
5. Obligations of the Licensee
The grant of the rights mentioned above is subject to some restrictions and
obligations imposed on the Licensee. Those obligations are the following:
Attribution right: The Licensee shall keep intact all copyright, patent or
trademarks notices and all notices that refer to the Licence and to the
disclaimer of warranties. The Licensee must include a copy of such notices and a
copy of the Licence with every copy of the Work he/she distributes or
communicates. The Licensee must cause any Derivative Work to carry prominent
notices stating that the Work has been modified and the date of modification.
Copyleft clause: If the Licensee distributes or communicates copies of the
Original Works or Derivative Works, this Distribution or Communication will be
done under the terms of this Licence or of a later version of this Licence
unless the Original Work is expressly distributed only under this version of the
Licence — for example by communicating EUPL v. 1.2 only. The Licensee
(becoming Licensor) cannot offer or impose any additional terms or conditions on
the Work or Derivative Work that alter or restrict the terms of the Licence.
Compatibility clause: If the Licensee Distributes or Communicates Derivative
Works or copies thereof based upon both the Work and another work licensed under
a Compatible Licence, this Distribution or Communication can be done under the
terms of this Compatible Licence. For the sake of this clause, Compatible
Licence refers to the licences listed in the appendix attached to this Licence.
Should the Licensee's obligations under the Compatible Licence conflict with
his/her obligations under this Licence, the obligations of the Compatible
Licence shall prevail.
Provision of Source Code: When distributing or communicating copies of the Work,
the Licensee will provide a machine-readable copy of the Source Code or indicate
a repository where this Source will be easily and freely available for as long
as the Licensee continues to distribute or communicate the Work.
Legal Protection: This Licence does not grant permission to use the trade names,
trademarks, service marks, or names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the copyright notice.
6. Chain of Authorship
The original Licensor warrants that the copyright in the Original Work granted
hereunder is owned by him/her or licensed to him/her and that he/she has the
power and authority to grant the Licence.
Each Contributor warrants that the copyright in the modifications he/she brings
to the Work are owned by him/her or licensed to him/her and that he/she has the
power and authority to grant the Licence.
Each time You accept the Licence, the original Licensor and subsequent
Contributors grant You a licence to their contributions to the Work, under the
terms of this Licence.
7. Disclaimer of Warranty
The Work is a work in progress, which is continuously improved by numerous
Contributors. It is not a finished work and may therefore contain defects or
bugs inherent to this type of development.
For the above reason, the Work is provided under the Licence on an as is basis
and without warranties of any kind concerning the Work, including without
limitation merchantability, fitness for a particular purpose, absence of defects
or errors, accuracy, non-infringement of intellectual property rights other than
copyright as stated in Article 6 of this Licence.
This disclaimer of warranty is an essential part of the Licence and a condition
for the grant of any rights to the Work.
8. Disclaimer of Liability
Except in the cases of wilful misconduct or damages directly caused to natural
persons, the Licensor will in no event be liable for any direct or indirect,
material or moral, damages of any kind, arising out of the Licence or of the use
of the Work, including without limitation, damages for loss of goodwill, work
stoppage, computer failure or malfunction, loss of data or any commercial
damage, even if the Licensor has been advised of the possibility of such damage.
However, the Licensor will be liable under statutory product liability laws as
far such laws apply to the Work.
9. Additional agreements
While distributing the Work, You may choose to conclude an additional agreement,
defining obligations or services consistent with this Licence. However, if
accepting obligations, You may act only on your own behalf and on your sole
responsibility, not on behalf of the original Licensor or any other Contributor,
and only if You agree to indemnify, defend, and hold each Contributor harmless
for any liability incurred by, or claims asserted against such Contributor by
the fact You have accepted any warranty or additional liability.
10. Acceptance of the Licence
The provisions of this Licence can be accepted by clicking on an icon I agree
placed under the bottom of a window displaying the text of this Licence or by
affirming consent in any other similar way, in accordance with the rules of
applicable law. Clicking on that icon indicates your clear and irrevocable
acceptance of this Licence and all of its terms and conditions.
Similarly, you irrevocably accept this Licence and all of its terms and
conditions by exercising any rights granted to You by Article 2 of this Licence,
such as the use of the Work, the creation by You of a Derivative Work or the
Distribution or Communication by You of the Work or copies thereof.
11. Information to the public
In case of any Distribution or Communication of the Work by means of electronic
communication by You (for example, by offering to download the Work from a
remote location) the distribution channel or media (for example, a website) must
at least provide to the public the information requested by the applicable law
regarding the Licensor, the Licence and the way it may be accessible, concluded,
stored and reproduced by the Licensee.
12. Termination of the Licence
The Licence and the rights granted hereunder will terminate automatically upon
any breach by the Licensee of the terms of the Licence.
Such a termination will not terminate the licences of any person who has
received the Work from the Licensee under the Licence, provided such persons
remain in full compliance with the Licence.
13. Miscellaneous
Without prejudice of Article 9 above, the Licence represents the complete
agreement between the Parties as to the Work.
If any provision of the Licence is invalid or unenforceable under applicable
law, this will not affect the validity or enforceability of the Licence as a
whole. Such provision will be construed or reformed so as necessary to make it
valid and enforceable.
The European Commission may publish other linguistic versions or new versions of
this Licence or updated versions of the Appendix, so far this is required and
reasonable, without reducing the scope of the rights granted by the Licence. New
versions of the Licence will be published with a unique version number.
All linguistic versions of this Licence, approved by the European Commission,
have identical value. Parties can take advantage of the linguistic version of
their choice.
14. Jurisdiction
Without prejudice to specific agreement between parties,
- any litigation resulting from the interpretation of this License, arising
between the European Union institutions, bodies, offices or agencies, as a
Licensor, and any Licensee, will be subject to the jurisdiction of the Court
of Justice of the European Union, as laid down in article 272 of the Treaty on
the Functioning of the European Union,
- any litigation arising between other parties and resulting from the
interpretation of this License, will be subject to the exclusive jurisdiction
of the competent court where the Licensor resides or conducts its primary
business.
15. Applicable Law
Without prejudice to specific agreement between parties,
- this Licence shall be governed by the law of the European Union Member State
where the Licensor has his seat, resides or has his registered office,
- this licence shall be governed by Belgian law if the Licensor has no seat,
residence or registered office inside a European Union Member State.
Appendix
Compatible Licences according to Article 5 EUPL are:
- GNU General Public License (GPL) v. 2, v. 3
- GNU Affero General Public License (AGPL) v. 3
- Open Software License (OSL) v. 2.1, v. 3.0
- Eclipse Public License (EPL) v. 1.0
- CeCILL v. 2.0, v. 2.1
- Mozilla Public Licence (MPL) v. 2
- GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
- Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
works other than software
- European Union Public Licence (EUPL) v. 1.1, v. 1.2
- Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong
Reciprocity (LiLiQ-R+).
The European Commission may update this Appendix to later versions of the above
licences without producing a new version of the EUPL, as long as they provide
the rights granted in Article 2 of this Licence and protect the covered Source
Code from exclusive appropriation.
All other changes or additions to this Appendix require the production of a new
EUPL version.

View File

@@ -1,6 +1,7 @@
use std::ops::DerefMut;
use super::{
logbook::{Logbook, LogbookWithBoatAndRowers},
role::Role,
user::{ManageUserUser, User},
};
@@ -42,6 +43,7 @@ impl From<Activity> for ActivityWithDetails {
// TODO: add `reason` as additional db field, to be able to query and show this to the users
pub enum Reason<'a> {
Auth(ReasonAuth<'a>),
Logbook(ReasonLogbook<'a>),
// `User` changed the data of `User`, explanation in `String`
UserDataChange(&'a ManageUserUser, &'a User, String),
// New Note for User
@@ -55,10 +57,11 @@ impl From<Reason<'_>> for ActivityBuilder {
Reason::UserDataChange(changed_by, changed_user, explanation) => Self::new(&format!(
"{changed_by} hat die Daten von {changed_user} aktualisiert: {explanation}"
))
.relevant_for_user(changed_user),
.user(changed_user),
Reason::NewUserNote(changed_by, user, explanation) => {
Self::new(&format!("({changed_by}) {explanation}")).relevant_for_user(user)
Self::new(&format!("({changed_by}) {explanation}")).user(user)
}
Reason::Logbook(logbook) => logbook.into(),
}
}
}
@@ -83,18 +86,42 @@ impl From<ReasonAuth<'_>> for ActivityBuilder {
match value {
ReasonAuth::SuccLogin(user, agent) => {
Self::new(&format!("{user} hat sich eingeloggt (User-Agent: {agent})"))
.relevant_for_user(user)
.user(user)
.keep_until_days(7)
}
ReasonAuth::DeletedUserLogin(user) => Self::new(&format!(
"{user} wollte sich einloggen, klappte jedoch nicht weil der Account gelöscht wurde."
))
.relevant_for_user(user)
.user(user)
.keep_until_days(30),
ReasonAuth::WrongPw(user) => Self::new(&format!(
"User {user} wollte sich einloggen, hat jedoch das falsche Passwort angegeben."
))
.relevant_for_user(user)
.user(user)
.keep_until_days(7),
}
}
}
pub enum ReasonLogbook<'a> {
// `User` tried to login with `String` as UserAgent
BoardOrAdminDeleted(&'a User, &'a LogbookWithBoatAndRowers),
}
impl<'a> From<ReasonLogbook<'a>> for Reason<'a> {
fn from(logbook_reason: ReasonLogbook<'a>) -> Self {
Reason::Logbook(logbook_reason)
}
}
impl From<ReasonLogbook<'_>> for ActivityBuilder {
fn from(value: ReasonLogbook<'_>) -> Self {
match value {
ReasonLogbook::BoardOrAdminDeleted(user, logbook) => Self::new(&format!(
"{user} hat den Logbuch-Eintrag gelöscht: {logbook}"
))
.user(user)
.logbook(&logbook.logbook)
.keep_until_days(7),
}
}
@@ -118,7 +145,7 @@ impl ActivityBuilder {
}
#[must_use]
pub fn relevant_for_user(self, user: &User) -> Self {
pub fn user(self, user: &User) -> Self {
Self {
relevant_for: format!("{}user-{};", self.relevant_for, user.id),
..self
@@ -126,13 +153,21 @@ impl ActivityBuilder {
}
#[must_use]
pub fn relevant_for_role(self, role: &Role) -> Self {
pub fn role(self, role: &Role) -> Self {
Self {
relevant_for: format!("{}role-{};", self.relevant_for, role.id),
..self
}
}
#[must_use]
pub fn logbook(self, logbook: &Logbook) -> Self {
Self {
relevant_for: format!("{}logbook-{};", self.relevant_for, logbook.id),
..self
}
}
#[must_use]
pub fn keep_until_days(self, days: i64) -> Self {
let now = Utc::now().naive_utc();

View File

@@ -1,14 +1,15 @@
use std::ops::DerefMut;
use chrono::NaiveDateTime;
use rocket::FromForm;
use rocket::serde::{Deserialize, Serialize};
use rocket::FromForm;
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
use crate::model::boathouse::Boathouse;
use super::location::Location;
use super::user::User;
use std::fmt::Display;
#[derive(FromRow, Debug, Serialize, Deserialize, Eq, Hash, PartialEq, Clone)]
pub struct Boat {
@@ -31,6 +32,17 @@ pub struct Boat {
pub deleted: bool,
}
impl Display for Boat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let private_or_club_boat = if self.owner.is_some() {
"privat"
} else {
"Vereinsboot"
};
write!(f, "{} ({}, {private_or_club_boat})", self.name, self.cat())
}
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "lowercase")]
pub enum BoatDamage {
@@ -178,8 +190,10 @@ AND date('now') BETWEEN start_date AND end_date;",
"Vereinsfremde Boote".to_string()
} else if self.default_shipmaster_only_steering {
format!("{}+", self.amount_seats - 1)
} else {
} else if self.skull {
format!("{}x", self.amount_seats)
} else {
format!("{}-", self.amount_seats)
}
}

View File

@@ -1,7 +1,10 @@
use rocket::serde::{Deserialize, Serialize};
use sqlx::{FromRow, SqlitePool};
use crate::tera::board::boathouse::FormBoathouseToAdd;
use crate::{
model::{log::Log, user::AllowedToUpdateBoathouse},
tera::board::boathouse::FormBoathouseToAdd,
};
use super::boat::Boat;
@@ -114,7 +117,11 @@ impl Boathouse {
BoathouseAisles::from(db, boathouses).await
}
pub async fn create(db: &SqlitePool, data: FormBoathouseToAdd) -> Result<(), String> {
pub async fn create(
db: &SqlitePool,
changed_by: &AllowedToUpdateBoathouse,
data: FormBoathouseToAdd,
) -> Result<(), String> {
sqlx::query!(
"INSERT INTO boathouse(boat_id, aisle, side, level) VALUES (?,?,?,?)",
data.boat_id,
@@ -125,6 +132,17 @@ impl Boathouse {
.execute(db)
.await
.map_err(|e| e.to_string())?;
let boat = Boat::find_by_id(db, data.boat_id).await.unwrap();
Log::create(
db,
format!(
"{changed_by} hat das Boot {boat} auf den Gang {}, Seite {}, und Höhe {} 'gelegt'.",
data.aisle, data.side, data.level
),
)
.await;
Ok(())
}
@@ -135,10 +153,20 @@ impl Boathouse {
.ok()
}
pub async fn delete(&self, db: &SqlitePool) {
pub async fn delete(&self, db: &SqlitePool, changed_by: &AllowedToUpdateBoathouse) {
sqlx::query!("DELETE FROM boathouse WHERE id=?", self.id)
.execute(db)
.await
.unwrap(); //Okay, because we can only create a Boat of a valid id
let boat = Boat::find_by_id(db, self.boat_id as i32).await.unwrap();
Log::create(
db,
format!(
"{changed_by} hat das Boot {boat} von Gang {}, Seite {}, und Höhe {} gelöscht.",
self.aisle, self.side, self.level
),
)
.await;
}
}

View File

@@ -1,4 +1,4 @@
use std::ops::DerefMut;
use std::{fmt::Display, ops::DerefMut};
use chrono::{Datelike, Duration, Local, NaiveDateTime};
use rocket::FromForm;
@@ -6,8 +6,15 @@ use serde::{Deserialize, Serialize};
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
use super::{
boat::Boat, log::Log, notification::Notification, role::Role, rower::Rower, user::User,
activity::{ActivityBuilder, ReasonLogbook},
boat::Boat,
log::Log,
notification::Notification,
role::Role,
rower::Rower,
user::{User, VorstandUser},
};
use crate::model::user::VecUser;
#[derive(FromRow, Serialize, Deserialize, Clone, Debug)]
pub struct Logbook {
@@ -115,6 +122,54 @@ pub struct LogbookWithBoatAndRowers {
pub rowers: Vec<User>,
}
impl Display for LogbookWithBoatAndRowers {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if let Some(arrival) = self.logbook.arrival {
let departure_date = format!("{}", self.logbook.departure.format("%Y-%m-%d"));
let arrival_date = format!("{}", arrival.format("%Y-%m-%d"));
if departure_date == arrival_date {
write!(
f,
"Datum: {}: Start: {}, Ende: {}; ",
&self.logbook.departure.format("%d. %m. %Y"),
&self.logbook.departure.format("%H:%M"),
&arrival.format("%H:%M")
)?;
} else {
write!(
f,
"{} - {}; ",
&self.logbook.departure.format("%d. %m. %Y"),
&arrival.format("%d. %m. %Y"),
)?;
}
} else {
write!(
f,
"Start: {}",
&self.logbook.departure.format("%d. %m. %Y %H:%M")
)?;
}
if let Some(destination) = &self.logbook.destination {
write!(f, "Ziel: {destination}; ")?;
}
write!(f, "Boot: {}; ", self.boat)?;
if let Some(distance) = self.logbook.distance_in_km {
write!(f, "Distanz: {distance} km; ")?;
}
write!(f, "Schiffsführer: {}; ", self.shipmaster_user)?;
write!(f, "Steuerperson: {}; ", self.steering_user)?;
write!(f, "Rudernde: {}; ", VecUser(&self.rowers))?;
if let Some(comments) = &self.logbook.comments {
if !comments.trim().is_empty() {
write!(f, "Kommentar: {comments}; ")?;
}
}
Ok(())
}
}
impl LogbookWithBoatAndRowers {
pub(crate) async fn from(db: &SqlitePool, log: Logbook) -> Self {
let mut tx = db.begin().await.unwrap();
@@ -138,11 +193,6 @@ impl LogbookWithBoatAndRowers {
}
}
#[derive(Debug, PartialEq)]
pub enum LogbookAdminUpdateError {
NotAllowed,
}
#[derive(Debug, PartialEq)]
pub enum LogbookUpdateError {
NotYourEntry,
@@ -579,16 +629,7 @@ ORDER BY departure DESC
Ok(ret)
}
pub async fn update(
&self,
db: &SqlitePool,
data: LogToUpdate,
user: &User,
) -> Result<(), LogbookAdminUpdateError> {
if !user.has_role(db, "Vorstand").await {
return Err(LogbookAdminUpdateError::NotAllowed);
}
pub async fn update(&self, db: &SqlitePool, data: LogToUpdate, changed_by: &VorstandUser) {
sqlx::query!(
"UPDATE logbook SET boat_id=?, shipmaster=?, steering_person=?, shipmaster_only_steering=?, departure=?, arrival=?, destination=?, distance_in_km=?, comments=?, logtype=? WHERE id=?",
data.boat_id,
@@ -605,7 +646,12 @@ ORDER BY departure DESC
)
.execute(db)
.await.unwrap();
Ok(())
Log::create(
db,
format!("{changed_by} updated log entry={:?} to {:?}", self, data),
)
.await;
}
async fn remove_rowers(&self, db: &mut Transaction<'_, Sqlite>) {
@@ -807,43 +853,22 @@ ORDER BY departure DESC
}
pub async fn delete(&self, db: &SqlitePool, user: &User) -> Result<(), LogbookDeleteError> {
Log::create(db, format!("{} deleted trip: {self:?}", user.name)).await;
if self.arrival.is_none() {
if user.has_role(db, "admin").await
|| user.has_role(db, "Vorstand").await
|| user.id == self.shipmaster
{
Log::create(db, format!("{} deleted trip: {self:?}", user.name)).await;
let now = Local::now().naive_local();
let difference = now - self.departure;
if difference > Duration::hours(1) {
let vorstand = Role::find_by_name(db, "Vorstand").await.unwrap();
let logbook = LogbookWithBoatAndRowers::from(db, self.clone()).await;
let mut msg = format!(
"{} hat folgenden Logbuch-Eintrag jetzt gelöscht, welcher bereits vor über einer Stunde begonnen wurde: Schiffsführer: {}, Steuerperson: {}, Abfahrt: {}",
user.name,
logbook.steering_user.name,
logbook.steering_user.name,
logbook.logbook.departure.format("%Y-%m-%d %H:%M")
);
if let Some(destination) = logbook.logbook.destination {
msg.push_str(&format!(", Ziel: {}", destination));
} else {
msg.push_str(", kein Ziel eingegeben");
}
msg.push_str(", Ruderer: ");
let mut it = logbook.rowers.clone().into_iter().peekable();
while let Some(rower) = it.next() {
msg.push_str(&rower.name);
if it.peek().is_some() {
msg.push_str(" + ");
}
}
Notification::create_for_role(
db,
&vorstand,
&msg,
&format!("{user} hat folgenden Logbuch-Eintrag jetzt gelöscht, welcher bereits vor über einer Stunde begonnen wurde: {logbook}"),
"Ungewöhnliches Verhalten",
None,
None,
@@ -858,8 +883,24 @@ ORDER BY departure DESC
return Ok(());
}
} else {
// Only admins can delete completed logbook entries
if user.has_role(db, "admin").await {
// Only admins+Vorstand can delete completed logbook entries
if user.has_role(db, "admin").await || user.has_role(db, "Vorstand").await {
let logbookdetails = LogbookWithBoatAndRowers::from(db, self.clone()).await;
ActivityBuilder::from(ReasonLogbook::BoardOrAdminDeleted(user, &logbookdetails))
.save(db)
.await;
let vorstand = Role::find_by_name(db, "Vorstand").await.unwrap();
Notification::create_for_role(
db,
&vorstand,
&format!("{user} hat den Logbuch-Eintrag gelöscht: {logbookdetails}"),
"Logbuch gelöscht",
None,
None,
)
.await;
sqlx::query!("DELETE FROM logbook WHERE id=?", self.id)
.execute(db)
.await

View File

@@ -162,7 +162,7 @@ impl Mail {
}
}
if user.has_role(db, "schnupperant").await {
if user.has_role(db, "schnupperant").await || user.has_role(db, "scheckbuch").await {
continue;
}
@@ -261,7 +261,7 @@ Der Vorstand");
ActivityBuilder::new(&format!(
"{user} hat die Info-Mail bzgl. Gebühren gesendet bekommen."
))
.relevant_for_user(&user)
.user(&user)
.save(db)
.await;
}
@@ -279,7 +279,7 @@ Der Vorstand");
}
}
if user.has_role(db, "schnupperant").await {
if user.has_role(db, "schnupperant").await || user.has_role(db, "scheckbuch").await {
continue;
}
@@ -388,7 +388,7 @@ Der Vorstand");
ActivityBuilder::new(&format!(
"{user} hat die Mahn-Mail bzgl. Gebühren gesendet bekommen."
))
.relevant_for_user(&user)
.user(&user)
.save(db)
.await;
}

View File

@@ -5,13 +5,12 @@ use waterlevel::WaterlevelDay;
use crate::AMOUNT_DAYS_TO_SHOW_TRIPS_AHEAD;
use self::{
use self::{waterlevel::Waterlevel, weather::Weather};
use boatreservation::{BoatReservation, BoatReservationWithDetails};
use planned::{
event::{Event, EventWithDetails},
trip::{Trip, TripWithDetails},
waterlevel::Waterlevel,
weather::Weather,
};
use boatreservation::{BoatReservation, BoatReservationWithDetails};
use std::collections::HashMap;
pub mod activity;
@@ -20,7 +19,6 @@ pub mod boatdamage;
pub mod boathouse;
pub mod boatreservation;
pub mod distance;
pub mod event;
pub mod family;
pub mod location;
pub mod log;
@@ -29,16 +27,13 @@ pub mod logtype;
pub mod mail;
pub mod notification;
pub mod personal;
pub mod planned;
pub mod role;
pub mod rower;
pub mod stat;
pub mod trailer;
pub mod trailerreservation;
pub mod trip;
pub mod tripdetails;
pub mod triptype;
pub mod user;
pub mod usertrip;
pub mod waterlevel;
pub mod weather;

View File

@@ -5,7 +5,7 @@ use regex::Regex;
use serde::{Deserialize, Serialize};
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
use super::{role::Role, user::User, usertrip::UserTrip};
use super::{planned::usertrip::UserTrip, role::Role, user::User};
#[derive(FromRow, Debug, Serialize, Deserialize, Clone)]
pub struct Notification {
@@ -226,13 +226,15 @@ ORDER BY read_at DESC, created_at DESC;
mod test {
use crate::{
model::{
event::{Event, EventUpdate, Registration},
notification::Notification,
planned::{
event::{Event, EventUpdate, Registration},
trip::Trip,
tripdetails::{TripDetails, TripDetailsToAdd},
user::{EventUser, SteeringUser, User},
usertrip::UserTrip,
},
user::{EventUser, SteeringUser, User},
},
testdb,
};

View File

@@ -1,9 +1,17 @@
use std::io::Write;
use ics::{ICalendar, components::Property};
use ics::{
ICalendar,
components::Property,
properties::{DtEnd, DtStart, Summary},
};
use sqlx::SqlitePool;
use crate::model::{event::Event, trip::Trip, user::User};
use crate::model::{
planned::{event::Event, trip::Trip},
user::User,
};
use chrono::{Duration, NaiveTime};
pub(crate) async fn get_personal_cal(db: &SqlitePool, user: &User) -> String {
let mut calendar = ICalendar::new("2.0", "ics-rs");
@@ -25,3 +33,125 @@ pub(crate) async fn get_personal_cal(db: &SqlitePool, user: &User) -> String {
write!(&mut buf, "{}", calendar).unwrap();
String::from_utf8(buf).unwrap()
}
impl Trip {
pub(crate) async fn get_vevent<'a>(self, db: &'a SqlitePool, user: &'a User) -> ics::Event<'a> {
let mut vevent =
ics::Event::new(format!("trip-{}@rudernlinz.at", self.id), "19900101T180000");
let time_str = self.planned_starting_time.replace(':', "");
let formatted_time = if time_str.len() == 3 {
format!("0{}", time_str)
} else {
time_str
};
vevent.push(DtStart::new(format!(
"{}T{}00",
self.day.replace('-', ""),
formatted_time
)));
let original_time = NaiveTime::parse_from_str(&self.planned_starting_time, "%H:%M")
.expect("Failed to parse time");
let long_trip = match self.trip_type(db).await {
Some(a) if a.name == "Lange Ausfahrt" => true,
_ => false,
};
let later_time = if long_trip {
original_time + Duration::hours(6)
} else {
original_time + Duration::hours(3)
};
if later_time > original_time {
// Check if no day-overflow
let time_three_hours_later = later_time.format("%H%M").to_string();
vevent.push(DtEnd::new(format!(
"{}T{}00",
self.day.replace('-', ""),
time_three_hours_later
)));
}
let mut name = String::new();
if self.is_cancelled() {
name.push_str("ABGESAGT");
if let Some(notes) = &self.notes {
if !notes.is_empty() {
name.push_str(&format!(" (Grund: {notes})"))
}
}
name.push_str("! :-( ");
}
if self.cox_id == user.id {
name.push_str("Ruderausfahrt (selber ausgeschrieben)");
} else {
name.push_str(&format!("Ruderausfahrt mit {} ", self.cox_name));
}
vevent.push(Summary::new(name));
vevent
}
}
impl Event {
pub(crate) async fn get_vevent(self, db: &SqlitePool) -> ics::Event {
let mut vevent = ics::Event::new(
format!("event-{}@rudernlinz.at", self.id),
"19900101T180000",
);
let time_str = self.planned_starting_time.replace(':', "");
let formatted_time = if time_str.len() == 3 {
format!("0{}", time_str)
} else {
time_str.clone() // TODO: remove again
};
vevent.push(DtStart::new(format!(
"{}T{}00",
self.day.replace('-', ""),
formatted_time
)));
let original_time = NaiveTime::parse_from_str(&self.planned_starting_time, "%H:%M")
.expect("Failed to parse time");
let long_trip = match self.trip_type(db).await {
Some(a) if a.name == "Lange Ausfahrt" => true,
_ => false,
};
let later_time = if long_trip {
original_time + Duration::hours(6)
} else {
original_time + Duration::hours(3)
};
if later_time > original_time {
// Check if no day-overflow
let time_three_hours_later = later_time.format("%H%M").to_string();
vevent.push(DtEnd::new(format!(
"{}T{}00",
self.day.replace('-', ""),
time_three_hours_later
)));
}
let tripdetails = self.trip_details(db).await;
let mut name = String::new();
if self.is_cancelled() {
name.push_str("ABGESAGT");
if let Some(notes) = &tripdetails.notes {
if !notes.is_empty() {
name.push_str(&format!(" (Grund: {notes})"))
}
}
name.push_str("! :-( ");
}
name.push_str(&format!("{} ", self.name));
if let Some(triptype) = tripdetails.triptype(db).await {
name.push_str(&format!("{} ", triptype.name))
}
vevent.push(Summary::new(name));
vevent
}
}

View File

@@ -1,22 +1,19 @@
use std::io::Write;
use chrono::{Duration, NaiveDate, NaiveTime};
use ics::{
ICalendar,
properties::{DtEnd, DtStart, Summary},
};
use chrono::NaiveDate;
use ics::ICalendar;
use serde::Serialize;
use sqlx::{FromRow, Row, SqlitePool};
use super::{
use super::{tripdetails::TripDetails, triptype::TripType};
use crate::model::{
log::Log,
notification::Notification,
role::Role,
tripdetails::TripDetails,
triptype::TripType,
user::{EventUser, User},
};
/// DB structure of an event
#[derive(Serialize, Clone, FromRow, Debug, PartialEq)]
pub struct Event {
pub id: i64,
@@ -142,7 +139,7 @@ WHERE planned_event.id like ?
.ok()
}
async fn trip_type(&self, db: &SqlitePool) -> Option<TripType> {
pub(crate) async fn trip_type(&self, db: &SqlitePool) -> Option<TripType> {
if let Some(trip_type_id) = self.trip_type_id {
TripType::find_by_id(db, trip_type_id).await
} else {
@@ -474,66 +471,6 @@ WHERE trip_details.id=?
String::from_utf8(buf).unwrap()
}
pub(crate) async fn get_vevent(self, db: &SqlitePool) -> ics::Event {
let mut vevent = ics::Event::new(
format!("event-{}@rudernlinz.at", self.id),
"19900101T180000",
);
let time_str = self.planned_starting_time.replace(':', "");
let formatted_time = if time_str.len() == 3 {
format!("0{}", time_str)
} else {
time_str.clone() // TODO: remove again
};
vevent.push(DtStart::new(format!(
"{}T{}00",
self.day.replace('-', ""),
formatted_time
)));
let original_time = NaiveTime::parse_from_str(&self.planned_starting_time, "%H:%M")
.expect("Failed to parse time");
let long_trip = match self.trip_type(db).await {
Some(a) if a.name == "Lange Ausfahrt" => true,
_ => false,
};
let later_time = if long_trip {
original_time + Duration::hours(6)
} else {
original_time + Duration::hours(3)
};
if later_time > original_time {
// Check if no day-overflow
let time_three_hours_later = later_time.format("%H%M").to_string();
vevent.push(DtEnd::new(format!(
"{}T{}00",
self.day.replace('-', ""),
time_three_hours_later
)));
}
let tripdetails = self.trip_details(db).await;
let mut name = String::new();
if self.is_cancelled() {
name.push_str("ABGESAGT");
if let Some(notes) = &tripdetails.notes {
if !notes.is_empty() {
name.push_str(&format!(" (Grund: {notes})"))
}
}
name.push_str("! :-( ");
}
name.push_str(&format!("{} ", self.name));
if let Some(triptype) = tripdetails.triptype(db).await {
name.push_str(&format!("{} ", triptype.name))
}
vevent.push(Summary::new(name));
vevent
}
pub async fn trip_details(&self, db: &SqlitePool) -> TripDetails {
TripDetails::find_by_id(db, self.trip_details_id)
.await
@@ -545,7 +482,7 @@ WHERE trip_details.id=?
mod test {
use crate::{
model::{
tripdetails::TripDetails,
planned::tripdetails::TripDetails,
user::{EventUser, User},
},
testdb,

19
src/model/planned/mod.rs Normal file
View File

@@ -0,0 +1,19 @@
//! This module contains everything for managing planned trips and events.
//! `Cox` can create trips, `EventUser` can create events. Rowers can join those.
/// Events can be created by everyone who has the `manage_events` role. They are used if multiple coxes are needed, e.g. for "Fetzenfahrt", "Anrudern", .... Additionally, events are shown in public calendar (e.g. on the website).
pub mod event;
/// Trips can be created by every cox. They are "simple", every-day trips.
pub mod trip;
/// Extracts the common data for both Trips and Events. Rower can register using this.
pub mod tripdetails;
/// Type of the trip
pub mod triptype;
/// Associative table between `User` and `TripDetails`. Its functionality should probably move into
/// those files.
// TODO: make this mod unnecessary
pub mod usertrip;

View File

@@ -0,0 +1,79 @@
use super::Trip;
use crate::model::{
log::Log,
notification::Notification,
planned::{tripdetails::TripDetails, triptype::TripType},
user::{ErgoUser, SteeringUser, User},
};
use sqlx::SqlitePool;
impl Trip {
/// Cox decides to create own trip.
pub async fn new_own(db: &SqlitePool, cox: &SteeringUser, trip_details: TripDetails) {
Self::perform_new(db, &cox.user, trip_details).await
}
/// ErgoUser decides to create ergo 'trip'. Returns false, if trip is not a ergo-session (and
/// thus User is not allowed to create such a trip)
pub async fn new_own_ergo(db: &SqlitePool, ergo: &ErgoUser, trip_details: TripDetails) -> bool {
if let Some(typ) = trip_details.triptype(db).await {
let allowed_type = TripType::find_by_id(db, 4).await.unwrap();
if typ == allowed_type {
Self::perform_new(db, &ergo.user, trip_details).await;
return true;
}
}
false
}
async fn perform_new(db: &SqlitePool, user: &User, trip_details: TripDetails) {
let _ = sqlx::query!(
"INSERT INTO trip (cox_id, trip_details_id) VALUES(?, ?)",
user.id,
trip_details.id
)
.execute(db)
.await;
Log::create(db, format!("{user} created a new trip: {trip_details}")).await;
Self::notify_trips_same_datetime(db, trip_details, user).await;
}
async fn notify_trips_same_datetime(db: &SqlitePool, trip_details: TripDetails, user: &User) {
let same_starting_datetime = TripDetails::find_by_startingdatetime(
db,
trip_details.day,
trip_details.planned_starting_time,
)
.await;
for notify in same_starting_datetime {
// don't notify oneself
if notify.id == trip_details.id {
continue;
}
// don't notify people who have cancelled their trip
if notify.cancelled() {
continue;
}
if let Some(trip) = Trip::find_by_trip_details(db, notify.id).await {
let user_earlier_trip = User::find_by_id(db, trip.cox_id as i32).await.unwrap();
Notification::create(
db,
&user_earlier_trip,
&format!(
"{user} hat eine Ausfahrt zur selben Zeit ({} um {}) wie du erstellt",
trip.day, trip.planned_starting_time
),
"Neue Ausfahrt zur selben Zeit",
None,
None,
)
.await;
}
}
}
}

View File

@@ -1,25 +1,28 @@
use chrono::{Duration, Local, NaiveDate, NaiveTime};
use ics::properties::{DtEnd, DtStart, Summary};
use chrono::{Local, NaiveDate};
use serde::Serialize;
use sqlx::SqlitePool;
mod create;
use super::{
event::{Event, Registration},
log::Log,
notification::Notification,
tripdetails::TripDetails,
triptype::TripType,
user::{ErgoUser, SteeringUser, User},
usertrip::UserTrip,
};
use crate::model::{
log::Log,
notification::Notification,
user::{SteeringUser, User},
};
#[derive(Serialize, Clone, Debug)]
pub struct Trip {
id: i64,
pub id: i64,
pub cox_id: i64,
cox_name: String,
pub cox_name: String,
trip_details_id: Option<i64>,
planned_starting_time: String,
pub planned_starting_time: String,
pub max_people: i64,
pub day: String,
pub notes: Option<String>,
@@ -69,65 +72,6 @@ impl TripWithDetails {
}
impl Trip {
/// Cox decides to create own trip.
pub async fn new_own(db: &SqlitePool, cox: &SteeringUser, trip_details: TripDetails) {
Self::perform_new(db, &cox.user, trip_details).await
}
pub async fn new_own_ergo(db: &SqlitePool, ergo: &ErgoUser, trip_details: TripDetails) {
let typ = trip_details.triptype(db).await;
if let Some(typ) = typ {
let allowed_type = TripType::find_by_id(db, 4).await.unwrap();
if typ == allowed_type {
Self::perform_new(db, &ergo.user, trip_details).await;
}
}
}
async fn perform_new(db: &SqlitePool, user: &User, trip_details: TripDetails) {
let _ = sqlx::query!(
"INSERT INTO trip (cox_id, trip_details_id) VALUES(?, ?)",
user.id,
trip_details.id
)
.execute(db)
.await;
let same_starting_datetime = TripDetails::find_by_startingdatetime(
db,
trip_details.day,
trip_details.planned_starting_time,
)
.await;
for notify in same_starting_datetime {
// don't notify oneself
if notify.id == trip_details.id {
continue;
}
// don't notify people who have cancelled their trip
if notify.cancelled() {
continue;
}
if let Some(trip) = Trip::find_by_trip_details(db, notify.id).await {
let user_earlier_trip = User::find_by_id(db, trip.cox_id as i32).await.unwrap();
Notification::create(
db,
&user_earlier_trip,
&format!(
"{} hat eine Ausfahrt zur selben Zeit ({} um {}) wie du erstellt",
user.name, trip.day, trip.planned_starting_time
),
"Neue Ausfahrt zur selben Zeit",
None,
None,
)
.await;
}
}
}
pub async fn find_by_trip_details(db: &SqlitePool, tripdetails_id: i64) -> Option<Self> {
sqlx::query_as!(
Self,
@@ -145,7 +89,7 @@ WHERE trip_details.id=?
.ok()
}
async fn trip_type(&self, db: &SqlitePool) -> Option<TripType> {
pub(crate) async fn trip_type(&self, db: &SqlitePool) -> Option<TripType> {
if let Some(trip_type_id) = self.trip_type_id {
TripType::find_by_id(db, trip_type_id).await
} else {
@@ -153,64 +97,6 @@ WHERE trip_details.id=?
}
}
pub(crate) async fn get_vevent<'a>(self, db: &'a SqlitePool, user: &'a User) -> ics::Event<'a> {
let mut vevent =
ics::Event::new(format!("trip-{}@rudernlinz.at", self.id), "19900101T180000");
let time_str = self.planned_starting_time.replace(':', "");
let formatted_time = if time_str.len() == 3 {
format!("0{}", time_str)
} else {
time_str
};
vevent.push(DtStart::new(format!(
"{}T{}00",
self.day.replace('-', ""),
formatted_time
)));
let original_time = NaiveTime::parse_from_str(&self.planned_starting_time, "%H:%M")
.expect("Failed to parse time");
let long_trip = match self.trip_type(db).await {
Some(a) if a.name == "Lange Ausfahrt" => true,
_ => false,
};
let later_time = if long_trip {
original_time + Duration::hours(6)
} else {
original_time + Duration::hours(3)
};
if later_time > original_time {
// Check if no day-overflow
let time_three_hours_later = later_time.format("%H%M").to_string();
vevent.push(DtEnd::new(format!(
"{}T{}00",
self.day.replace('-', ""),
time_three_hours_later
)));
}
let mut name = String::new();
if self.is_cancelled() {
name.push_str("ABGESAGT");
if let Some(notes) = &self.notes {
if !notes.is_empty() {
name.push_str(&format!(" (Grund: {notes})"))
}
}
name.push_str("! :-( ");
}
if self.cox_id == user.id {
name.push_str("Ruderausfahrt (selber ausgeschrieben)");
} else {
name.push_str(&format!("Ruderausfahrt mit {} ", self.cox_name));
}
vevent.push(Summary::new(name));
vevent
}
pub async fn all(db: &SqlitePool) -> Vec<Self> {
sqlx::query_as!(
Self,
@@ -491,7 +377,7 @@ WHERE day=?
trips
}
fn is_cancelled(&self) -> bool {
pub(crate) fn is_cancelled(&self) -> bool {
self.max_people == -1
}
}
@@ -527,13 +413,15 @@ pub enum TripUpdateError {
mod test {
use crate::{
model::{
event::Event,
notification::Notification,
planned::{
event::Event,
trip::{self, TripDeleteError},
tripdetails::TripDetails,
user::{SteeringUser, User},
usertrip::UserTrip,
},
user::{SteeringUser, User},
},
testdb,
};

View File

@@ -1,14 +1,14 @@
use crate::model::user::User;
use crate::model::{notification::Notification, user::User};
use chrono::{Local, NaiveDate};
use rocket::FromForm;
use serde::{Deserialize, Serialize};
use sqlx::{FromRow, SqlitePool};
use super::{
notification::Notification,
trip::{Trip, TripWithDetails},
triptype::TripType,
};
use std::fmt::Display;
#[derive(FromRow, Debug, Serialize, Deserialize)]
pub struct TripDetails {
@@ -23,6 +23,20 @@ pub struct TripDetails {
pub is_locked: bool,
}
impl Display for TripDetails {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&format!(
"Ausfahrt am {} um {} mit {} Personen",
self.day, self.planned_starting_time, self.max_people
))?;
if let Some(notes) = &self.notes {
f.write_str(&format!(" Notizen: {notes}"))?;
}
Ok(())
}
}
#[derive(FromForm, Serialize)]
pub struct TripDetailsToAdd<'r> {
//TODO: properly parse `planned_starting_time`
@@ -303,7 +317,7 @@ pub(crate) enum Action {
#[cfg(test)]
mod test {
use crate::{model::tripdetails::TripDetailsToAdd, testdb};
use crate::{model::planned::tripdetails::TripDetailsToAdd, testdb};
use super::TripDetails;
use sqlx::SqlitePool;

View File

@@ -2,12 +2,14 @@ use serde::{Deserialize, Serialize};
use sqlx::{FromRow, SqlitePool};
use super::{
notification::Notification,
trip::{Trip, TripWithDetails},
tripdetails::TripDetails,
};
use crate::model::{
notification::Notification,
planned::tripdetails::{Action, CoxAtTrip::Yes},
user::{SteeringUser, User},
};
use crate::model::tripdetails::{Action, CoxAtTrip::Yes};
#[derive(FromRow, Debug, Serialize, Deserialize, Clone)]
pub struct UserTrip {
@@ -270,8 +272,10 @@ pub enum UserTripDeleteError {
mod test {
use crate::{
model::{
event::Event, trip::Trip, tripdetails::TripDetails, user::SteeringUser,
usertrip::UserTripError,
planned::{
event::Event, trip::Trip, tripdetails::TripDetails, usertrip::UserTripError,
},
user::SteeringUser,
},
testdb,
};

View File

@@ -158,7 +158,7 @@ WHERE name like ?
ActivityBuilder::new(&format!(
"{updated_by} hat Rolle {self} von {self:#?} auf FORMATTED_NAME={formatted_name}, DESC={desc} aktualisiert."
)).relevant_for_role(self).save(db).await;
)).role(self).save(db).await;
Ok(())
}

View File

@@ -138,10 +138,7 @@ impl User {
None => format!("{updated_by} hat eine Adresse für {self} hinzugefügt: {new_address}"),
};
ActivityBuilder::new(&msg)
.relevant_for_user(self)
.save(db)
.await;
ActivityBuilder::new(&msg).user(self).save(db).await;
}
pub(crate) async fn update_nickname(
@@ -174,10 +171,7 @@ impl User {
"{updated_by} hat einen neuen Spitznamen für {self} hinzugefügt: {new_nickname}"
),
};
ActivityBuilder::new(&msg)
.relevant_for_user(self)
.save(db)
.await;
ActivityBuilder::new(&msg).user(self).save(db).await;
Ok(())
}
@@ -206,10 +200,7 @@ impl User {
),
};
ActivityBuilder::new(&msg)
.relevant_for_user(self)
.save(db)
.await;
ActivityBuilder::new(&msg).user(self).save(db).await;
}
pub(crate) async fn update_birthdate(
@@ -236,10 +227,7 @@ impl User {
}
};
ActivityBuilder::new(&msg)
.relevant_for_user(self)
.save(db)
.await;
ActivityBuilder::new(&msg).user(self).save(db).await;
}
pub(crate) async fn update_family(
@@ -261,7 +249,7 @@ impl User {
ActivityBuilder::new(&format!(
"{updated_by} hat {self} zu einer Familie hinzugefügt."
))
.relevant_for_user(self)
.user(self)
.save(db)
.await;
} else {
@@ -272,7 +260,7 @@ impl User {
ActivityBuilder::new(&format!(
"{updated_by} hat die Familienzugehörigkeit von {self} gelöscht."
))
.relevant_for_user(self)
.user(self)
.save(db)
.await;
};
@@ -318,7 +306,7 @@ impl User {
)
.await;
ActivityBuilder::new(&format!("{updated_by} hat {self} zur Steuerperson gemacht"))
.relevant_for_user(self)
.user(self)
.save(db)
.await;
}
@@ -337,7 +325,7 @@ impl User {
)
.await;
ActivityBuilder::new(&format!("{updated_by} hat {self} zum Bootsführer gemacht"))
.relevant_for_user(self)
.user(self)
.save(db)
.await;
}
@@ -354,12 +342,33 @@ impl User {
None,
)
.await;
ActivityBuilder::new(&format!("{updated_by} hat {self} zum normalen Mitglied gemacht (keine Steuerperson/Schiffsführer mehr)"))
.relevant_for_user(self)
ActivityBuilder::new(&format!("{updated_by} hat {self} zum normalen Mitglied gemacht (keine Steuerperson/Bootsführer mehr)"))
.user(self)
.save(db)
.await;
}
}
(old, new) if old == Some(bootsfuehrer.clone()) && new == Some(cox.clone()) => {
self.remove_role(db, updated_by, &bootsfuehrer).await?;
self.add_role(db, updated_by, &cox).await?;
Notification::create_for_role(
db,
&member,
&format!(
"Lieber Vorstand, {self} ist ab sofort kein Bootsführer:in mehr, sondern 'nur' mehr eine Steuerperson."
),
"Bootsführer--",
None,
None,
)
.await;
ActivityBuilder::new(&format!(
"{updated_by} hat {self} zur Steuerperson gemacht (kein Bootsführer mehr)"
))
.user(self)
.save(db)
.await;
}
(old, new) => return Err(format!("Not allowed to change from {old:?} to {new:?}")),
};
@@ -392,7 +401,7 @@ impl User {
ActivityBuilder::new(&format!(
"{updated_by} hat die Ermäßigung von {self} von {old} auf {new} geändert"
))
.relevant_for_user(self)
.user(self)
.save(db)
.await;
@@ -424,7 +433,7 @@ impl User {
ActivityBuilder::new(&format!(
"{updated_by} hat die Rolle {role} von {self} entfernt."
))
.relevant_for_user(self)
.user(self)
.save(db)
.await;
}
@@ -451,7 +460,7 @@ impl User {
ActivityBuilder::new(&format!(
"{updated_by} hat den Bezahlstatus von {self} auf 'nicht bezahlt' gesetzt."
))
.relevant_for_user(self)
.user(self)
.save(db)
.await;
}
@@ -474,7 +483,7 @@ impl User {
ActivityBuilder::new(&format!(
"{updated_by} hat den Bezahlstatus von {self} auf 'bezahlt' gesetzt."
))
.relevant_for_user(self)
.user(self)
.save(db)
.await;
}
@@ -511,7 +520,7 @@ impl User {
ActivityBuilder::new(&format!(
"{updated_by} hat die Rolle '{role}' dem Benutzer {self} hinzugefügt."
))
.relevant_for_user(self)
.user(self)
.save(db)
.await;
}
@@ -520,6 +529,13 @@ impl User {
}
pub(crate) async fn remove_membership_pdf(&self, db: &SqlitePool, updated_by: &ManageUserUser) {
ActivityBuilder::new(&format!(
"{updated_by} hat die Beitrittserklärung vom Beutzer gelöscht."
))
.user(self)
.save(db)
.await;
sqlx::query!(
"UPDATE user SET membership_pdf = null where id = ?",
self.id
@@ -556,7 +572,7 @@ impl User {
ActivityBuilder::new(&format!(
"{updated_by} hat die Mitgliedserklärung (PDF) für user {self} hinzugefügt."
))
.relevant_for_user(self)
.user(self)
.save(db)
.await;

View File

@@ -86,7 +86,7 @@ impl ClubMemberUser {
ActivityBuilder::new(&format!(
"{modified_by} hat {self} zu einem regulären hochgestuft."
))
.relevant_for_user(&self)
.user(&self)
.save(db)
.await;
@@ -109,7 +109,7 @@ impl ClubMemberUser {
db,
&vorstand,
&format!(
"Lieber Vorstand, der Mitgliedstatus von {} hat sich geändert auf 'Unterstützendes Mitglied'.",
"Lieber Vorstand, {} ist nun ein unterstützendes Mitglied.",
self.name,
),
"Neues unterstützendes Vereinsmitglied",
@@ -122,7 +122,7 @@ impl ClubMemberUser {
ActivityBuilder::new(&format!(
"{modified_by} hat {self} zu einem unterstützenden Mitglied gemacht."
))
.relevant_for_user(&self)
.user(&self)
.save(db)
.await;
@@ -145,7 +145,7 @@ impl ClubMemberUser {
db,
&vorstand,
&format!(
"Lieber Vorstand, der Mitgliedstatus von {} hat sich geändert auf 'Förderndes Mitglied'.",
"Lieber Vorstand, {} ist nun ein förderndes Mitglied.",
self.name,
),
"Neues förderndes Vereinsmitglied",
@@ -158,7 +158,7 @@ impl ClubMemberUser {
ActivityBuilder::new(&format!(
"{modified_by} hat {self} zu ein förderndes Mitglied gemacht."
))
.relevant_for_user(&self)
.user(&self)
.save(db)
.await;

View File

@@ -1,7 +1,7 @@
use super::User;
use crate::{
BOAT_STORAGE, DUAL_MEMBERSHIP, EINSCHREIBGEBUEHR, FAMILY_THREE_OR_MORE, FAMILY_TWO, FOERDERND,
REGULAR, RENNRUDERBEITRAG, STUDENT_OR_PUPIL, TRIAL_ROWING, TRIAL_ROWING_REDUCED,
REGULAR, RENNRUDERBEITRAG, SCHECKBUCH, STUDENT_OR_PUPIL, TRIAL_ROWING, TRIAL_ROWING_REDUCED,
UNTERSTUETZEND, model::family::Family,
};
use chrono::{Datelike, Local, NaiveDate};
@@ -70,6 +70,7 @@ impl User {
&& !self.has_role(db, "Unterstützend").await
&& !self.has_role(db, "Förderndes Mitglied").await
&& !self.has_role(db, "schnupperant").await
&& !self.has_role(db, "scheckbuch").await
{
return None;
}
@@ -110,6 +111,7 @@ impl User {
&& !self.has_role(db, "Unterstützend").await
&& !self.has_role(db, "Förderndes Mitglied").await
&& !self.has_role(db, "schnupperant").await
&& !self.has_role(db, "scheckbuch").await
{
return fee;
}
@@ -162,6 +164,8 @@ impl User {
} else {
fee.add("Schnupperkurs".into(), TRIAL_ROWING);
}
} else if self.has_role(db, "scheckbuch").await {
fee.add("Scheckbuch".into(), SCHECKBUCH);
} else if self.has_role(db, "Unterstützend").await {
fee.add("Unterstützendes Mitglied".into(), UNTERSTUETZEND);
} else if self.has_role(db, "Förderndes Mitglied").await {

View File

@@ -45,7 +45,7 @@ ASKÖ Ruderverein Donau Linz", self.name),
ActivityBuilder::new(&format!(
"User {self} hat die Info-Mail bzgl. neues förderndes Mitglied (Handbuch und WLAN Infos) an {mail} gesendet bekommen"
))
.relevant_for_user(self)
.user(self)
.save(db)
.await;

View File

@@ -20,9 +20,9 @@ use super::{
mail::Mail,
notification::Notification,
personal::{equatorprice, rowingbadge},
planned::tripdetails::TripDetails,
role::Role,
stat::Stat,
tripdetails::TripDetails,
Day,
};
use crate::AMOUNT_DAYS_TO_SHOW_TRIPS_AHEAD;
@@ -65,6 +65,21 @@ impl Display for User {
}
}
pub(crate) struct VecUser<'a>(pub &'a Vec<User>);
impl Display for VecUser<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
self.0
.iter()
.map(|user| user.name.as_str())
.collect::<Vec<_>>()
.join(", ")
)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct UserWithDetails {
#[serde(flatten)]
@@ -87,6 +102,13 @@ impl UserWithDetails {
user,
}
}
pub fn allowed_to_row(&self) -> bool {
self.roles.contains(&"Donau Linz".into())
|| self.roles.contains(&"Förderndes Mitglied".into())
|| self.roles.contains(&"scheckbuch".into())
|| self.user.name == "Externe Steuerperson"
}
}
#[derive(Debug)]
@@ -288,14 +310,14 @@ WHERE id like ?
}
pub async fn find_by_name(db: &SqlitePool, name: &str) -> Option<Self> {
let name = name.trim().to_lowercase();
let name = name.trim();
sqlx::query_as!(
Self,
"
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, phone, address, family_id, user_token
FROM user
WHERE lower(name)=?
WHERE lower(name)=lower(?)
",
name
)
@@ -409,7 +431,7 @@ WHERE family_id IS NULL;
"
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, phone, address, family_id, user_token
FROM user
WHERE deleted = 0 AND (SELECT COUNT(*) FROM user_role WHERE user_id=user.id AND role_id = (SELECT id FROM role WHERE name = 'cox')) > 0
WHERE deleted = 0 AND (SELECT COUNT(*) FROM user_role WHERE user_id=user.id AND role_id in (SELECT id FROM role WHERE name = 'cox' or name = 'Bootsführer')) > 0
ORDER BY last_access DESC
"
)
@@ -457,7 +479,7 @@ ASKÖ Ruderverein Donau Linz", self.name),
smtp_pw,
).await?;
ActivityBuilder::new(&format!("User {self} hat eine Mail bekommen, dass seine 5 Ausfahrten mit der heutigen Ausfahrt aufgebraucht sind, und dass der nächste Schritt eine Vereinsmitgliedschaft wäre (inkl. Links zu Beitrittserklärung + Info, dass sie an info@ geschickt werden soll.")).relevant_for_user(self).save_tx(db).await;
ActivityBuilder::new(&format!("User {self} hat eine Mail bekommen, dass seine 5 Ausfahrten mit der heutigen Ausfahrt aufgebraucht sind, und dass der nächste Schritt eine Vereinsmitgliedschaft wäre (inkl. Links zu Beitrittserklärung + Info, dass sie an info@ geschickt werden soll.")).user(self).save_tx(db).await;
Ok(())
}
@@ -515,7 +537,7 @@ ASKÖ Ruderverein Donau Linz", self.name),
ActivityBuilder::new(&format!(
"{changed_by} hat das Passwort von User {self} zurückgesetzt."
))
.relevant_for_user(self)
.user(self)
.save(db)
.await;
}
@@ -527,7 +549,7 @@ ASKÖ Ruderverein Donau Linz", self.name),
.await
.unwrap(); //Okay, because we can only create a User of a valid id
ActivityBuilder::new(&format!("{self} hat sein Passwort geändert."))
.relevant_for_user(self)
.user(self)
.save(db)
.await;
}
@@ -557,7 +579,7 @@ ASKÖ Ruderverein Donau Linz", self.name),
.await
.unwrap(); //Okay, because we can only create a User of a valid id
ActivityBuilder::new(&format!("User {self} wurde von {deleted_by} gelöscht."))
.relevant_for_user(self)
.user(self)
.save(db)
.await;
}
@@ -652,7 +674,7 @@ ASKÖ Ruderverein Donau Linz", self.name),
)
.await;
ActivityBuilder::new(&format!("5 Scheckbuchausfahrten von {self} wurden mit der heutigen Ausfahrt aufgebraucht. Info-Mail wurde an {self} geschickt + alle Steuerberechtigten informiert, dass wir pot. ein neues Mitglied haben"))
.relevant_for_user(self)
.user(self)
.save_tx(db)
.await;
}
@@ -670,7 +692,7 @@ ASKÖ Ruderverein Donau Linz", self.name),
)
.await;
ActivityBuilder::new(&format!("{self} hat nun bereits die {amount_trips}. seiner 5 Scheckbuchausfahrten absolviert. Vorstand wurde via Notification informiert."))
.relevant_for_user(self)
.user(self)
.save_tx(db)
.await;
}
@@ -695,7 +717,7 @@ ASKÖ Ruderverein Donau Linz", self.name),
ActivityBuilder::new(&format!(
"{self} hat das heurige Fahrtenabzeichen geschafft! Der Vorstand + {self} wurde via Notification informiert."
))
.relevant_for_user(self)
.user(self)
.save_tx(db)
.await;
@@ -717,7 +739,7 @@ ASKÖ Ruderverein Donau Linz", self.name),
)
.await;
ActivityBuilder::new(&format!("{self} hat den Äquatorpreis in {level} geschafft! Der Vorstand + {self} wurde via Notification informiert."))
.relevant_for_user(self)
.user(self)
.save_tx(db)
.await;
@@ -844,6 +866,7 @@ special_user!(AllowedToEditPaymentStatusUser, +"kassier", +"admin");
special_user!(ManageUserUser, +"admin", +"schriftfuehrer");
special_user!(AllowedToSendFeeReminderUser, +"admin", +"schriftfuehrer", +"kassier");
special_user!(AllowedToUpdateTripToAlwaysBeShownUser, +"admin");
special_user!(AllowedToUpdateBoathouse, +"admin", +"Vorstand", +"tech");
#[derive(FromRow, Serialize, Deserialize, Clone, Debug)]
pub struct UserWithRolesAndMembershipPdf {

View File

@@ -1,8 +1,7 @@
use super::{ManageUserUser, User};
use crate::{
NonEmptyString,
model::{activity::ActivityBuilder, mail::Mail, notification::Notification, role::Role},
special_user,
special_user, NonEmptyString,
};
use chrono::NaiveDate;
use rocket::{async_trait, fs::TempFile, tokio::io::AsyncReadExt};
@@ -52,7 +51,7 @@ pub trait ClubMember {
ActivityBuilder::new(&format!(
"{created_by} hat Mitglied {user} mit der Rolle {role} angelegt."
))
.relevant_for_user(&user)
.user(&user)
.save(db)
.await;
@@ -79,7 +78,7 @@ impl RegularUser {
mail,
"Willkommen im ASKÖ Ruderverein Donau Linz!",
format!(
"Hallo {0},
"Hallo {self},
herzlich willkommen im ASKÖ Ruderverein Donau Linz! Wir freuen uns sehr, dich als neues Mitglied in unserem Verein begrüßen zu dürfen.
@@ -87,7 +86,7 @@ Um dir den Einstieg zu erleichtern, findest du in unserem Handbuch alle wichtige
Du kannst auch gerne unserer Signal-Gruppe beitreten, um auf dem Laufenden zu bleiben und dich mit anderen Mitgliedern auszutauschen: https://signal.group/#CjQKICFrq6zSsRHxrucS3jEcQn6lknEXacAykwwLV3vNLKxPEhA17jxz7cpjfu3JZokLq1TH
Für die Organisation unserer Ausfahrten nutzen wir app.rudernlinz.at. Logge dich einfach mit deinem Namen ('{0}' ohne Anführungszeichen) ein, beim ersten Mal kannst du das Passwortfeld leer lassen. Unter 'Geplante Ausfahrten' kannst du dich jederzeit zu den Ausfahrten anmelden.
Für die Organisation unserer Ausfahrten nutzen wir app.rudernlinz.at. Logge dich einfach mit deinem Namen ('{self}' ohne Anführungszeichen) ein, beim ersten Mal kannst du das Passwortfeld leer lassen. Unter 'Geplante Ausfahrten' kannst du dich jederzeit zu den Ausfahrten anmelden.
Beim nächsten Treffen im Verein, erinnere jemand vom Vorstand (https://rudernlinz.at/unser-verein/vorstand/) bitte daran, deinen Fingerabdruck zu registrieren, damit du Zugang zum Bootshaus erhältst.
@@ -95,15 +94,17 @@ Damit du dich noch mehr verbunden fühlst (:-)), haben wir im Bootshaus ein WLAN
Falls du deinen Mitgliedsbeitrag noch nicht bezahlt hast, erledige dies bitte demnächst. Den genauen Betrag und einen QR Code, den du mit deiner Bankapp scannen kannst findest du unter https://app.rudernlinz.at/planned
Wenn du alle Ausfahrten, zu denen du dich angemeldet hast in deinem eigenen Kalender sehen willst, füge folgenden Link hinzu: https://app.rudernlinz.at/cal/personal/{}/{}
Wir freuen uns darauf, dich bald am Wasser zu sehen und gemeinsam tolle Erfahrungen zu sammeln!
Riemen- & Dollenbruch
ASKÖ Ruderverein Donau Linz", self.name),
ASKÖ Ruderverein Donau Linz", self.user.id, self.user.user_token),
smtp_pw,
).await?;
ActivityBuilder::new(&format!("Willkommensmail für {self} wurde an {mail} verschickt (Handbuch, Signal-Gruppe, App-Info, Fingerprint, WLAN)."))
.relevant_for_user(self)
.user(self)
.save(db)
.await;

View File

@@ -88,7 +88,7 @@ impl ScheckbuchUser {
ActivityBuilder::new(&format!(
"{changed_by} hat den Scheckbuch-User {self} auf ein reguläres Mitglied upgegraded! Die Steuerpersonen wurden via Notification informiert."
))
.relevant_for_user(&self)
.user(&self)
.save(db)
.await;
@@ -144,7 +144,7 @@ impl ScheckbuchUser {
.await;
}
ActivityBuilder::new(&format!("{changed_by} hat den Scheckbuch-User {self} auf ein unterstützendes Mitglied upgegraded!"))
.relevant_for_user(&self)
.user(&self)
.save(db)
.await;
@@ -200,7 +200,7 @@ impl ScheckbuchUser {
ActivityBuilder::new(&format!(
"{changed_by} hat den Scheckbuch-User {self} auf ein förderndes Mitglied upgegraded!"
))
.relevant_for_user(&self)
.user(&self)
.save(db)
.await;
@@ -215,7 +215,7 @@ impl ScheckbuchUser {
ActivityBuilder::new(&format!(
"{self} hat eine Info-Mail bekommen (Erklärung Scheckbuch, Ruderapp) und alle Steuerberechtigten wurden informiert."
))
.relevant_for_user(self)
.user(self)
.save(db)
.await;
@@ -295,7 +295,7 @@ ASKÖ Ruderverein Donau Linz", self.name, SCHECKBUCH/100),
user.notify(db, smtp_pw).await?;
ActivityBuilder::new(&format!("{created_by} hat Scheckbuch {user} angelegt."))
.relevant_for_user(&user)
.user(&user)
.save(db)
.await;

View File

@@ -101,7 +101,7 @@ impl SchnupperantUser {
ActivityBuilder::new(&format!(
"{changed_by} hat den Schnupperant {self} auf ein reguläres Mitglied upgegraded!"
))
.relevant_for_user(&self)
.user(&self)
.save(db)
.await;
@@ -142,7 +142,7 @@ impl SchnupperantUser {
ActivityBuilder::new(&format!(
"{changed_by} hat dem ehemaligen Schnupperant {self} nun ein Scheckbuch gegeben"
))
.relevant_for_user(&self)
.user(&self)
.save(db)
.await;
@@ -184,7 +184,7 @@ impl SchnupperantUser {
ActivityBuilder::new(&format!(
"{changed_by} hat dem eigentlichen Schnupperanten {self} wieder auf die 'Interessierten'-Liste zurückgegeben."
))
.relevant_for_user(&self)
.user(&self)
.save(db)
.await;
@@ -253,7 +253,7 @@ impl SchnupperantUser {
ActivityBuilder::new(&format!(
"{changed_by} hat den Schnupperant {self} auf ein unterstützendes Mitglied upgegraded!"
))
.relevant_for_user(&self)
.user(&self)
.save(db)
.await;
@@ -320,7 +320,7 @@ impl SchnupperantUser {
ActivityBuilder::new(&format!(
"{changed_by} hat den Schnupperant {self} auf ein förderndes Mitglied upgegraded!"
))
.relevant_for_user(&self)
.user(&self)
.save(db)
.await;
@@ -335,7 +335,7 @@ impl SchnupperantUser {
ActivityBuilder::new(&format!(
"{self} hat eine Mail bekommen (Inhalt: wir freuen uns auf ihn + senden detailliertere Infos später zu) und die Schnupperbetreuer wurden via Notification informiert."
))
.relevant_for_user(self)
.user(self)
.save(db)
.await;
@@ -423,7 +423,7 @@ ASKÖ Ruderverein Donau Linz",
ActivityBuilder::new(&format!(
"{created_by} hat {user} zur fixen Schnupperkurs-Anmeldung hinzugefügt."
))
.relevant_for_user(&user)
.user(&user)
.save(db)
.await;

View File

@@ -44,7 +44,7 @@ impl SchnupperInterestUser {
ActivityBuilder::new(&format!(
"Der Schnupperinteressierte {self} hat sich (ohne Schnupperkurs) doch gleich direkt für ein Scheckbuch entschieden. {changed_by} hat dieses eingerichtet."
))
.relevant_for_user(&self)
.user(&self)
.save(db)
.await;
@@ -86,7 +86,7 @@ impl SchnupperInterestUser {
ActivityBuilder::new(&format!(
"Der Schnupperinteressierte {self} hat sich zum Schnupperkurs angemeldet."
))
.relevant_for_user(&self)
.user(&self)
.save(db)
.await;
@@ -99,7 +99,7 @@ impl SchnupperInterestUser {
ActivityBuilder::new(&format!(
"Der Schnupperbetreuer hat eine Info via Notification bekommen, dass {self} Interesse an einen Schnupperkurs hat."
))
.relevant_for_user(self)
.user(self)
.save(db)
.await;
@@ -153,7 +153,7 @@ impl SchnupperInterestUser {
ActivityBuilder::new(&format!(
"{created_by} hat Schnupper-Interessierten {user} angelegt."
))
.relevant_for_user(&user)
.user(&user)
.save(db)
.await;

View File

@@ -45,7 +45,7 @@ ASKÖ Ruderverein Donau Linz", self.name),
ActivityBuilder::new(&format!(
"{self} hat eine Mail an {mail} bekommen, mit Infos dass er/sie nun ein unterstützendes Mitglied ist (Handbuch, WLAN)."
))
.relevant_for_user(self)
.user(self)
.save(db)
.await;

View File

@@ -9,8 +9,10 @@ use serde::Serialize;
use sqlx::SqlitePool;
use crate::model::{
planned::{
event::{self, Event},
tripdetails::{TripDetails, TripDetailsToAdd},
},
user::EventUser,
};

View File

@@ -7,11 +7,11 @@ use crate::{
mail::valid_mails,
role::Role,
user::{
AdminUser, AllowedToEditPaymentStatusUser, ManageUserUser, User, UserWithDetails,
UserWithMembershipPdf, UserWithRolesAndMembershipPdf, VorstandUser,
clubmember::ClubMemberUser, foerdernd::FoerderndUser, member::Member,
regular::RegularUser, scheckbuch::ScheckbuchUser, schnupperant::SchnupperantUser,
schnupperinterest::SchnupperInterestUser, unterstuetzend::UnterstuetzendUser,
AdminUser, AllowedToEditPaymentStatusUser, ManageUserUser, User, UserWithDetails,
UserWithMembershipPdf, UserWithRolesAndMembershipPdf, VorstandUser,
},
},
tera::Config,
@@ -19,7 +19,6 @@ use crate::{
use chrono::NaiveDate;
use futures::future::join_all;
use rocket::{
FromForm, Request, Route, State,
form::Form,
fs::TempFile,
get,
@@ -27,9 +26,9 @@ use rocket::{
post,
request::{FlashMessage, FromRequest, Outcome},
response::{Flash, Redirect},
routes,
routes, FromForm, Request, Route, State,
};
use rocket_dyn_templates::{Template, tera::Context};
use rocket_dyn_templates::{tera::Context, Template};
use sqlx::SqlitePool;
// Custom request guard to extract the Referer header
@@ -357,7 +356,7 @@ async fn add_note(
match user.add_note(db, &admin, &data.note).await {
Ok(_) => Flash::success(
Redirect::to(format!("/admin/user/{}", user.id)),
"Notiz hinzugefügt",
"Notiz hinzugefügt. Du findest sie ab sofort unter 'Aktivitäten'.",
),
Err(e) => Flash::error(Redirect::to(format!("/admin/user/{}", user.id)), e),
}

View File

@@ -1,17 +1,16 @@
use crate::model::{
boat::Boat,
boathouse::Boathouse,
user::{AdminUser, UserWithDetails, VorstandUser},
user::{AllowedToUpdateBoathouse, UserWithDetails, VorstandUser},
};
use rocket::{
FromForm, Route, State,
form::Form,
get, post,
request::FlashMessage,
response::{Flash, Redirect},
routes,
routes, FromForm, Route, State,
};
use rocket_dyn_templates::{Template, tera::Context};
use rocket_dyn_templates::{tera::Context, Template};
use sqlx::SqlitePool;
#[get("/boathouse")]
@@ -38,6 +37,11 @@ async fn index(
let boathouse = Boathouse::get(db).await;
context.insert("boathouse", &boathouse);
let allowed_to_edit = AllowedToUpdateBoathouse::new(db, &admin.user)
.await
.is_some();
context.insert("allowed_to_edit", &allowed_to_edit);
context.insert(
"loggedin_user",
&UserWithDetails::from_user(admin.into_inner(), db).await,
@@ -57,36 +61,29 @@ pub struct FormBoathouseToAdd {
async fn new<'r>(
db: &State<SqlitePool>,
data: Form<FormBoathouseToAdd>,
_admin: AdminUser,
user: AllowedToUpdateBoathouse,
) -> Flash<Redirect> {
match Boathouse::create(db, data.into_inner()).await {
match Boathouse::create(db, &user, data.into_inner()).await {
Ok(_) => Flash::success(Redirect::to("/board/boathouse"), "Boot hinzugefügt"),
Err(e) => Flash::error(Redirect::to("/board/boathouse"), e),
}
}
#[get("/boathouse/<boathouse_id>/delete")]
async fn delete(db: &State<SqlitePool>, _admin: AdminUser, boathouse_id: i32) -> Flash<Redirect> {
async fn delete(
db: &State<SqlitePool>,
user: AllowedToUpdateBoathouse,
boathouse_id: i32,
) -> Flash<Redirect> {
let boat = Boathouse::find_by_id(db, boathouse_id).await;
match boat {
Some(boat) => {
boat.delete(db).await;
boat.delete(db, &user).await;
Flash::success(Redirect::to("/board/boathouse"), "Bootsplatz gelöscht")
}
None => Flash::error(Redirect::to("/board/boathouse"), "Boatplace does not exist"),
}
}
//#[post("/boat/new", data = "<data>")]
//async fn create(
// db: &State<SqlitePool>,
// data: Form<BoatToAdd<'_>>,
// _admin: AdminUser,
//) -> Flash<Redirect> {
// match Boat::create(db, data.into_inner()).await {
// Ok(_) => Flash::success(Redirect::to("/admin/boat"), "Boot hinzugefügt"),
// Err(e) => Flash::error(Redirect::to("/admin/boat"), e),
// }
//}
pub fn routes() -> Vec<Route> {
routes![index, new, delete]

View File

@@ -8,10 +8,12 @@ use rocket::{
use sqlx::SqlitePool;
use crate::model::{
event::Event,
log::Log,
planned::{
event::Event,
trip::{self, CoxHelpError, Trip, TripDeleteError, TripHelpDeleteError, TripUpdateError},
tripdetails::{TripDetails, TripDetailsToAdd},
},
user::{AllowedToUpdateTripToAlwaysBeShownUser, ErgoUser, SteeringUser, User},
};
@@ -26,18 +28,10 @@ async fn create_ergo(
//created
Trip::new_own_ergo(db, &cox, trip_details).await; //TODO: fix
//Log::create(
// db,
// format!(
// "Cox {} created trip on {} @ {} for {} rower",
// cox.name, trip_details.day, trip_details.planned_starting_time, trip_details.max_people,
// ),
//)
//.await;
Flash::success(Redirect::to("/planned"), "Ausfahrt erfolgreich erstellt.")
}
/// SteeringUser created new trip
#[post("/trip", data = "<data>")]
async fn create(
db: &State<SqlitePool>,
@@ -49,15 +43,6 @@ async fn create(
//created
Trip::new_own(db, &cox, trip_details).await; //TODO: fix
//Log::create(
// db,
// format!(
// "Cox {} created trip on {} @ {} for {} rower",
// cox.name, trip_details.day, trip_details.planned_starting_time, trip_details.max_people,
// ),
//)
//.await;
Flash::success(Redirect::to("/planned"), "Ausfahrt erfolgreich erstellt.")
}
@@ -234,7 +219,7 @@ mod test {
};
use sqlx::SqlitePool;
use crate::{model::trip::Trip, testdb};
use crate::{model::planned::trip::Trip, testdb};
#[sqlx::test]
fn test_trip_create() {

View File

@@ -1,7 +1,6 @@
use std::net::IpAddr;
use rocket::{
Request, Route, State,
form::Form,
get,
http::{Cookie, CookieJar},
@@ -10,8 +9,9 @@ use rocket::{
response::{Flash, Redirect},
routes,
time::{Duration, OffsetDateTime},
Request, Route, State,
};
use rocket_dyn_templates::{Template, context};
use rocket_dyn_templates::{context, Template};
use sqlx::SqlitePool;
use tera::Context;
@@ -22,11 +22,11 @@ use crate::{
distance::Distance,
log::Log,
logbook::{
LogToAdd, LogToFinalize, LogToUpdate, Logbook, LogbookAdminUpdateError,
LogbookCreateError, LogbookDeleteError, LogbookUpdateError,
LogToAdd, LogToFinalize, LogToUpdate, Logbook, LogbookCreateError, LogbookDeleteError,
LogbookUpdateError,
},
logtype::LogType,
trip::Trip,
planned::trip::Trip,
user::{DonauLinzUser, User, UserWithDetails, VorstandUser},
},
tera::Config,
@@ -47,12 +47,46 @@ impl<'r> FromRequest<'r> for KioskCookie {
}
#[get("/", rank = 2)]
async fn index(
async fn index_loggedin(
db: &State<SqlitePool>,
flash: Option<FlashMessage<'_>>,
user: DonauLinzUser,
) -> Template {
let mut context = Context::new();
let boats = Boat::for_user(db, &user).await;
context.insert("boats", &boats);
context.insert(
"loggedin_user",
&UserWithDetails::from_user(user.into_inner(), db).await,
);
let context = index(db, flash, context).await;
Template::render("log", context.into_json())
}
#[get("/")]
async fn index_kiosk(
db: &State<SqlitePool>,
flash: Option<FlashMessage<'_>>,
_kiosk: KioskCookie,
) -> Template {
let mut context = Context::new();
let boats = Boat::all(db).await;
context.insert("boats", &boats);
context.insert("show_kiosk_header", &true);
let context = index(db, flash, context).await;
Template::render("kiosk", context.into_json())
}
async fn index(db: &SqlitePool, flash: Option<FlashMessage<'_>>, mut context: Context) -> Context {
if let Some(msg) = flash {
context.insert("flash", &msg.into_inner());
}
let mut coxes: Vec<UserWithDetails> = futures::future::join_all(
User::cox(db)
@@ -61,9 +95,7 @@ async fn index(
.map(|user| UserWithDetails::from_user(user, db)),
)
.await;
coxes.retain(|u| {
u.roles.contains(&"Donau Linz".into()) || u.roles.contains(&"scheckbuch".into())
});
coxes.retain(|u| u.roles.contains(&"Donau Linz".into()));
let mut users: Vec<UserWithDetails> = futures::future::join_all(
User::all(db)
@@ -72,23 +104,13 @@ async fn index(
.map(|user| UserWithDetails::from_user(user, db)),
)
.await;
users.retain(|u| {
u.roles.contains(&"Donau Linz".into())
|| u.roles.contains(&"scheckbuch".into())
|| u.user.name == "Externe Steuerperson"
});
users.retain(|u| u.allowed_to_row());
let logtypes = LogType::all(db).await;
let distances = Distance::all(db).await;
let on_water = Logbook::on_water(db).await;
let mut context = Context::new();
if let Some(msg) = flash {
context.insert("flash", &msg.into_inner());
}
context.insert("boats", &boats);
context.insert("planned_trips", &Trip::get_for_today(db).await);
context.insert(
"reservations",
@@ -97,37 +119,57 @@ async fn index(
context.insert("coxes", &coxes);
context.insert("users", &users);
context.insert("logtypes", &logtypes);
context.insert(
"loggedin_user",
&UserWithDetails::from_user(user.into_inner(), db).await,
);
context.insert("on_water", &on_water);
context.insert("distances", &distances);
Template::render("log", context.into_json())
context
}
#[get("/show", rank = 3)]
async fn show(db: &State<SqlitePool>, user: DonauLinzUser) -> Template {
async fn show(
db: &State<SqlitePool>,
flash: Option<FlashMessage<'_>>,
user: DonauLinzUser,
) -> Template {
let logs = Logbook::completed(db).await;
let boats = Boat::all(db).await;
let users = User::all(db).await;
let logtypes = LogType::all(db).await;
Template::render(
"log.completed",
context!(logs, boats, users, logtypes, loggedin_user: &UserWithDetails::from_user(user.into_inner(), db).await),
)
let mut context = Context::new();
if let Some(msg) = flash {
context.insert("flash", &msg.into_inner());
}
context.insert("logs", &logs);
context.insert("boats", &boats);
context.insert("users", &users);
context.insert("logtypes", &logtypes);
context.insert(
"loggedin_user",
&UserWithDetails::from_user(user.into_inner(), db).await,
);
Template::render("log.completed", context.into_json())
}
#[get("/show?<year>", rank = 2)]
async fn show_for_year(db: &State<SqlitePool>, user: VorstandUser, year: i32) -> Template {
async fn show_for_year(
db: &State<SqlitePool>,
flash: Option<FlashMessage<'_>>,
user: VorstandUser,
year: i32,
) -> Template {
let logs = Logbook::completed_in_year(db, year).await;
Template::render(
"log.completed",
context!(logs, loggedin_user: &UserWithDetails::from_user(user.user, db).await),
)
let mut context = Context::new();
if let Some(msg) = flash {
context.insert("flash", &msg.into_inner());
}
context.insert("logs", &logs);
context.insert(
"loggedin_user",
&UserWithDetails::from_user(user.into_inner(), db).await,
);
Template::render("log.completed", context.into_json())
}
#[get("/show")]
@@ -155,63 +197,6 @@ async fn new_kiosk(
Redirect::to("/log")
}
#[get("/")]
async fn kiosk(
db: &State<SqlitePool>,
flash: Option<FlashMessage<'_>>,
_kiosk: KioskCookie,
) -> Template {
let boats = Boat::all(db).await;
let mut coxes: Vec<UserWithDetails> = futures::future::join_all(
User::cox(db)
.await
.into_iter()
.map(|user| UserWithDetails::from_user(user, db)),
)
.await;
coxes.retain(|u| {
u.roles.contains(&"Donau Linz".into()) || u.roles.contains(&"scheckbuch".into())
});
let mut users: Vec<UserWithDetails> = futures::future::join_all(
User::all(db)
.await
.into_iter()
.map(|user| UserWithDetails::from_user(user, db)),
)
.await;
users.retain(|u| {
u.roles.contains(&"Donau Linz".into()) || u.roles.contains(&"scheckbuch".into())
});
let logtypes = LogType::all(db).await;
let distances = Distance::all(db).await;
let on_water = Logbook::on_water(db).await;
let mut context = Context::new();
if let Some(msg) = flash {
context.insert("flash", &msg.into_inner());
}
context.insert("planned_trips", &Trip::get_for_today(db).await);
context.insert("boats", &boats);
context.insert(
"reservations",
&BoatReservation::all_future_with_groups(db).await,
);
context.insert("coxes", &coxes);
context.insert("users", &users);
context.insert("logtypes", &logtypes);
context.insert("on_water", &on_water);
context.insert("distances", &distances);
context.insert("show_kiosk_header", &true);
Template::render("kiosk", context.into_json())
}
async fn create_logbook(
db: &SqlitePool,
data: Form<LogToAdd>,
@@ -370,27 +355,12 @@ async fn update(
);
};
match logbook.update(db, data.clone(), &user.user).await {
Ok(()) => {
Log::create(
db,
format!(
"User {} updated log entry={:?} to {:?}",
&user.name, logbook, data
),
)
.await;
logbook.update(db, data.clone(), &user).await;
Flash::success(
Redirect::to("/log/show"),
"Logbucheintrag erfolgreich bearbeitet".to_string(),
)
}
Err(LogbookAdminUpdateError::NotAllowed) => Flash::error(
Redirect::to("/log/show"),
"Du hast keine Erlaubnis, diesen Logbucheintrag zu bearbeiten!".to_string(),
),
}
}
async fn home_logbook(
@@ -513,10 +483,7 @@ async fn delete(db: &State<SqlitePool>, logbook_id: i64, user: DonauLinzUser) ->
)
.await;
match logbook.delete(db, &user).await {
Ok(_) => Flash::success(
Redirect::to(redirect),
format!("Eintrag {} von {} gelöscht!", logbook_id, user.name),
),
Ok(_) => Flash::success(Redirect::to(redirect), "Erfolgreich gelöscht"),
Err(LogbookDeleteError::NotYourEntry) => Flash::error(
Redirect::to(redirect),
"Du hast nicht die Berechtigung, den Eintrag zu löschen!",
@@ -562,11 +529,11 @@ async fn delete_kiosk(
pub fn routes() -> Vec<Route> {
routes![
index,
index_loggedin,
index_kiosk,
create,
create_kiosk,
home,
kiosk,
home_kiosk,
new_kiosk,
show,
@@ -585,7 +552,7 @@ mod test {
use sqlx::SqlitePool;
use crate::model::logbook::Logbook;
use crate::tera::{User, log::Boat};
use crate::tera::{log::Boat, User};
use crate::testdb;
#[sqlx::test]

View File

@@ -1,7 +1,7 @@
use rocket::{Route, State, get, http::ContentType, routes};
use sqlx::SqlitePool;
use crate::model::{event::Event, personal::cal::get_personal_cal, user::User};
use crate::model::{personal::cal::get_personal_cal, planned::event::Event, user::User};
#[get("/cal")]
async fn cal(db: &State<SqlitePool>) -> (ContentType, String) {

View File

@@ -12,11 +12,13 @@ use crate::{
AMOUNT_DAYS_TO_SHOW_TRIPS_AHEAD,
model::{
log::Log,
planned::{
tripdetails::TripDetails,
triptype::TripType,
user::{AllowedForPlannedTripsUser, User, UserWithDetails},
usertrip::{UserTrip, UserTripDeleteError, UserTripError},
},
user::{AllowedForPlannedTripsUser, User, UserWithDetails},
},
};
#[get("/")]

View File

@@ -7,12 +7,12 @@
{% set place = boathouse[aisle_name][side_name].boats %}
{% if place[level] %}
{{ place[level].boat.name }}
{% if "admin" in loggedin_user.roles %}
{% if allowed_to_edit %}
<a class="btn btn-primary absolute end-0"
href="/board/boathouse/{{ place[level].boathouse_id }}/delete">X</a>
{% endif %}
{% elif boats | length > 0 %}
{% if "admin" in loggedin_user.roles %}
{% if allowed_to_edit %}
<details>
<summary>Kein Boot</summary>
<form action="/board/boathouse" method="post" class="grid gap-3">

View File

@@ -94,7 +94,7 @@
{# --- START Boatreservations--- #}
{% for _, reservations_for_event in day.boat_reservations %}
{% set reservation = reservations_for_event[0] %}
<div class="pt-2 px-3 border-gray-200">
<div class="pt-2 px-3 border-t border-gray-200">
<div class="flex justify-between items-center">
<div class="mr-1">
<span class="text-primary-900 dark:text-white">