Compare commits
147 Commits
improve-lo
...
5ee776317b
Author | SHA1 | Date | |
---|---|---|---|
5ee776317b | |||
2e13acc0b0 | |||
0a31410ca5 | |||
f793cb4a9a | |||
6a59634de3 | |||
d3b2d78f9f | |||
155adce2e9 | |||
63a32f02bf | |||
9548cb4f0b | |||
c42713b86e | |||
429f0c1ddc | |||
d5a92d8f79 | |||
aa3df2a294 | |||
0354e4e190 | |||
7a2743046d | |||
7935d1837f | |||
7027145a9a | |||
782d68cd03 | |||
f769af279b | |||
c6a2b529c3 | |||
b0b2ad2148 | |||
de62585b64 | |||
09e06017c2 | |||
34ade37f2d | |||
ac24be6c5e | |||
138c0598e6 | |||
5b75ff5d38 | |||
13976b02d8 | |||
a42e0b3ed3 | |||
743359904a | |||
3aef4fa971 | |||
f46ddf249a | |||
29e9911653 | |||
bc6244bc03 | |||
47e3d1b5b3 | |||
d6b9a2f11b | |||
eca711e572 | |||
4e04b2b082 | |||
73a7abd418 | |||
09aa0fc136 | |||
abd58766d8 | |||
58a357fdb5 | |||
cc9505ca1e | |||
5202060e2f | |||
129c90f1aa | |||
22f70f533a | |||
64b3e63e15 | |||
e631ee67b5 | |||
6df029b4a7 | |||
63edc3d249 | |||
61016f284c | |||
1d4d59842b | |||
18348e68f3 | |||
7730de8ada | |||
a63d29a42a | |||
066f47d99d | |||
f7bb394236 | |||
b3033fbc72 | |||
1f4ebc31ed | |||
c246e06e69 | |||
0dca843d6a | |||
50cd3c2d75 | |||
e334cea0e2 | |||
7e10253e2e | |||
0edd796f73 | |||
dc75e0145a | |||
1e2dc4ccbc | |||
e883c0e6e2 | |||
4bcba1ec47 | |||
452a1e1b97 | |||
d2390ca5c2 | |||
412b733e30 | |||
965cba0919 | |||
4906b757b8 | |||
dae8632a34 | |||
55bdca4238 | |||
0b62f59d19 | |||
bf7dab235c | |||
bb3e8dadb7 | |||
924683511c | |||
ed6d05eb9e | |||
edcdc74c1c | |||
d7d6eb2b43 | |||
3ab1dbd1f1 | |||
6e9367fa07 | |||
4859890389 | |||
e4a8caf632 | |||
cd39f1a694 | |||
4f34cc180c | |||
396fc8e659 | |||
f86d2f6307 | |||
3c26381901 | |||
1ecde79593 | |||
e8b8ba393f | |||
e01f9806bd | |||
3801c7ce8c | |||
816257d4be | |||
71087af0df | |||
23399b7757 | |||
0c5812f725 | |||
6efcaaccf9 | |||
d88a35bb82 | |||
52abcbb3fb | |||
60578dfaba | |||
29777cdc36 | |||
22b9a2e324 | |||
addf0f437b | |||
a97d515f03 | |||
72fc3ed91e | |||
b079eafc3d | |||
51df7f2d1e | |||
6e1bfe8635 | |||
ce28f93d65 | |||
78faf1b0db | |||
bf3a4c686a | |||
5fb9e0fbba | |||
e3fc756b3f | |||
f58e7d1307 | |||
374fed9e3b | |||
b9f2382cba | |||
aab3a15488 | |||
83b93fba09 | |||
3b5ff70d1d | |||
2af9ac20b1 | |||
5331ac71fa | |||
6098aedb74 | |||
7083d27644 | |||
8277ef6af8 | |||
67d5df9c18 | |||
3ffc44a5a2 | |||
bd2686fa9c | |||
495ee666cd | |||
5296b6a6c1 | |||
49e657ab54 | |||
25bbaca0d3 | |||
26038eabe4 | |||
57acd92e7c | |||
c136c60e62 | |||
a5e90ea014 | |||
f0f3909239 | |||
1438bbe3a8 | |||
a910cd745d | |||
6265440288 | |||
3baed66ebc | |||
499ce06438 | |||
67e5277c62 | |||
ce154bf060 |
51
.gitea/workflows/update.yml
Normal file
51
.gitea/workflows/update.yml
Normal file
@ -0,0 +1,51 @@
|
||||
name: Update Cargo Dependencies
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 2 * * 5' # Run weekly on Friday at 2am
|
||||
workflow_dispatch: # Allow manual triggering
|
||||
|
||||
jobs:
|
||||
update-dependencies:
|
||||
runs-on: ubuntu-latest
|
||||
container: git.hofer.link/philipp/ci-images:rust-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Update dependencies
|
||||
run: |
|
||||
cargo upgrade
|
||||
cargo update
|
||||
|
||||
- name: Create Pull Request Staging
|
||||
uses: https://git.hofer.link/philipp/create-pull-request@18ef1fdad70eec569ab10292c1fa79c1b5296370
|
||||
with:
|
||||
token: ${{ secrets.GITEATOKEN }}
|
||||
commit-message: Update Cargo dependencies
|
||||
title: Update Cargo dependencies
|
||||
body: |
|
||||
This PR updates Cargo dependencies to their latest versions.
|
||||
|
||||
@philipp
|
||||
|
||||
- Run `cargo upgrade` to update version requirements in Cargo.toml
|
||||
- Run `cargo update` to update Cargo.lock
|
||||
branch: update-cargo-dependencies
|
||||
delete-branch: false
|
||||
|
||||
- name: Create Pull Request Main
|
||||
uses: https://git.hofer.link/philipp/create-pull-request@18ef1fdad70eec569ab10292c1fa79c1b5296370
|
||||
with:
|
||||
token: ${{ secrets.GITEATOKEN }}
|
||||
commit-message: Update Cargo dependencies
|
||||
title: Update Cargo dependencies
|
||||
body: |
|
||||
This PR updates Cargo dependencies to their latest versions.
|
||||
|
||||
@philipp
|
||||
|
||||
- Run `cargo upgrade` to update version requirements in Cargo.toml
|
||||
- Run `cargo update` to update Cargo.lock
|
||||
branch: update-cargo-dependencies
|
||||
base: main
|
||||
delete-branch: true
|
599
Cargo.lock
generated
599
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,7 @@ rowing-tera = ["rocket_dyn_templates", "tera"]
|
||||
rest = []
|
||||
|
||||
[dependencies]
|
||||
rocket = { version = "0.5.0", features = ["secrets"]}
|
||||
rocket = { version = "0.5", features = ["secrets"]}
|
||||
rocket_dyn_templates = {version = "0.2", features = [ "tera" ], optional = true }
|
||||
log = "0.4"
|
||||
env_logger = "0.11"
|
||||
@ -19,15 +19,15 @@ serde = { version = "1.0", features = [ "derive" ]}
|
||||
serde_json = "1.0"
|
||||
chrono = { version = "0.4", features = ["serde"]}
|
||||
chrono-tz = "0.10"
|
||||
tera = { version = "1.18", features = ["date-locale"], optional = true}
|
||||
tera = { version = "1.20", features = ["date-locale"], optional = true}
|
||||
ics = "0.5"
|
||||
futures = "0.3"
|
||||
lettre = "0.11"
|
||||
csv = "1.3"
|
||||
itertools = "0.14"
|
||||
job_scheduler_ng = "2.0"
|
||||
job_scheduler_ng = "2.2"
|
||||
ureq = { version = "3.0", features = ["json"] }
|
||||
regex = "1.10"
|
||||
regex = "1.11"
|
||||
urlencoding = "2.1"
|
||||
|
||||
[target.'cfg(not(windows))'.dependencies]
|
||||
|
287
LICENSE
Normal file
287
LICENSE
Normal 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.
|
@ -115,7 +115,7 @@ test("Cox can start and finish trip", async ({ page }, testInfo) => {
|
||||
await page.getByPlaceholder("Passwort").press("Enter");
|
||||
|
||||
await page.goto("/log/show");
|
||||
await page.getByText('(cox2)').click();
|
||||
await page.getByRole('link', { name: 'Joe' }).nth(1).click();
|
||||
page.once("dialog", (dialog) => {
|
||||
dialog.accept().catch(() => {});
|
||||
});
|
||||
@ -208,7 +208,6 @@ test("Kiosk can start and finish trip", async ({ page }, testInfo) => {
|
||||
|
||||
await page.getByRole('link', { name: 'Logbuch' }).click();
|
||||
await expect(page.locator('body')).toContainText('Joe');
|
||||
await expect(page.locator('body')).toContainText('(cox2)');
|
||||
await expect(page.locator('body')).toContainText('Ottensheim (25 km)');
|
||||
await expect(page.locator('body')).toContainText('Ruderer: cox2, rower2');
|
||||
|
||||
@ -225,7 +224,7 @@ test("Kiosk can start and finish trip", async ({ page }, testInfo) => {
|
||||
await page.getByPlaceholder("Passwort").press("Enter");
|
||||
|
||||
await page.goto("/log/show");
|
||||
await page.getByText('(cox2)').click();
|
||||
await page.getByRole('link', { name: 'Joe' }).nth(1).click();
|
||||
page.once("dialog", (dialog) => {
|
||||
dialog.accept().catch(() => {});
|
||||
});
|
||||
@ -286,7 +285,6 @@ test("Cox can start and finish trip with cox steering only", async ({ page }, te
|
||||
|
||||
await page.goto('/log/show');
|
||||
await expect(page.locator('body')).toContainText('cox_only_steering_boat');
|
||||
await expect(page.locator('body')).toContainText('(cox2 - handgesteuert)');
|
||||
await expect(page.locator('body')).toContainText('Ottensheim (25 km)');
|
||||
|
||||
|
||||
@ -302,7 +300,7 @@ test("Cox can start and finish trip with cox steering only", async ({ page }, te
|
||||
await page.getByPlaceholder("Passwort").press("Enter");
|
||||
|
||||
await page.goto("/log/show");
|
||||
await page.getByText('(cox2 - handgesteuert)').click();
|
||||
await page.getByRole("link", { name: "cox_only_steering_boat" }).click();
|
||||
page.once("dialog", (dialog) => {
|
||||
dialog.accept().catch(() => {});
|
||||
});
|
||||
@ -371,7 +369,7 @@ test("Kiosk can start and finish trip in one stop", async ({ page }, testInfo) =
|
||||
await page.getByPlaceholder("Passwort").press("Enter");
|
||||
|
||||
await page.goto("/log/show");
|
||||
await page.getByText('(cox2)').click();
|
||||
await page.getByRole('link', { name: 'Joe' }).nth(1).click();
|
||||
page.once("dialog", (dialog) => {
|
||||
dialog.accept().catch(() => {});
|
||||
});
|
||||
|
@ -23,6 +23,9 @@ pub(crate) const UNTERSTUETZEND: i64 = 2500;
|
||||
pub(crate) const FOERDERND: i64 = 8500;
|
||||
pub(crate) const SCHECKBUCH: i64 = 3000;
|
||||
pub(crate) const EINSCHREIBGEBUEHR: i64 = 3000;
|
||||
pub(crate) const DUAL_MEMBERSHIP: i64 = 18000;
|
||||
pub(crate) const TRIAL_ROWING: i64 = 12000;
|
||||
pub(crate) const TRIAL_ROWING_REDUCED: i64 = 6000;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct NonEmptyString(String);
|
||||
|
@ -1,7 +1,11 @@
|
||||
use std::ops::DerefMut;
|
||||
|
||||
use super::{role::Role, user::User};
|
||||
use chrono::NaiveDateTime;
|
||||
use super::{
|
||||
logbook::{Logbook, LogbookWithBoatAndRowers},
|
||||
role::Role,
|
||||
user::{ManageUserUser, User},
|
||||
};
|
||||
use chrono::{DateTime, Duration, Local, NaiveDateTime, TimeZone, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||
|
||||
@ -14,6 +18,115 @@ pub struct Activity {
|
||||
pub keep_until: Option<NaiveDateTime>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ActivityWithDetails {
|
||||
#[serde(flatten)]
|
||||
pub(crate) activity: Activity,
|
||||
keep_until_days: Option<i64>,
|
||||
}
|
||||
|
||||
impl From<Activity> for ActivityWithDetails {
|
||||
fn from(activity: Activity) -> Self {
|
||||
let keep_until_days = activity.keep_until.map(|keep_until| {
|
||||
let now = Utc::now().naive_utc();
|
||||
let duration = keep_until.signed_duration_since(now);
|
||||
duration.num_days()
|
||||
});
|
||||
|
||||
Self {
|
||||
keep_until_days,
|
||||
activity,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
NewUserNote(&'a ManageUserUser, &'a User, String),
|
||||
}
|
||||
|
||||
impl From<Reason<'_>> for ActivityBuilder {
|
||||
fn from(value: Reason<'_>) -> Self {
|
||||
match value {
|
||||
Reason::Auth(auth) => auth.into(),
|
||||
Reason::UserDataChange(changed_by, changed_user, explanation) => Self::new(&format!(
|
||||
"{changed_by} hat die Daten von {changed_user} aktualisiert: {explanation}"
|
||||
))
|
||||
.user(changed_user),
|
||||
Reason::NewUserNote(changed_by, user, explanation) => {
|
||||
Self::new(&format!("({changed_by}) {explanation}")).user(user)
|
||||
}
|
||||
Reason::Logbook(logbook) => logbook.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum ReasonAuth<'a> {
|
||||
// `User` tried to login with `String` as UserAgent
|
||||
SuccLogin(&'a User, String),
|
||||
// `User` tried to login which was already deleted
|
||||
DeletedUserLogin(&'a User),
|
||||
// `User` tried to login, supplied wrong PW
|
||||
WrongPw(&'a User),
|
||||
}
|
||||
|
||||
impl<'a> From<ReasonAuth<'a>> for Reason<'a> {
|
||||
fn from(auth_reason: ReasonAuth<'a>) -> Self {
|
||||
Reason::Auth(auth_reason)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ReasonAuth<'_>> for ActivityBuilder {
|
||||
fn from(value: ReasonAuth<'_>) -> Self {
|
||||
match value {
|
||||
ReasonAuth::SuccLogin(user, agent) => {
|
||||
Self::new(&format!("{user} hat sich eingeloggt (User-Agent: {agent})"))
|
||||
.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."
|
||||
))
|
||||
.user(user)
|
||||
.keep_until_days(30),
|
||||
ReasonAuth::WrongPw(user) => Self::new(&format!(
|
||||
"User {user} wollte sich einloggen, hat jedoch das falsche Passwort angegeben."
|
||||
))
|
||||
.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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ActivityBuilder {
|
||||
text: String,
|
||||
relevant_for: String,
|
||||
@ -21,6 +134,7 @@ pub struct ActivityBuilder {
|
||||
}
|
||||
|
||||
impl ActivityBuilder {
|
||||
/// TODO: maybe make this private, and only allow specific acitivites defined in `Reason`
|
||||
#[must_use]
|
||||
pub fn new(text: &str) -> Self {
|
||||
Self {
|
||||
@ -31,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
|
||||
@ -39,13 +153,30 @@ 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();
|
||||
Self {
|
||||
keep_until: Some(now + Duration::days(days)),
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn save(self, db: &SqlitePool) {
|
||||
Activity::create(db, &self.text, &self.relevant_for, self.keep_until).await;
|
||||
}
|
||||
@ -110,4 +241,30 @@ ORDER BY created_at DESC;
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
async fn last(db: &SqlitePool) -> Vec<Self> {
|
||||
sqlx::query_as!(
|
||||
Self,
|
||||
"
|
||||
SELECT id, created_at, text, relevant_for, keep_until FROM activity
|
||||
ORDER BY id DESC
|
||||
LIMIT 1000
|
||||
"
|
||||
)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub async fn show(db: &SqlitePool) -> String {
|
||||
let mut ret = String::new();
|
||||
|
||||
for log in Self::last(db).await {
|
||||
let utc_time: DateTime<Utc> = Utc::from_utc_datetime(&Utc, &log.created_at);
|
||||
let local_time = utc_time.with_timezone(&Local);
|
||||
ret.push_str(&format!("- {local_time}: {}\n", log.text));
|
||||
}
|
||||
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
use std::ops::DerefMut;
|
||||
|
||||
use chrono::NaiveDateTime;
|
||||
use itertools::Itertools;
|
||||
use rocket::FromForm;
|
||||
use rocket::serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||
@ -10,6 +9,7 @@ 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 {
|
||||
@ -32,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 {
|
||||
@ -102,24 +113,10 @@ impl Boat {
|
||||
}
|
||||
|
||||
pub async fn shipmaster_allowed(&self, db: &SqlitePool, user: &User) -> bool {
|
||||
if let Some(owner_id) = self.owner {
|
||||
return owner_id == user.id;
|
||||
}
|
||||
|
||||
if user.has_role(db, "Rennrudern").await {
|
||||
let ottensheim = Location::find_by_name(db, "Ottensheim".into())
|
||||
.await
|
||||
.unwrap();
|
||||
if self.location_id == ottensheim.id {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if self.amount_seats == 1 {
|
||||
return true;
|
||||
}
|
||||
|
||||
user.allowed_to_steer(db).await
|
||||
let mut tx = db.begin().await.unwrap();
|
||||
let ret = self.shipmaster_allowed_tx(&mut tx, user).await;
|
||||
tx.commit().await.unwrap();
|
||||
ret
|
||||
}
|
||||
|
||||
pub async fn shipmaster_allowed_tx(
|
||||
@ -127,10 +124,27 @@ impl Boat {
|
||||
db: &mut Transaction<'_, Sqlite>,
|
||||
user: &User,
|
||||
) -> bool {
|
||||
if user.has_role_tx(db, "admin").await {
|
||||
return true;
|
||||
}
|
||||
|
||||
if let Some(owner_id) = self.owner {
|
||||
return owner_id == user.id;
|
||||
}
|
||||
|
||||
if user.has_role_tx(db, "Rennrudern").await {
|
||||
let ottensheim = Location::find_by_name_tx(db, "Ottensheim".into())
|
||||
.await
|
||||
.unwrap();
|
||||
if self.location_id == ottensheim.id {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if self.name == "Externes Boot" {
|
||||
return true;
|
||||
}
|
||||
|
||||
if self.amount_seats == 1 {
|
||||
return true;
|
||||
}
|
||||
@ -176,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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,58 +273,16 @@ ORDER BY
|
||||
}
|
||||
|
||||
pub async fn for_user(db: &SqlitePool, user: &User) -> Vec<BoatWithDetails> {
|
||||
if user.has_role(db, "admin").await {
|
||||
return Self::all(db).await;
|
||||
}
|
||||
let mut boats = if user.allowed_to_steer(db).await {
|
||||
sqlx::query_as!(
|
||||
Boat,
|
||||
"
|
||||
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible
|
||||
FROM boat
|
||||
WHERE (owner is null or owner = ?) AND deleted = 0
|
||||
ORDER BY amount_seats DESC
|
||||
",
|
||||
user.id
|
||||
)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap() //TODO: fixme
|
||||
} else {
|
||||
sqlx::query_as!(
|
||||
Boat,
|
||||
"
|
||||
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible
|
||||
FROM boat
|
||||
WHERE (owner = ? OR (owner is null and amount_seats = 1)) AND deleted = 0
|
||||
ORDER BY amount_seats DESC
|
||||
",
|
||||
user.id
|
||||
)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap() //TODO: fixme
|
||||
};
|
||||
let all_boats = Self::all(db).await;
|
||||
let mut filtered_boats = Vec::new();
|
||||
|
||||
if user.has_role(db, "Rennrudern").await {
|
||||
let ottensheim = Location::find_by_name(db, "Ottensheim".into())
|
||||
.await
|
||||
.unwrap();
|
||||
let boats_in_ottensheim = sqlx::query_as!(
|
||||
Boat,
|
||||
"SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible
|
||||
FROM boat
|
||||
WHERE (owner is null and location_id = ?) AND deleted = 0
|
||||
ORDER BY amount_seats DESC
|
||||
",ottensheim.id)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap(); //TODO: fixme
|
||||
boats.extend(boats_in_ottensheim.into_iter());
|
||||
for boat in all_boats {
|
||||
if boat.boat.shipmaster_allowed(db, user).await {
|
||||
filtered_boats.push(boat);
|
||||
}
|
||||
}
|
||||
let boats = boats.into_iter().unique().collect();
|
||||
|
||||
Self::boats_to_details(db, boats).await
|
||||
filtered_boats
|
||||
}
|
||||
|
||||
pub async fn all_at_location(db: &SqlitePool, location: String) -> Vec<BoatWithDetails> {
|
||||
|
@ -86,7 +86,7 @@ GROUP BY family.id;"
|
||||
}
|
||||
|
||||
pub async fn members(&self, db: &SqlitePool) -> Vec<User> {
|
||||
sqlx::query_as!(User, "SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, user_token FROM user WHERE family_id = ?", self.id)
|
||||
sqlx::query_as!(User, "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 family_id = ?", self.id)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap()
|
||||
|
@ -1,5 +1,6 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, SqlitePool};
|
||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||
use std::ops::DerefMut;
|
||||
|
||||
#[derive(FromRow, Debug, Serialize, Deserialize)]
|
||||
pub struct Location {
|
||||
@ -37,6 +38,20 @@ impl Location {
|
||||
.await
|
||||
.ok()
|
||||
}
|
||||
pub async fn find_by_name_tx(db: &mut Transaction<'_, Sqlite>, name: String) -> Option<Self> {
|
||||
sqlx::query_as!(
|
||||
Self,
|
||||
"
|
||||
SELECT id, name
|
||||
FROM location
|
||||
WHERE name=?
|
||||
",
|
||||
name
|
||||
)
|
||||
.fetch_one(db.deref_mut())
|
||||
.await
|
||||
.ok()
|
||||
}
|
||||
|
||||
pub async fn all(db: &SqlitePool) -> Vec<Self> {
|
||||
sqlx::query_as!(Self, "SELECT id, name FROM location")
|
||||
|
@ -1,74 +1,16 @@
|
||||
use std::ops::DerefMut;
|
||||
use super::activity::ActivityBuilder;
|
||||
use sqlx::{Sqlite, SqlitePool, Transaction};
|
||||
|
||||
use chrono::{DateTime, Local, NaiveDateTime, TimeZone, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||
|
||||
#[derive(FromRow, Debug, Serialize, Deserialize)]
|
||||
pub struct Log {
|
||||
pub msg: String,
|
||||
pub created_at: NaiveDateTime,
|
||||
}
|
||||
pub struct Log {}
|
||||
|
||||
// TODO: remove and convert to proper acitvities
|
||||
impl Log {
|
||||
pub async fn create(db: &SqlitePool, msg: String) -> bool {
|
||||
sqlx::query!("INSERT INTO log(msg) VALUES (?)", msg,)
|
||||
.execute(db)
|
||||
.await
|
||||
.is_ok()
|
||||
ActivityBuilder::new(&msg).save(db).await;
|
||||
true
|
||||
}
|
||||
pub async fn create_with_tx(db: &mut Transaction<'_, Sqlite>, msg: String) -> bool {
|
||||
sqlx::query!("INSERT INTO log(msg) VALUES (?)", msg,)
|
||||
.execute(db.deref_mut())
|
||||
.await
|
||||
.is_ok()
|
||||
}
|
||||
|
||||
async fn last(db: &SqlitePool) -> Vec<Log> {
|
||||
sqlx::query_as!(
|
||||
Log,
|
||||
"
|
||||
SELECT msg, created_at
|
||||
FROM log
|
||||
ORDER BY id DESC
|
||||
LIMIT 1000
|
||||
"
|
||||
)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub async fn generate_feed(db: &SqlitePool) -> String {
|
||||
let mut ret = String::from(
|
||||
r#"<?xml version="1.0" encoding="utf-8"?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>Ruder App Admin Feed</title>
|
||||
<link>app.rudernlinz.at</link>
|
||||
<description>An RSS feed with activities from app.rudernlinz.at</description>"#,
|
||||
);
|
||||
for log in Self::last(db).await {
|
||||
let utc_time: DateTime<Utc> = Utc::from_utc_datetime(&Utc, &log.created_at);
|
||||
let local_time = utc_time.with_timezone(&Local);
|
||||
ret.push_str("<item><title>");
|
||||
ret.push_str(&format!("({}) {}", local_time, log.msg));
|
||||
ret.push_str("</title></item>");
|
||||
}
|
||||
ret.push_str("</channel>");
|
||||
ret.push_str("</rss>");
|
||||
ret.replace('\n', "")
|
||||
}
|
||||
|
||||
pub async fn show(db: &SqlitePool) -> String {
|
||||
let mut ret = String::new();
|
||||
|
||||
for log in Self::last(db).await {
|
||||
let utc_time: DateTime<Utc> = Utc::from_utc_datetime(&Utc, &log.created_at);
|
||||
let local_time = utc_time.with_timezone(&Local);
|
||||
ret.push_str(&format!("- {} - {}\n", local_time, log.msg));
|
||||
}
|
||||
|
||||
ret
|
||||
ActivityBuilder::new(&msg).save_tx(db).await;
|
||||
true
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
@ -367,7 +417,6 @@ ORDER BY departure DESC
|
||||
min_distance: i32,
|
||||
year: i32,
|
||||
filter: Filter,
|
||||
exclude_last_log: bool,
|
||||
) -> Vec<LogbookWithBoatAndRowers> {
|
||||
let logs: Vec<Logbook> = sqlx::query_as(
|
||||
&format!("
|
||||
@ -399,9 +448,6 @@ ORDER BY departure DESC
|
||||
}
|
||||
}
|
||||
}
|
||||
if exclude_last_log {
|
||||
ret.pop();
|
||||
}
|
||||
|
||||
ret
|
||||
}
|
||||
@ -583,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,
|
||||
@ -609,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>) {
|
||||
@ -811,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,
|
||||
@ -862,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
|
||||
|
@ -161,6 +161,11 @@ impl Mail {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if user.has_role(db, "schnupperant").await || user.has_role(db, "scheckbuch").await {
|
||||
continue;
|
||||
}
|
||||
|
||||
if !user.has_role(db, "paid").await || test.is_some() {
|
||||
let mut is_family = false;
|
||||
let mut send_to = String::new();
|
||||
@ -256,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;
|
||||
}
|
||||
@ -273,6 +278,11 @@ Der Vorstand");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if user.has_role(db, "schnupperant").await || user.has_role(db, "scheckbuch").await {
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Some(fee) = user.fee(db).await {
|
||||
if !fee.paid || test.is_some() {
|
||||
let mut is_family = false;
|
||||
@ -378,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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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,
|
||||
};
|
||||
|
||||
|
@ -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");
|
||||
@ -19,9 +27,131 @@ pub(crate) async fn get_personal_cal(db: &SqlitePool, user: &User) -> String {
|
||||
|
||||
let trips = Trip::all_with_user(db, user).await;
|
||||
for trip in trips {
|
||||
calendar.add_event(trip.get_vevent(user).await);
|
||||
calendar.add_event(trip.get_vevent(db, user).await);
|
||||
}
|
||||
let mut buf = Vec::new();
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use std::cmp;
|
||||
|
||||
use chrono::{Datelike, Local, NaiveDate};
|
||||
use serde::Serialize;
|
||||
use sqlx::{Sqlite, SqlitePool, Transaction};
|
||||
use sqlx::{Acquire, Sqlite, SqlitePool, Transaction};
|
||||
|
||||
use crate::model::{
|
||||
logbook::{Filter, Logbook, LogbookWithBoatAndRowers},
|
||||
@ -141,11 +141,7 @@ impl Status {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn for_user_tx(
|
||||
db: &mut Transaction<'_, Sqlite>,
|
||||
user: &User,
|
||||
exclude_last_log: bool,
|
||||
) -> Option<Self> {
|
||||
pub(crate) async fn for_user_tx(db: &mut Transaction<'_, Sqlite>, user: &User) -> Option<Self> {
|
||||
let Ok(agebracket) = AgeBracket::try_from(user) else {
|
||||
return None;
|
||||
};
|
||||
@ -164,7 +160,6 @@ impl Status {
|
||||
agebracket.required_dist_single_day_in_km(),
|
||||
year,
|
||||
Filter::SingleDayOnly,
|
||||
exclude_last_log,
|
||||
)
|
||||
.await;
|
||||
let multi_day_trips_over_required_distance =
|
||||
@ -174,7 +169,6 @@ impl Status {
|
||||
agebracket.required_dist_multi_day_in_km(),
|
||||
year,
|
||||
Filter::MultiDayOnly,
|
||||
exclude_last_log,
|
||||
)
|
||||
.await;
|
||||
|
||||
@ -195,7 +189,7 @@ impl Status {
|
||||
|
||||
pub(crate) async fn for_user(db: &SqlitePool, user: &User) -> Option<Self> {
|
||||
let mut tx = db.begin().await.unwrap();
|
||||
let ret = Self::for_user_tx(&mut tx, user, false).await;
|
||||
let ret = Self::for_user_tx(&mut tx, user).await;
|
||||
tx.commit().await.unwrap();
|
||||
ret
|
||||
}
|
||||
@ -204,11 +198,19 @@ impl Status {
|
||||
db: &mut Transaction<'_, Sqlite>,
|
||||
user: &User,
|
||||
) -> bool {
|
||||
if let Some(status) = Self::for_user_tx(db, user, false).await {
|
||||
if let Some(status) = Self::for_user_tx(db, user).await {
|
||||
// if user has agebracket...
|
||||
if status.achieved {
|
||||
// ... and has achieved the 'Fahrtenabzeichen'
|
||||
let without_last_entry = Self::for_user_tx(db, user, true).await.unwrap();
|
||||
let mut without_last = db.begin().await.unwrap();
|
||||
let last = Logbook::completed_with_user_tx(&mut without_last, user).await;
|
||||
let last = last.last().unwrap();
|
||||
sqlx::query!("DELETE FROM logbook WHERE id=?", last.logbook.id)
|
||||
.execute(&mut *without_last)
|
||||
.await
|
||||
.unwrap(); //Okay, because we can only create a Logbook of a valid id
|
||||
|
||||
let without_last_entry = Self::for_user_tx(&mut without_last, user).await.unwrap();
|
||||
if !without_last_entry.achieved {
|
||||
// ... and this wasn't the case before the last logentry
|
||||
return true;
|
||||
|
@ -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,6 +139,14 @@ WHERE planned_event.id like ?
|
||||
.ok()
|
||||
}
|
||||
|
||||
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 {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_pinned_for_day(db: &SqlitePool, day: NaiveDate) -> Vec<EventWithDetails> {
|
||||
let mut events = Self::get_for_day(db, day).await;
|
||||
events.retain(|e| e.event.always_show);
|
||||
@ -466,57 +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 later_time = 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
|
||||
@ -528,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
19
src/model/planned/mod.rs
Normal 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;
|
79
src/model/planned/trip/create.rs
Normal file
79
src/model/planned/trip/create.rs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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,54 +89,12 @@ WHERE trip_details.id=?
|
||||
.ok()
|
||||
}
|
||||
|
||||
pub(crate) async fn get_vevent(self, user: &User) -> ics::Event {
|
||||
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)
|
||||
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 {
|
||||
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 later_time = 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
|
||||
)));
|
||||
None
|
||||
}
|
||||
|
||||
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> {
|
||||
@ -475,7 +377,7 @@ WHERE day=?
|
||||
trips
|
||||
}
|
||||
|
||||
fn is_cancelled(&self) -> bool {
|
||||
pub(crate) fn is_cancelled(&self) -> bool {
|
||||
self.max_people == -1
|
||||
}
|
||||
}
|
||||
@ -511,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,
|
||||
};
|
||||
|
@ -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;
|
@ -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,
|
||||
};
|
@ -40,8 +40,12 @@ impl Ord for Role {
|
||||
|
||||
impl Display for Role {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
if let Some(formatted_name) = &self.formatted_name {
|
||||
write!(f, "{}", formatted_name)
|
||||
} else {
|
||||
write!(f, "{}", self.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Role {
|
||||
@ -154,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(())
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ impl Rower {
|
||||
sqlx::query_as!(
|
||||
User,
|
||||
"
|
||||
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, user_token
|
||||
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 id in (SELECT rower_id FROM rower WHERE logbook_id=?)
|
||||
",
|
||||
|
@ -2,7 +2,10 @@
|
||||
|
||||
use super::{AllowedToEditPaymentStatusUser, ManageUserUser, User};
|
||||
use crate::model::{
|
||||
activity::ActivityBuilder, family::Family, mail::valid_mails, notification::Notification,
|
||||
activity::{self, ActivityBuilder},
|
||||
family::Family,
|
||||
mail::valid_mails,
|
||||
notification::Notification,
|
||||
role::Role,
|
||||
};
|
||||
use chrono::NaiveDate;
|
||||
@ -14,13 +17,15 @@ impl User {
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
updated_by: &ManageUserUser,
|
||||
user: &User,
|
||||
note: &str,
|
||||
) -> Result<(), String> {
|
||||
let note = note.trim();
|
||||
|
||||
ActivityBuilder::new(&format!("({updated_by}) {note}"))
|
||||
.relevant_for_user(user)
|
||||
ActivityBuilder::from(activity::Reason::UserDataChange(
|
||||
updated_by,
|
||||
self,
|
||||
note.to_string(),
|
||||
))
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
@ -47,18 +52,11 @@ impl User {
|
||||
.unwrap(); //Okay, because we can only create a User of a valid id
|
||||
|
||||
let msg = match &self.mail {
|
||||
Some(old_mail) => {
|
||||
format!(
|
||||
"{updated_by} hat die Mail-Adresse von {self} von {old_mail} auf {new_mail} geändert."
|
||||
)
|
||||
}
|
||||
None => {
|
||||
format!("{updated_by} eine neue Mail-Adresse für {self} hinzugefügt: {new_mail}")
|
||||
}
|
||||
Some(old_mail) => format!("Mail-Adresse von {old_mail} auf {new_mail} geändert."),
|
||||
None => format!("Neue Mail-Adresse für: {new_mail}"),
|
||||
};
|
||||
|
||||
ActivityBuilder::new(&msg)
|
||||
.relevant_for_user(self)
|
||||
ActivityBuilder::from(activity::Reason::UserDataChange(updated_by, self, msg))
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
@ -89,19 +87,16 @@ impl User {
|
||||
query.execute(db).await.unwrap(); //Okay, because we can only create a User of a valid id
|
||||
|
||||
let msg = match &self.phone {
|
||||
Some(old_phone) if new_phone.is_empty() => format!(
|
||||
"{updated_by} hat die Telefonnummer von {self} entfernt (alte Nummer: {old_phone})"
|
||||
),
|
||||
Some(old_phone) => format!(
|
||||
"{updated_by} hat die Telefonnummer von {self} von {old_phone} auf {new_phone} geändert."
|
||||
),
|
||||
None => format!(
|
||||
"{updated_by} hat eine neue Telefonnummer für {self} hinzugefügt: {new_phone}"
|
||||
),
|
||||
Some(old_phone) if new_phone.is_empty() => {
|
||||
format!("Telefonnummer wurde entfernt (alte Nummer: {old_phone})")
|
||||
}
|
||||
Some(old_phone) => {
|
||||
format!("Telefonnummer wurde von {old_phone} auf {new_phone} geändert.")
|
||||
}
|
||||
None => format!("Neue Telefonnummer hinzugefügt: {new_phone}"),
|
||||
};
|
||||
|
||||
ActivityBuilder::new(&msg)
|
||||
.relevant_for_user(self)
|
||||
ActivityBuilder::from(activity::Reason::UserDataChange(updated_by, self, msg))
|
||||
.save(db)
|
||||
.await;
|
||||
}
|
||||
@ -143,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(
|
||||
@ -179,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(())
|
||||
}
|
||||
@ -211,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(
|
||||
@ -241,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(
|
||||
@ -266,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 {
|
||||
@ -277,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;
|
||||
};
|
||||
@ -311,8 +294,19 @@ impl User {
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
Notification::create(
|
||||
db,
|
||||
self,
|
||||
&format!(
|
||||
"Liebe neue Steuerperson, gratuliere zur geschafften Steuerprüfung 💪. Du kannst ab sofort selber Ausfahrten ausschreiben und der Steuerpersonen Signal-Gruppe beitreten: https://signal.group/#CjQKIHJInNb3zSVW7ipLo7_ygIqVxhxUaaNYx4sy2jdklLsIEhBHJNM2KZM1UnBdQxWy_Gdp"
|
||||
),
|
||||
"Gratulation",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
ActivityBuilder::new(&format!("{updated_by} hat {self} zur Steuerperson gemacht"))
|
||||
.relevant_for_user(self)
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
}
|
||||
@ -331,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;
|
||||
}
|
||||
@ -342,14 +336,14 @@ impl User {
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
&vorstand,
|
||||
&format!("Lieber Vorstand, {self} ist ab kein {old} mehr."),
|
||||
"Steuerperson --",
|
||||
&format!("Lieber Vorstand, {self} ist ab sofort kein {old} mehr."),
|
||||
"Steuerperson--;",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
ActivityBuilder::new(&format!("{updated_by} hat {self} zum normalen Mitlgied gemacht (keine Steuerperson/Schiffsführer mehr)"))
|
||||
.relevant_for_user(self)
|
||||
ActivityBuilder::new(&format!("{updated_by} hat {self} zum normalen Mitglied gemacht (keine Steuerperson/Schiffsführer mehr)"))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
}
|
||||
@ -371,14 +365,14 @@ impl User {
|
||||
|
||||
if let Some(old_financial) = self.financial(db).await {
|
||||
self.remove_role(db, updated_by, &old_financial).await?;
|
||||
old.push_str(&old_financial.name);
|
||||
old.push_str(&old_financial.to_string());
|
||||
} else {
|
||||
old.push_str("Keine Ermäßigung");
|
||||
}
|
||||
|
||||
if let Some(new_financial) = financial {
|
||||
self.add_role(db, updated_by, &new_financial).await?;
|
||||
new.push_str(&new_financial.name);
|
||||
new.push_str(&new_financial.to_string());
|
||||
} else {
|
||||
new.push_str("Keine Ermäßigung");
|
||||
}
|
||||
@ -386,7 +380,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;
|
||||
|
||||
@ -418,7 +412,7 @@ impl User {
|
||||
ActivityBuilder::new(&format!(
|
||||
"{updated_by} hat die Rolle {role} von {self} entfernt."
|
||||
))
|
||||
.relevant_for_user(self)
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
}
|
||||
@ -445,7 +439,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;
|
||||
}
|
||||
@ -468,7 +462,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;
|
||||
}
|
||||
@ -505,7 +499,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;
|
||||
}
|
||||
@ -513,6 +507,15 @@ impl User {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn remove_membership_pdf(&self, db: &SqlitePool, updated_by: &ManageUserUser) {
|
||||
sqlx::query!(
|
||||
"UPDATE user SET membership_pdf = null where id = ?",
|
||||
self.id
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap(); //Okay, because we can only create a User of a valid id
|
||||
}
|
||||
pub(crate) async fn add_membership_pdf(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
@ -541,7 +544,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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
use super::User;
|
||||
use crate::{
|
||||
BOAT_STORAGE, EINSCHREIBGEBUEHR, FAMILY_THREE_OR_MORE, FAMILY_TWO, FOERDERND, REGULAR,
|
||||
RENNRUDERBEITRAG, STUDENT_OR_PUPIL, UNTERSTUETZEND, model::family::Family,
|
||||
BOAT_STORAGE, DUAL_MEMBERSHIP, EINSCHREIBGEBUEHR, FAMILY_THREE_OR_MORE, FAMILY_TWO, FOERDERND,
|
||||
REGULAR, RENNRUDERBEITRAG, SCHECKBUCH, STUDENT_OR_PUPIL, TRIAL_ROWING, TRIAL_ROWING_REDUCED,
|
||||
UNTERSTUETZEND, model::family::Family,
|
||||
};
|
||||
use chrono::{Datelike, Local, NaiveDate};
|
||||
use serde::Serialize;
|
||||
@ -68,6 +69,8 @@ impl User {
|
||||
if !self.has_role(db, "Donau Linz").await
|
||||
&& !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;
|
||||
}
|
||||
@ -107,6 +110,8 @@ impl User {
|
||||
if !self.has_role(db, "Donau Linz").await
|
||||
&& !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;
|
||||
}
|
||||
@ -126,8 +131,10 @@ impl User {
|
||||
);
|
||||
}
|
||||
|
||||
if !self.has_role(db, "schnupperant").await {
|
||||
if let Some(member_since_date) = &self.member_since_date {
|
||||
if let Ok(member_since_date) = NaiveDate::parse_from_str(member_since_date, "%Y-%m-%d")
|
||||
if let Ok(member_since_date) =
|
||||
NaiveDate::parse_from_str(member_since_date, "%Y-%m-%d")
|
||||
{
|
||||
if member_since_date.year() == Local::now().year()
|
||||
&& !self.has_role(db, "no-einschreibgebuehr").await
|
||||
@ -136,6 +143,7 @@ impl User {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let halfprice = if let Some(member_since_date) = &self.member_since_date {
|
||||
match NaiveDate::parse_from_str(member_since_date, "%Y-%m-%d") {
|
||||
@ -150,7 +158,15 @@ impl User {
|
||||
false
|
||||
};
|
||||
|
||||
if self.has_role(db, "Unterstützend").await {
|
||||
if self.has_role(db, "schnupperant").await {
|
||||
if self.has_role(db, "Student").await || self.has_role(db, "Schüler").await {
|
||||
fee.add("Schnupperkurs (reduziert)".into(), TRIAL_ROWING_REDUCED);
|
||||
} 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 {
|
||||
fee.add("Förderndes Mitglied".into(), FOERDERND);
|
||||
@ -163,6 +179,18 @@ impl User {
|
||||
}
|
||||
} else if self.has_role(db, "Ehrenmitglied").await {
|
||||
fee.add("Ehrenmitglied".into(), 0);
|
||||
} else if self.has_role(db, "dual_membership").await {
|
||||
if halfprice {
|
||||
fee.add(
|
||||
"Doppelmitgliedschaft mit anderem österr. Ruderverein (Halbpreis)".into(),
|
||||
DUAL_MEMBERSHIP / 2,
|
||||
);
|
||||
} else {
|
||||
fee.add(
|
||||
"Doppelmitgliedschaft mit anderem österr. Ruderverein".into(),
|
||||
DUAL_MEMBERSHIP,
|
||||
);
|
||||
}
|
||||
} else if halfprice {
|
||||
fee.add("Mitgliedsbeitrag (Halbpreis)".into(), REGULAR / 2);
|
||||
} else {
|
||||
@ -170,6 +198,19 @@ impl User {
|
||||
}
|
||||
}
|
||||
|
||||
if !self.has_role(db, "schnupperant").await
|
||||
&& self.has_role(db, "participated_schnupperkurs").await
|
||||
{
|
||||
if self.has_role(db, "Student").await || self.has_role(db, "Schüler").await {
|
||||
fee.add(
|
||||
"Anrechnung reduzierter Schnupperkurs".into(),
|
||||
-TRIAL_ROWING_REDUCED,
|
||||
);
|
||||
} else {
|
||||
fee.add("Anrechnung Schnupperkurs".into(), -TRIAL_ROWING);
|
||||
}
|
||||
}
|
||||
|
||||
fee
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -13,16 +13,16 @@ use rocket::{
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||
|
||||
use super::activity::ActivityBuilder;
|
||||
use super::activity::{ActivityBuilder, ReasonAuth};
|
||||
use super::{
|
||||
log::Log,
|
||||
logbook::Logbook,
|
||||
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;
|
||||
@ -53,7 +53,6 @@ pub struct User {
|
||||
pub birthdate: Option<String>,
|
||||
pub mail: Option<String>,
|
||||
pub nickname: Option<String>,
|
||||
pub notes: Option<String>,
|
||||
pub phone: Option<String>,
|
||||
pub address: Option<String>,
|
||||
pub family_id: Option<i64>,
|
||||
@ -66,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)]
|
||||
@ -262,7 +276,7 @@ AND r.cluster = 'skill';
|
||||
sqlx::query_as!(
|
||||
Self,
|
||||
"
|
||||
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, user_token
|
||||
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 id like ?
|
||||
",
|
||||
@ -277,7 +291,7 @@ WHERE id like ?
|
||||
sqlx::query_as!(
|
||||
Self,
|
||||
"
|
||||
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, user_token
|
||||
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 id like ?
|
||||
",
|
||||
@ -289,14 +303,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, notes, phone, address, family_id, user_token
|
||||
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
|
||||
)
|
||||
@ -339,7 +353,7 @@ WHERE lower(name)=?
|
||||
pub async fn all_with_order(db: &SqlitePool, sort: &str, asc: bool) -> Vec<Self> {
|
||||
let mut query = format!(
|
||||
"
|
||||
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, user_token
|
||||
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
|
||||
ORDER BY {}
|
||||
@ -367,7 +381,7 @@ WHERE lower(name)=?
|
||||
sqlx::query_as!(
|
||||
Self,
|
||||
"
|
||||
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, user_token
|
||||
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, phone, address, family_id, user_token
|
||||
FROM user u
|
||||
JOIN user_role ur ON u.id = ur.user_id
|
||||
WHERE ur.role_id = ? AND deleted = 0
|
||||
@ -383,14 +397,14 @@ ORDER BY name;
|
||||
sqlx::query_as!(
|
||||
Self,
|
||||
"
|
||||
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, user_token FROM user
|
||||
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 family_id IS NOT NULL
|
||||
GROUP BY family_id
|
||||
|
||||
UNION
|
||||
|
||||
-- Select users with a null family_id, without grouping
|
||||
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, user_token FROM user
|
||||
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 family_id IS NULL;
|
||||
"
|
||||
)
|
||||
@ -408,7 +422,7 @@ WHERE family_id IS NULL;
|
||||
sqlx::query_as!(
|
||||
Self,
|
||||
"
|
||||
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, user_token
|
||||
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
|
||||
ORDER BY last_access DESC
|
||||
@ -458,7 +472,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(())
|
||||
}
|
||||
@ -466,49 +480,25 @@ ASKÖ Ruderverein Donau Linz", self.name),
|
||||
pub async fn login(db: &SqlitePool, name: &str, pw: &str) -> Result<Self, LoginError> {
|
||||
let name = name.trim().to_lowercase(); // just to make sure...
|
||||
let Some(user) = User::find_by_name(db, &name).await else {
|
||||
if ![
|
||||
"n-sageder",
|
||||
"p-hofer",
|
||||
"marie-birner",
|
||||
"daniel-kortschak",
|
||||
"rudernlinz",
|
||||
"m-birner",
|
||||
"s-sollberger",
|
||||
"d-kortschak",
|
||||
"wwwadmin",
|
||||
"wadminw",
|
||||
"admin",
|
||||
"m sageder",
|
||||
"d kortschak",
|
||||
"a almousa",
|
||||
"p hofer",
|
||||
"s sollberger",
|
||||
"n sageder",
|
||||
"wp-system",
|
||||
"s.sollberger",
|
||||
"m.birner",
|
||||
"m-sageder",
|
||||
"a-almousa",
|
||||
"m.sageder",
|
||||
"n.sageder",
|
||||
"a.almousa",
|
||||
"p.hofer",
|
||||
"philipp-hofer",
|
||||
"d.kortschak",
|
||||
"[login]",
|
||||
]
|
||||
.contains(&name.as_str())
|
||||
{
|
||||
Log::create(db, format!("Username ({name}) not found (tried to login)")).await;
|
||||
}
|
||||
return Err(LoginError::InvalidAuthenticationCombo); // Username not found
|
||||
};
|
||||
|
||||
if user.deleted {
|
||||
ActivityBuilder::new(&format!(
|
||||
"User {user} wollte sich einloggen, klappte jedoch nicht weil er gelöscht wurde."
|
||||
))
|
||||
.relevant_for_user(&user)
|
||||
if let Some(board) = Role::find_by_name(db, "Vorstand").await {
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
&board,
|
||||
&format!(
|
||||
"{user} wollte sich einloggen, klappte jedoch nicht weil der Account gelöscht wurde."
|
||||
),
|
||||
"Fehlgeschlagener Login",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
ActivityBuilder::from(ReasonAuth::DeletedUserLogin(&user))
|
||||
.save(db)
|
||||
.await;
|
||||
return Err(LoginError::InvalidAuthenticationCombo); //User existed sometime ago; has
|
||||
@ -520,10 +510,7 @@ ASKÖ Ruderverein Donau Linz", self.name),
|
||||
if password_hash == user_pw {
|
||||
return Ok(user);
|
||||
}
|
||||
ActivityBuilder::new(&format!(
|
||||
"User {user} wollte sich einloggen, hat jedoch das falsche Passwort angegeben."
|
||||
))
|
||||
.relevant_for_user(&user)
|
||||
ActivityBuilder::from(ReasonAuth::WrongPw(&user))
|
||||
.save(db)
|
||||
.await;
|
||||
Err(LoginError::InvalidAuthenticationCombo)
|
||||
@ -533,15 +520,17 @@ ASKÖ Ruderverein Donau Linz", self.name),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn reset_pw(&self, db: &SqlitePool) {
|
||||
pub async fn reset_pw(&self, db: &SqlitePool, changed_by: &ManageUserUser) {
|
||||
sqlx::query!("UPDATE user SET pw = null where id = ?", self.id)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap(); //Okay, because we can only create a User of a valid id
|
||||
|
||||
// TODO: add responsible person
|
||||
ActivityBuilder::new(&format!("Passwort von User {self} wurde zurückgesetzt."))
|
||||
.relevant_for_user(self)
|
||||
ActivityBuilder::new(&format!(
|
||||
"{changed_by} hat das Passwort von User {self} zurückgesetzt."
|
||||
))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
}
|
||||
@ -552,10 +541,8 @@ ASKÖ Ruderverein Donau Linz", self.name),
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap(); //Okay, because we can only create a User of a valid id
|
||||
ActivityBuilder::new(&format!(
|
||||
"Passwort von User {self} wurde erfolgreich geändert."
|
||||
))
|
||||
.relevant_for_user(self)
|
||||
ActivityBuilder::new(&format!("{self} hat sein Passwort geändert."))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
}
|
||||
@ -577,10 +564,6 @@ ASKÖ Ruderverein Donau Linz", self.name),
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap(); //Okay, because we can only create a User of a valid id
|
||||
ActivityBuilder::new(&format!("User {self} hat sich eingeloggt."))
|
||||
.relevant_for_user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
}
|
||||
|
||||
pub async fn delete(&self, db: &SqlitePool, deleted_by: &ManageUserUser) {
|
||||
@ -589,7 +572,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;
|
||||
}
|
||||
@ -684,7 +667,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;
|
||||
}
|
||||
@ -702,7 +685,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;
|
||||
}
|
||||
@ -727,7 +710,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;
|
||||
|
||||
@ -749,7 +732,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;
|
||||
|
||||
@ -924,7 +907,7 @@ impl UserWithMembershipPdf {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::testdb;
|
||||
use crate::{model::user::ManageUserUser, testdb};
|
||||
|
||||
use super::User;
|
||||
use sqlx::SqlitePool;
|
||||
@ -999,8 +982,9 @@ mod test {
|
||||
fn reset() {
|
||||
let pool = testdb!();
|
||||
let user = User::find_by_id(&pool, 1).await.unwrap();
|
||||
let changed_by = ManageUserUser::new(&pool, &user).await.unwrap();
|
||||
|
||||
user.reset_pw(&pool).await;
|
||||
user.reset_pw(&pool, &changed_by).await;
|
||||
|
||||
let user = User::find_by_id(&pool, 1).await.unwrap();
|
||||
assert_eq!(user.pw, None);
|
||||
|
@ -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,21 +86,25 @@ 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.
|
||||
|
||||
Damit du dich noch mehr verbunden fühlst (:-)), haben wir im Bootshaus ein WLAN für Vereinsmitglieder 'ASKÖ Ruderverein Donau Linz' eingerichtet. Das Passwort dafür lautet 'donau1921' (ohne Anführungszeichen). Bitte gib das Passwort an keine vereinsfremden Personen weiter.
|
||||
|
||||
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;
|
||||
|
||||
|
@ -75,9 +75,9 @@ impl ScheckbuchUser {
|
||||
Notification::create_for_steering_people(
|
||||
db,
|
||||
&format!(
|
||||
"Liebe Steuerberechtigte, {} hatte ein Scheckbuch und ist nun seit {} es ein neues reguläres Mitglied. 🎉",
|
||||
"Liebe Steuerberechtigte, {} hatte ein Scheckbuch und ist nun seit {} ein neues reguläres Mitglied. 🎉",
|
||||
self.name,
|
||||
self.member_since_date.clone().unwrap()
|
||||
member_since
|
||||
),
|
||||
"Neues Vereinsmitglied",
|
||||
None,
|
||||
@ -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;
|
||||
|
||||
@ -133,9 +133,9 @@ impl ScheckbuchUser {
|
||||
db,
|
||||
&vorstand,
|
||||
&format!(
|
||||
"Lieber Vorstand, {} hatte ein Scheckbuch und ist nun seit {} es ein neues unterstützendes Mitglied.",
|
||||
"Lieber Vorstand, {} hatte ein Scheckbuch und ist nun seit {} ein neues unterstützendes Mitglied.",
|
||||
self.name,
|
||||
self.member_since_date.clone().unwrap()
|
||||
member_since
|
||||
),
|
||||
"Neues unterstützendes Vereinsmitglied",
|
||||
None,
|
||||
@ -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;
|
||||
|
||||
@ -187,9 +187,9 @@ impl ScheckbuchUser {
|
||||
db,
|
||||
&vorstand,
|
||||
&format!(
|
||||
"Lieber Vorstand, {} hatte ein Scheckbuch und ist nun seit {} es ein neues förderndes Mitglied.",
|
||||
"Lieber Vorstand, {} hatte ein Scheckbuch und ist nun seit {} ein neues förderndes Mitglied.",
|
||||
self.name,
|
||||
self.member_since_date.clone().unwrap()
|
||||
member_since
|
||||
),
|
||||
"Neues förderndes Vereinsmitglied",
|
||||
None,
|
||||
@ -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;
|
||||
|
||||
|
@ -65,20 +65,32 @@ impl SchnupperantUser {
|
||||
.await?;
|
||||
|
||||
// Change roles
|
||||
let regular = Role::find_by_name(db, "Donau Linz").await.unwrap();
|
||||
let paid = Role::find_by_name(db, "paid").await.unwrap();
|
||||
if self.user.remove_role(db, changed_by, &paid).await.is_err() {
|
||||
self.remove_membership_pdf(db, changed_by).await;
|
||||
return Err("Kann noch kein normales Mitglied werden, da die Schnupperkurs-Gebühr noch nicht bezahlt wurde.".into());
|
||||
}
|
||||
let scheckbook = Role::find_by_name(db, "schnupperant").await.unwrap();
|
||||
self.user.remove_role(db, changed_by, &scheckbook).await?;
|
||||
|
||||
let regular = Role::find_by_name(db, "Donau Linz").await.unwrap();
|
||||
self.user.add_role(db, changed_by, ®ular).await?;
|
||||
|
||||
let participated_schnupperkurs = Role::find_by_name(db, "participated_schnupperkurs")
|
||||
.await
|
||||
.unwrap();
|
||||
self.user
|
||||
.add_role(db, changed_by, &participated_schnupperkurs)
|
||||
.await?;
|
||||
|
||||
// Notify
|
||||
let regular = RegularUser::new(db, &self.user).await.unwrap();
|
||||
regular.send_welcome_mail_to_user(db, smtp_pw).await?;
|
||||
Notification::create_for_steering_people(
|
||||
db,
|
||||
&format!(
|
||||
"Liebe Steuerberechtigte, {} nahm an unserem Schnupperkurs teil und ist nun seit {} ein neues reguläres Mitglied. 🎉",
|
||||
self.name,
|
||||
self.member_since_date.clone().unwrap()
|
||||
"Liebe Steuerberechtigte, {} nahm an unserem Schnupperkurs teil und ist nun seit {member_since} ein neues reguläres Mitglied. 🎉",
|
||||
self.name
|
||||
),
|
||||
"Neues Vereinsmitglied",
|
||||
None,
|
||||
@ -89,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;
|
||||
|
||||
@ -130,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;
|
||||
|
||||
@ -172,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;
|
||||
|
||||
@ -203,6 +215,11 @@ impl SchnupperantUser {
|
||||
.await?;
|
||||
|
||||
// Change roles
|
||||
let paid = Role::find_by_name(db, "paid").await.unwrap();
|
||||
if self.user.remove_role(db, changed_by, &paid).await.is_err() {
|
||||
self.remove_membership_pdf(db, changed_by).await;
|
||||
return Err("Kann noch kein normales Mitglied werden, da die Schnupperkurs-Gebühr noch nicht bezahlt wurde.".into());
|
||||
}
|
||||
let unterstuetzend = Role::find_by_name(db, "Unterstützend").await.unwrap();
|
||||
let scheckbook = Role::find_by_name(db, "schnupperant").await.unwrap();
|
||||
self.user.remove_role(db, changed_by, &scheckbook).await?;
|
||||
@ -236,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;
|
||||
|
||||
@ -267,6 +284,11 @@ impl SchnupperantUser {
|
||||
.await?;
|
||||
|
||||
// Change roles
|
||||
let paid = Role::find_by_name(db, "paid").await.unwrap();
|
||||
if self.user.remove_role(db, changed_by, &paid).await.is_err() {
|
||||
self.remove_membership_pdf(db, changed_by).await;
|
||||
return Err("Kann noch kein normales Mitglied werden, da die Schnupperkurs-Gebühr noch nicht bezahlt wurde.".into());
|
||||
}
|
||||
let unterstuetzend = Role::find_by_name(db, "Förderndes Mitglied").await.unwrap();
|
||||
let scheckbook = Role::find_by_name(db, "schnupperant").await.unwrap();
|
||||
self.user.remove_role(db, changed_by, &scheckbook).await?;
|
||||
@ -298,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;
|
||||
|
||||
@ -307,13 +329,13 @@ impl SchnupperantUser {
|
||||
|
||||
// TODO: make private
|
||||
pub(crate) async fn notify(&self, db: &SqlitePool, smtp_pw: &str) -> Result<(), String> {
|
||||
self.notify_coxes_about_new_scheckbuch(db).await;
|
||||
self.notify_coxes_about_new_schnupperant(db).await;
|
||||
self.send_welcome_mail_to_user(db, smtp_pw).await?;
|
||||
|
||||
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;
|
||||
|
||||
@ -335,19 +357,27 @@ impl SchnupperantUser {
|
||||
mail,
|
||||
"ASKÖ Ruderverein Donau Linz | Anmeldung Schnupperkurs",
|
||||
format!(
|
||||
"Hallo {0},
|
||||
"Hallo {0},
|
||||
|
||||
es freut uns sehr, dich bei unserem Schnupperkurs willkommen heißen zu dürfen. Detaillierte Informationen folgen noch, ich werde sie dir ein paar Tage vor dem Termin zusenden.
|
||||
es freut uns sehr, dich bei unserem Schnupperkurs willkommen heißen zu dürfen.
|
||||
|
||||
Bitte überweise die {1} € auf unser Bankkonto (IBAN: AT58 2032 0321 0072 9256) und gib beim Verwendungszweck 'Schnupperkurs {0}' an.
|
||||
|
||||
Detaillierte Informationen folgen noch, du wirst sie ein paar Tage vor dem Termin bekommen (wenn das Wetter/Wasserstand/... abschätzbar ist).
|
||||
|
||||
Riemen- & Dollenbruch,
|
||||
ASKÖ Ruderverein Donau Linz", self.name),
|
||||
ASKÖ Ruderverein Donau Linz",
|
||||
self.name,
|
||||
self.fee(db).await.unwrap().sum_in_cents/100
|
||||
),
|
||||
smtp_pw,
|
||||
).await?;
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn notify_coxes_about_new_scheckbuch(&self, db: &SqlitePool) {
|
||||
async fn notify_coxes_about_new_schnupperant(&self, db: &SqlitePool) {
|
||||
if let Some(role) = Role::find_by_name(db, "schnupper-betreuer").await {
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
@ -393,7 +423,7 @@ ASKÖ Ruderverein Donau Linz", self.name),
|
||||
ActivityBuilder::new(&format!(
|
||||
"{created_by} hat {user} zur fixen Schnupperkurs-Anmeldung hinzugefügt."
|
||||
))
|
||||
.relevant_for_user(&user)
|
||||
.user(&user)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -9,8 +9,10 @@ use serde::Serialize;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::{
|
||||
planned::{
|
||||
event::{self, Event},
|
||||
tripdetails::{TripDetails, TripDetailsToAdd},
|
||||
},
|
||||
user::EventUser,
|
||||
};
|
||||
|
||||
|
@ -3,10 +3,7 @@ use rocket::{FromForm, Route, State, form::Form, get, post, routes};
|
||||
use rocket_dyn_templates::{Template, context};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::{
|
||||
model::{log::Log, role::Role, user::AdminUser},
|
||||
tera::Config,
|
||||
};
|
||||
use crate::model::{activity::Activity, role::Role, user::AdminUser};
|
||||
|
||||
pub mod boat;
|
||||
pub mod event;
|
||||
@ -16,18 +13,9 @@ pub mod role;
|
||||
pub mod schnupper;
|
||||
pub mod user;
|
||||
|
||||
#[get("/rss?<key>")]
|
||||
async fn rss(db: &State<SqlitePool>, key: &str, config: &State<Config>) -> String {
|
||||
if key.eq(&config.rss_key) {
|
||||
Log::generate_feed(db).await
|
||||
} else {
|
||||
"Not allowed".into()
|
||||
}
|
||||
}
|
||||
|
||||
#[get("/rss", rank = 2)]
|
||||
async fn show_rss(db: &State<SqlitePool>, _admin: AdminUser) -> String {
|
||||
Log::show(db).await
|
||||
async fn show_activities(db: &State<SqlitePool>, _admin: AdminUser) -> String {
|
||||
Activity::show(db).await
|
||||
}
|
||||
|
||||
#[get("/list")]
|
||||
@ -83,6 +71,6 @@ pub fn routes() -> Vec<Route> {
|
||||
ret.append(&mut mail::routes());
|
||||
ret.append(&mut event::routes());
|
||||
ret.append(&mut role::routes());
|
||||
ret.append(&mut routes![rss, show_rss, show_list, list]);
|
||||
ret.append(&mut routes![show_activities, show_list, list]);
|
||||
ret
|
||||
}
|
||||
|
@ -3,13 +3,14 @@ use crate::model::{
|
||||
user::{AdminUser, UserWithDetails, VorstandUser},
|
||||
};
|
||||
use rocket::{
|
||||
FromForm, Route, State,
|
||||
form::Form,
|
||||
get, post,
|
||||
request::FlashMessage,
|
||||
response::{Flash, Redirect},
|
||||
routes, FromForm, Route, State,
|
||||
routes,
|
||||
};
|
||||
use rocket_dyn_templates::{tera::Context, Template};
|
||||
use rocket_dyn_templates::{Template, tera::Context};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[get("/role")]
|
||||
|
@ -1,17 +1,17 @@
|
||||
use crate::{
|
||||
model::{
|
||||
activity::Activity,
|
||||
activity::{Activity, ActivityWithDetails},
|
||||
family::Family,
|
||||
log::Log,
|
||||
logbook::Logbook,
|
||||
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,6 +19,7 @@ use crate::{
|
||||
use chrono::NaiveDate;
|
||||
use futures::future::join_all;
|
||||
use rocket::{
|
||||
FromForm, Request, Route, State,
|
||||
form::Form,
|
||||
fs::TempFile,
|
||||
get,
|
||||
@ -26,9 +27,9 @@ use rocket::{
|
||||
post,
|
||||
request::{FlashMessage, FromRequest, Outcome},
|
||||
response::{Flash, Redirect},
|
||||
routes, FromForm, Request, Route, State,
|
||||
routes,
|
||||
};
|
||||
use rocket_dyn_templates::{tera::Context, Template};
|
||||
use rocket_dyn_templates::{Template, tera::Context};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
// Custom request guard to extract the Referer header
|
||||
@ -135,13 +136,17 @@ async fn view(
|
||||
if user.name == "Externe Steuerperson" {
|
||||
return Err(Flash::error(
|
||||
Redirect::to("/admin/user"),
|
||||
"Diese besondere Person kannst du dir leider nicht anschauen, mein lieber neugieriger Ruderant!"
|
||||
"Diese besondere Person kannst du dir leider nicht anschauen, mein lieber neugieriger Ruderant!",
|
||||
));
|
||||
}
|
||||
|
||||
let member = Member::from(db, user.clone()).await;
|
||||
let fee = user.fee(db).await;
|
||||
let activities = Activity::for_user(db, &user).await;
|
||||
let activities: Vec<ActivityWithDetails> = Activity::for_user(db, &user)
|
||||
.await
|
||||
.into_iter()
|
||||
.map(Into::into)
|
||||
.collect();
|
||||
let financial = Role::all_cluster(db, "financial").await;
|
||||
let user_financial = user.financial(db).await;
|
||||
let skill = Role::all_cluster(db, "skill").await;
|
||||
@ -276,7 +281,7 @@ async fn resetpw(db: &State<SqlitePool>, admin: ManageUserUser, user: i32) -> Fl
|
||||
format!("{} has resetted the pw for {}", admin.user.name, user.name),
|
||||
)
|
||||
.await;
|
||||
user.reset_pw(db).await;
|
||||
user.reset_pw(db, &admin).await;
|
||||
Flash::success(
|
||||
Redirect::to("/admin/user"),
|
||||
format!("Passwort von {} zurückgesetzt", user.name),
|
||||
@ -349,7 +354,7 @@ async fn add_note(
|
||||
);
|
||||
};
|
||||
|
||||
match user.add_note(db, &admin, &user, &data.note).await {
|
||||
match user.add_note(db, &admin, &data.note).await {
|
||||
Ok(_) => Flash::success(
|
||||
Redirect::to(format!("/admin/user/{}", user.id)),
|
||||
"Notiz hinzugefügt",
|
||||
|
@ -14,6 +14,7 @@ use rocket_dyn_templates::{Template, context, tera};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::{
|
||||
activity::{ActivityBuilder, ReasonAuth},
|
||||
log::Log,
|
||||
user::{LoginError, User},
|
||||
};
|
||||
@ -82,13 +83,8 @@ async fn login(
|
||||
|
||||
cookies.add_private(Cookie::new("loggedin_user", format!("{}", user.id)));
|
||||
|
||||
Log::create(
|
||||
db,
|
||||
format!(
|
||||
"Succ login of {} with this useragent: {}",
|
||||
login.name, agent.0
|
||||
),
|
||||
)
|
||||
ActivityBuilder::from(ReasonAuth::SuccLogin(&user, agent.0))
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
// Check for redirect_url cookie and redirect accordingly
|
||||
|
@ -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() {
|
||||
|
@ -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,
|
||||
@ -108,26 +108,50 @@ async fn index(
|
||||
}
|
||||
|
||||
#[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")]
|
||||
@ -370,27 +394,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 +522,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!",
|
||||
|
@ -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) {
|
||||
|
@ -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("/")]
|
||||
|
@ -3,14 +3,20 @@
|
||||
{% extends "base" %}
|
||||
{% block content %}
|
||||
<div class="max-w-screen-lg w-full dark:text-white">
|
||||
<h1 class="h1">Rolle</h1>
|
||||
<div class="grid ">
|
||||
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"
|
||||
role="alert">
|
||||
<h2 class="h2">Rolle</h2>
|
||||
<h1 class="h1">Rollen</h1>
|
||||
<div class="search-wrapper">
|
||||
<label for="name" class="sr-only">Suche</label>
|
||||
<input type="search"
|
||||
name="name"
|
||||
id="filter-js"
|
||||
class="search-bar"
|
||||
placeholder="Suchen nach Namen...">
|
||||
</div>
|
||||
<div id="filter-result-js" class="search-result"></div>
|
||||
<div class="border-r border-l border-gray-200 dark:border-primary-600">
|
||||
{% for role in roles %}
|
||||
<div data-filterable="true"
|
||||
data-filter="{{ role.name }}"
|
||||
data-filter="{{ role.name }} {{ role.formatted_name }}"
|
||||
class="w-full border-t">
|
||||
<form action="/admin/role/{{ role.id }}"
|
||||
data-filterable="true"
|
||||
@ -23,9 +29,11 @@
|
||||
<br />
|
||||
</div>
|
||||
<div class="grid md:grid-cols-3 gap-3">
|
||||
{{ macros::input(label='Formatierter Name', name='formatted_name', type='text', value=role.formatted_name) }}
|
||||
{{ macros::input(label='Name (formatiert)', name='formatted_name', type='text', value=role.formatted_name) }}
|
||||
{{ macros::input(label='Beschreibung', name='desc', type='text', value=role.desc) }}
|
||||
<input value="Ändern" type="submit" class="w-28 btn btn-primary" />
|
||||
<div class="flex items-end">
|
||||
<input value="Ändern" type="submit" class="w-full btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -33,5 +41,4 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
@ -8,19 +8,16 @@
|
||||
<summary class="px-3 cursor-pointer text-md font-bold text-primary-950 dark:text-white">
|
||||
Neue Person hinzufügen
|
||||
</summary>
|
||||
|
||||
<div class="grid sm:grid-cols-3 gap-3 mt-3">
|
||||
<button type="button"
|
||||
onclick="document.getElementById('add-clubuser').showModal()"
|
||||
class="btn btn-primary">Vereinsmitglied</button>
|
||||
class="btn btn-primary">🥳 Vereinsmitglied</button>
|
||||
<button type="button"
|
||||
onclick="document.getElementById('add-scheckbuch').showModal()"
|
||||
class="btn btn-dark">Scheckbuch</button>
|
||||
class="btn btn-dark">🧑🏫 Scheckbuch</button>
|
||||
<button type="button"
|
||||
onclick="document.getElementById('add-schnupperkurs').showModal()"
|
||||
class="btn btn-dark">Schnupperkurs</button>
|
||||
|
||||
|
||||
class="btn btn-dark">👨🎓 Schnupperkurs</button>
|
||||
</div>
|
||||
<dialog id="add-clubuser"
|
||||
class="max-w-screen-sm w-full dark:bg-primary-900 dark:text-white rounded-md"
|
||||
@ -67,7 +64,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<dialog id="add-scheckbuch"
|
||||
class="max-w-screen-sm w-full dark:bg-primary-900 dark:text-white rounded-md"
|
||||
onclick="document.getElementById('add-scheckbuch').close()">
|
||||
@ -99,7 +95,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<dialog id="add-schnupperkurs"
|
||||
class="max-w-screen-sm w-full dark:bg-primary-900 dark:text-white rounded-md"
|
||||
onclick="document.getElementById('add-schnupperkurs').close()">
|
||||
@ -122,7 +117,6 @@
|
||||
enctype="multipart/form-data"
|
||||
class="grid gap-3">
|
||||
<h2 class="h3 mb-3">Neuer Schnupperant</h2>
|
||||
|
||||
<div>
|
||||
<label for="schnupper_type" class="text-sm text-gray-600 dark:text-gray-100">Typ</label>
|
||||
<select name="schnupper_type" id="schnupper_type" class="input rounded-md ">
|
||||
|
@ -4,7 +4,9 @@
|
||||
{% block content %}
|
||||
<div class="max-w-screen-lg w-full">
|
||||
{% if "admin" in loggedin_user.roles or "Vorstand" in loggedin_user.roles %}
|
||||
<div class="mb-5 lg:mb-0">
|
||||
<a href="/admin/user" class="link link-primary link-no-underline">← Userverwaltung</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<h1 class="h1">{{ user.name }}</h1>
|
||||
<div class="grid sm:grid-cols-2 gap-8 my-8">
|
||||
@ -119,12 +121,12 @@
|
||||
</div>
|
||||
{% if allowed_to_edit %}
|
||||
<div class="py-3">
|
||||
<div class="mt-3 text-right">
|
||||
<div class="text-right">
|
||||
<button type="button"
|
||||
onclick="document.getElementById('change-member-type').showModal()"
|
||||
class="btn btn-dark">Mitgliedsstatus ändern</button>
|
||||
<a href="/admin/user/{{ user.id }}/delete"
|
||||
class="btn btn-alert"
|
||||
class="btn btn-alert mt-3"
|
||||
onclick="return confirm('Ist {{ user.name }} wirklich aus dem Verein ausgetreten?');">
|
||||
{% include "includes/delete-icon" %}
|
||||
Mitglied ist ausgetreten
|
||||
@ -385,9 +387,11 @@
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if "paid" in user.roles %}
|
||||
✅ {% for key, value in member %}
|
||||
✅
|
||||
{% for key, value in member %}
|
||||
{% if loop.first %}{{ key }}{% endif %}
|
||||
{% endfor %} hat schon bezahlt
|
||||
{% endfor %}
|
||||
hat schon bezahlt
|
||||
{% else %}
|
||||
❌
|
||||
{% for key, value in member %}
|
||||
@ -402,11 +406,15 @@
|
||||
{% endif %}
|
||||
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow">
|
||||
<h2 class="h2">Aktivitäten</h2>
|
||||
<div class="mx-3 divide-y divide-gray-200 dark:divide-primary-600">
|
||||
<div class="mx-3 max-h-60 overflow-y-scroll">
|
||||
<div class="py-3">
|
||||
<ul class="list-disc ms-4">
|
||||
{% for activity in activities %}
|
||||
<li>{{ activity.created_at | date(format="%d. %m. %Y") }}: {{ activity.text }}</li>
|
||||
<li>
|
||||
<strong>{{ activity.created_at | date(format="%d. %m. %Y") }}:</strong> <small>{{ activity.text }}
|
||||
{% if activity.keep_until_days %}(⏳ {{ activity.keep_until_days }} Tage){% endif %}
|
||||
</small>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>Noch keine Aktivität... Stay tuned 😆</li>
|
||||
{% endfor %}
|
||||
|
@ -202,9 +202,7 @@
|
||||
onclick="document.getElementById('change-{{ log.id }}').showModal()"
|
||||
class="link link-black font-bold">{{ log.boat.name }}</a>
|
||||
{% else %}
|
||||
<strong class="text-black dark:text-white">
|
||||
{{ log.boat.name }}
|
||||
</strong>
|
||||
<strong class="text-black dark:text-white">{{ log.boat.name }}</strong>
|
||||
{% endif %}
|
||||
<small class="text-gray-600 dark:text-gray-100">({{ log.shipmaster_user.name -}}
|
||||
{% if log.shipmaster_only_steering %}
|
||||
@ -276,7 +274,7 @@
|
||||
</svg>
|
||||
</button>
|
||||
<div class="mt-8">
|
||||
<h2 class="h3">Eintrag '{{ log.boat.name }}' ändern </h2>
|
||||
<h2 class="h3">Eintrag '{{ log.boat.name }}' ändern</h2>
|
||||
<p class="text-center mb-3">{{ log.id }}</p>
|
||||
<form action="/log/update" method="post" class="grid gap-3">
|
||||
<input type="hidden" name="id" value="{{ log.id }}" />
|
||||
@ -286,8 +284,14 @@
|
||||
name="steering_person"
|
||||
value="{{ log.steering_person }}" />
|
||||
{{ macros::checkbox(label='Handgesteuert', name='shipmaster_only_steering', id=log.shipmaster_only_steering,checked=log.shipmaster_only_steering) }}
|
||||
<input type="datetime-local" class="input rounded-md" name="departure" value="{{ log.departure }}" />
|
||||
<input type="datetime-local" class="input rounded-md" name="arrival" value="{{ log.arrival }}" />
|
||||
<input type="datetime-local"
|
||||
class="input rounded-md"
|
||||
name="departure"
|
||||
value="{{ log.departure }}" />
|
||||
<input type="datetime-local"
|
||||
class="input rounded-md"
|
||||
name="arrival"
|
||||
value="{{ log.arrival }}" />
|
||||
<input type="hidden" name="destination" value="{{ log.destination }}" />
|
||||
<input type="hidden" name="distance_in_km" value="{{ log.distance_in_km }}" />
|
||||
<input type="hidden" name="comments" value="{{ log.comments }}" />
|
||||
|
@ -212,8 +212,9 @@
|
||||
</h3>
|
||||
</summary>
|
||||
<div class="mt-3">
|
||||
{% if price.level == "DONE" %}
|
||||
{% if achievements.curr_equatorprice_name == "Diamant" %}
|
||||
Gratuliere, du hast alles in deinem Rudererleben erreicht, was es (beim Äquatorpreis) zu erreichen gibt.
|
||||
Insgesamt bist du schon stolze {{ price.rowed_km }} km gerudert.
|
||||
{% else %}
|
||||
<label for="equatorprice" class="label">{{ price.desc }} ({{ price.rowed_km }} / {{ price.required_km }} km)</label>
|
||||
<progress id="equatorprice"
|
||||
@ -417,6 +418,9 @@
|
||||
<li class="py-1">
|
||||
<a href="/admin/boat" class="block w-100 py-2 hover:text-primary-600">Boote</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="https://cloud.rudernlinz.at/login?user={{ loggedin_user.name }}" target="_blank" class="block w-100 py-2 hover:text-primary-600">Nextcloud ↗️</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
@ -26,7 +26,7 @@
|
||||
{% for log in logs %}
|
||||
{% set_global allowed_to_edit = false %}
|
||||
{% if loggedin_user %}
|
||||
{% if "Vorstand" in loggedin_user.roles %}
|
||||
{% if "Vorstand" in loggedin_user.roles or "admin" in loggedin_user.roles %}
|
||||
{% set_global allowed_to_edit = true %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
@ -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">
|
||||
|
Reference in New Issue
Block a user