forked from Ruderverein-Donau-Linz/rowt
Compare commits
198 Commits
Author | SHA1 | Date | |
---|---|---|---|
ac24be6c5e | |||
138c0598e6 | |||
13976b02d8 | |||
a42e0b3ed3 | |||
3aef4fa971 | |||
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 | |||
![]() |
af2e7cb557 | ||
![]() |
81b99ef414 | ||
17513bbc38 | |||
c1cecf3b20 | |||
8e40e563c6 | |||
![]() |
bb78441cc4 | ||
![]() |
abcf46281b | ||
c460494be8 | |||
7083d27644 | |||
e5560ba536 | |||
![]() |
b7094bff06 | ||
![]() |
6b8b4ba1d2 | ||
03f76b1ae5 | |||
1864ea260c | |||
![]() |
35a5a55140 | ||
9a4dcc0b9d | |||
8277ef6af8 | |||
43074b3bd7 | |||
933e407c64 | |||
d9e86bf43b | |||
67d5df9c18 | |||
ebbb4fe3da | |||
9178476013 | |||
e853381bd7 | |||
3ffc44a5a2 | |||
8777ccb341 | |||
6362fed909 | |||
bd2686fa9c | |||
905178e60d | |||
cd52e76b61 | |||
151c97aabc | |||
495ee666cd | |||
e360c4f06b | |||
d50501b362 | |||
e6895c8cf1 | |||
![]() |
7bd863ddf1 | ||
afc32cc41e | |||
![]() |
9dfcb4e2c4 | ||
![]() |
149b6afbf5 | ||
f9a53a703b | |||
c8be0c2c22 | |||
![]() |
6c8667973d | ||
![]() |
07f7dbca12 | ||
3f29400831 | |||
46981c3311 | |||
![]() |
b08fcdc05b | ||
![]() |
a60606bbe4 | ||
![]() |
540031cab4 | ||
![]() |
a93c420630 | ||
8dc55a7aad | |||
![]() |
5b78afff63 | ||
25c3a28c7d | |||
2bb42c3f6a | |||
![]() |
d7dec5da29 | ||
![]() |
ffe1745b65 | ||
5296b6a6c1 | |||
f374016207 | |||
6d329eb980 | |||
cfd3c6200f | |||
![]() |
4d95282e58 | ||
![]() |
540c122248 | ||
9aab07422d | |||
49e657ab54 | |||
![]() |
c47b1988b2 | ||
a73bbf059f | |||
1f17a10133 | |||
73c79fb008 | |||
c2b57583cf | |||
25bbaca0d3 | |||
d2000f4699 | |||
26038eabe4 | |||
c4ed766c4d | |||
68cf563964 | |||
b2e07653e6 | |||
19887e133d | |||
d2914f9287 | |||
c8d5c633d7 | |||
90087843ad | |||
5e588f209f | |||
c99c83d9fb | |||
57acd92e7c | |||
ef7beccdf2 | |||
34850321b7 | |||
b0168b798c | |||
c136c60e62 | |||
7604678d4a | |||
876451fc02 | |||
80a70fb812 | |||
a5e90ea014 | |||
8059e5b8fc | |||
f0f3909239 | |||
a484785027 | |||
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: true
|
||||
|
||||
- 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
|
210
Cargo.lock
generated
210
Cargo.lock
generated
@ -221,9 +221,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.74"
|
||||
version = "0.3.75"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
|
||||
checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cfg-if",
|
||||
@ -303,9 +303,9 @@ checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.22.0"
|
||||
version = "1.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540"
|
||||
checksum = "9134a6ef01ce4b366b50689c94f82c14bc72bc5d0386829828a2e2752ef7958c"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
@ -321,9 +321,9 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.19"
|
||||
version = "1.2.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362"
|
||||
checksum = "8691782945451c1c383942c4874dbe63814f61cb57ef773cda2972682b7bb3c0"
|
||||
dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
@ -336,9 +336,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.40"
|
||||
version = "0.4.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c"
|
||||
checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d"
|
||||
dependencies = [
|
||||
"android-tzdata",
|
||||
"iana-time-zone",
|
||||
@ -615,9 +615,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "der"
|
||||
version = "0.7.9"
|
||||
version = "0.7.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0"
|
||||
checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb"
|
||||
dependencies = [
|
||||
"const-oid",
|
||||
"pem-rfc7468",
|
||||
@ -635,9 +635,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "deunicode"
|
||||
version = "1.6.1"
|
||||
version = "1.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc55fe0d1f6c107595572ec8b107c0999bb1a2e0b75e37429a4fb0d6474a0e7d"
|
||||
checksum = "abd57806937c9cc163efc8ea3910e00a62e2aeb0b8119f1793a978088f8f6b04"
|
||||
|
||||
[[package]]
|
||||
name = "devise"
|
||||
@ -1028,9 +1028,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.15"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
||||
checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
@ -1126,9 +1126,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.2"
|
||||
version = "0.15.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
|
||||
checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3"
|
||||
dependencies = [
|
||||
"allocator-api2",
|
||||
"equivalent",
|
||||
@ -1141,7 +1141,7 @@ version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
|
||||
dependencies = [
|
||||
"hashbrown 0.15.2",
|
||||
"hashbrown 0.15.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1158,9 +1158,9 @@ checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fbd780fe5cc30f81464441920d82ac8740e2e46b29a6fad543ddd075229ce37e"
|
||||
checksum = "f154ce46856750ed433c8649605bf7ed2de3bc35fd9d2a9f30cddd873c80cb08"
|
||||
|
||||
[[package]]
|
||||
name = "hex"
|
||||
@ -1476,7 +1476,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown 0.15.2",
|
||||
"hashbrown 0.15.3",
|
||||
"serde",
|
||||
]
|
||||
|
||||
@ -1521,7 +1521,7 @@ version = "0.4.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9"
|
||||
dependencies = [
|
||||
"hermit-abi 0.5.0",
|
||||
"hermit-abi 0.5.1",
|
||||
"libc",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
@ -1549,9 +1549,9 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||
|
||||
[[package]]
|
||||
name = "jiff"
|
||||
version = "0.2.8"
|
||||
version = "0.2.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5ad87c89110f55e4cd4dc2893a9790820206729eaf221555f742d540b0724a0"
|
||||
checksum = "f02000660d30638906021176af16b17498bd0d12813dbfe7b276d8bc7f3c0806"
|
||||
dependencies = [
|
||||
"jiff-static",
|
||||
"log",
|
||||
@ -1562,9 +1562,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "jiff-static"
|
||||
version = "0.2.8"
|
||||
version = "0.2.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d076d5b64a7e2fe6f0743f02c43ca4a6725c0f904203bfe276a5b3e793103605"
|
||||
checksum = "f3c30758ddd7188629c6713fc45d1188af4f44c90582311d0c8d8c9907f60c48"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -1594,9 +1594,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kqueue"
|
||||
version = "1.0.8"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c"
|
||||
checksum = "eac30106d7dce88daf4a3fcb4879ea939476d5074a9b7ddd0fb97fa4bed5596a"
|
||||
dependencies = [
|
||||
"kqueue-sys",
|
||||
"libc",
|
||||
@ -1654,9 +1654,9 @@ checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
|
||||
|
||||
[[package]]
|
||||
name = "libm"
|
||||
version = "0.2.11"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
|
||||
checksum = "a25169bd5913a4b437588a7e3d127cd6e90127b60e0ffbd834a38f1599e016b8"
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
@ -2002,9 +2002,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.107"
|
||||
version = "0.9.108"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8288979acd84749c744a9014b4382d42b8f7b2592847b5afb2ed29e5d16ede07"
|
||||
checksum = "e145e1651e858e820e4860f7b9c5e169bc1d8ce1c86043be79fa7b7634821847"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
@ -2267,14 +2267,14 @@ version = "0.2.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
|
||||
dependencies = [
|
||||
"zerocopy 0.8.24",
|
||||
"zerocopy 0.8.25",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.94"
|
||||
version = "1.0.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
|
||||
checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
@ -2294,9 +2294,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "psm"
|
||||
version = "0.1.25"
|
||||
version = "0.1.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f58e5423e24c18cc840e1c98370b3993c6649cd1678b4d24318bcf0a083cbe88"
|
||||
checksum = "6e944464ec8536cd1beb0bbfd96987eb5e3b72f2ecdafdc5c769a37f1fa2ae1f"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
@ -2355,14 +2355,14 @@ version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
dependencies = [
|
||||
"getrandom 0.2.15",
|
||||
"getrandom 0.2.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.11"
|
||||
version = "0.5.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2f103c6d277498fbceb16e84d317e2a400f160f46904d5f5410848c829511a3"
|
||||
checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af"
|
||||
dependencies = [
|
||||
"bitflags 2.9.0",
|
||||
]
|
||||
@ -2439,7 +2439,7 @@ checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"getrandom 0.2.15",
|
||||
"getrandom 0.2.16",
|
||||
"libc",
|
||||
"untrusted",
|
||||
"windows-sys 0.52.0",
|
||||
@ -2594,9 +2594,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "1.0.5"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf"
|
||||
checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266"
|
||||
dependencies = [
|
||||
"bitflags 2.9.0",
|
||||
"errno",
|
||||
@ -2607,9 +2607,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.23.26"
|
||||
version = "0.23.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df51b5869f3a441595eac5e8ff14d486ff285f7b8c0df8770e49c3b56351f0f0"
|
||||
checksum = "730944ca083c1c233a75c09f199e973ca499344a2b7ba9e755c457e86fb4a321"
|
||||
dependencies = [
|
||||
"log",
|
||||
"once_cell",
|
||||
@ -2637,9 +2637,9 @@ checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c"
|
||||
|
||||
[[package]]
|
||||
name = "rustls-webpki"
|
||||
version = "0.103.1"
|
||||
version = "0.103.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fef8b8769aaccf73098557a87cd1816b4f9c7c16811c9c77142aa695c16f2c03"
|
||||
checksum = "7149975849f1abb3832b246010ef62ccc80d3a76169517ada7188252b9cfb437"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"rustls-pki-types",
|
||||
@ -2777,9 +2777,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.10.8"
|
||||
version = "0.10.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
|
||||
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
@ -2803,9 +2803,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.2"
|
||||
version = "1.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
|
||||
checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
@ -2885,9 +2885,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sqlx"
|
||||
version = "0.8.4"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14e22987355fbf8cfb813a0cf8cd97b1b4ec834b94dbd759a9e8679d41fabe83"
|
||||
checksum = "f3c3a85280daca669cfd3bcb68a337882a8bc57ec882f72c5d13a430613a738e"
|
||||
dependencies = [
|
||||
"sqlx-core",
|
||||
"sqlx-macros",
|
||||
@ -2898,9 +2898,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sqlx-core"
|
||||
version = "0.8.4"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55c4720d7d4cd3d5b00f61d03751c685ad09c33ae8290c8a2c11335e0604300b"
|
||||
checksum = "f743f2a3cea30a58cd479013f75550e879009e3a02f616f18ca699335aa248c3"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"bytes",
|
||||
@ -2913,7 +2913,7 @@ dependencies = [
|
||||
"futures-intrusive",
|
||||
"futures-io",
|
||||
"futures-util",
|
||||
"hashbrown 0.15.2",
|
||||
"hashbrown 0.15.3",
|
||||
"hashlink",
|
||||
"indexmap",
|
||||
"log",
|
||||
@ -2930,14 +2930,14 @@ dependencies = [
|
||||
"tokio-stream",
|
||||
"tracing",
|
||||
"url",
|
||||
"webpki-roots",
|
||||
"webpki-roots 0.26.11",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlx-macros"
|
||||
version = "0.8.4"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "175147fcb75f353ac7675509bc58abb2cb291caf0fd24a3623b8f7e3eb0a754b"
|
||||
checksum = "7f4200e0fde19834956d4252347c12a083bdcb237d7a1a1446bffd8768417dce"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -2948,9 +2948,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sqlx-macros-core"
|
||||
version = "0.8.4"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cde983058e53bfa75998e1982086c5efe3c370f3250bf0357e344fa3352e32b"
|
||||
checksum = "882ceaa29cade31beca7129b6beeb05737f44f82dbe2a9806ecea5a7093d00b7"
|
||||
dependencies = [
|
||||
"dotenvy",
|
||||
"either",
|
||||
@ -2974,9 +2974,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sqlx-mysql"
|
||||
version = "0.8.4"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "847d2e5393a4f39e47e4f36cab419709bc2b83cbe4223c60e86e1471655be333"
|
||||
checksum = "0afdd3aa7a629683c2d750c2df343025545087081ab5942593a5288855b1b7a7"
|
||||
dependencies = [
|
||||
"atoi",
|
||||
"base64",
|
||||
@ -3017,9 +3017,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sqlx-postgres"
|
||||
version = "0.8.4"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc35947a541b9e0a2e3d85da444f1c4137c13040267141b208395a0d0ca4659f"
|
||||
checksum = "a0bedbe1bbb5e2615ef347a5e9d8cd7680fb63e77d9dafc0f29be15e53f1ebe6"
|
||||
dependencies = [
|
||||
"atoi",
|
||||
"base64",
|
||||
@ -3055,9 +3055,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sqlx-sqlite"
|
||||
version = "0.8.4"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c48291dac4e5ed32da0927a0b981788be65674aeb62666d19873ab4289febde"
|
||||
checksum = "c26083e9a520e8eb87a06b12347679b142dc2ea29e6e409f805644a7a979a5bc"
|
||||
dependencies = [
|
||||
"atoi",
|
||||
"chrono",
|
||||
@ -3095,9 +3095,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
|
||||
[[package]]
|
||||
name = "stacker"
|
||||
version = "0.1.20"
|
||||
version = "0.1.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "601f9201feb9b09c00266478bf459952b9ef9a6b94edb2f21eba14ab681a60a9"
|
||||
checksum = "cddb07e32ddb770749da91081d8d0ac3a16f1a569a18b20348cd371f5dead06b"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cfg-if",
|
||||
@ -3134,9 +3134,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.100"
|
||||
version = "2.0.101"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
|
||||
checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -3145,9 +3145,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "synstructure"
|
||||
version = "0.13.1"
|
||||
version = "0.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
|
||||
checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -3277,9 +3277,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.44.2"
|
||||
version = "1.45.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48"
|
||||
checksum = "2513ca694ef9ede0fb23fe71a4ee4107cb102b9dc1930f6d0fd77aae068ae165"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes",
|
||||
@ -3316,9 +3316,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tokio-util"
|
||||
version = "0.7.14"
|
||||
version = "0.7.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b9590b93e6fcc1739458317cccd391ad3955e2bde8913edf6f95f9e65a8f034"
|
||||
checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-core",
|
||||
@ -3329,9 +3329,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.20"
|
||||
version = "0.8.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148"
|
||||
checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
@ -3341,26 +3341,33 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.6.8"
|
||||
version = "0.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
|
||||
checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.24"
|
||||
version = "0.22.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474"
|
||||
checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"winnow 0.7.6",
|
||||
"toml_write",
|
||||
"winnow 0.7.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_write"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfb942dfe1d8e29a7ee7fcbde5bd2b9a25fb89aa70caea2eba3bee836ff41076"
|
||||
|
||||
[[package]]
|
||||
name = "tower-service"
|
||||
version = "0.3.3"
|
||||
@ -3567,9 +3574,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
|
||||
|
||||
[[package]]
|
||||
name = "ureq"
|
||||
version = "3.0.10"
|
||||
version = "3.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4b0351ca625c7b41a8e4f9bb6c5d9755f67f62c2187ebedecacd9974674b271d"
|
||||
checksum = "b7a3e9af6113ecd57b8c63d3cd76a385b2e3881365f1f489e54f49801d0c83ea"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"cookie_store",
|
||||
@ -3583,14 +3590,14 @@ dependencies = [
|
||||
"serde_json",
|
||||
"ureq-proto",
|
||||
"utf-8",
|
||||
"webpki-roots",
|
||||
"webpki-roots 0.26.11",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ureq-proto"
|
||||
version = "0.3.5"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae239d0a3341aebc94259414d1dc67cfce87d41cbebc816772c91b77902fafa4"
|
||||
checksum = "fadf18427d33828c311234884b7ba2afb57143e6e7e69fda7ee883b624661e36"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"http 1.3.1",
|
||||
@ -3766,9 +3773,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "webpki-roots"
|
||||
version = "0.26.8"
|
||||
version = "0.26.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2210b291f7ea53617fbafcc4939f10914214ec15aace5ba62293a668f322c5c9"
|
||||
checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9"
|
||||
dependencies = [
|
||||
"webpki-roots 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki-roots"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2853738d1cc4f2da3a225c18ec6c3721abb31961096e9dbf5ab35fa88b19cfdb"
|
||||
dependencies = [
|
||||
"rustls-pki-types",
|
||||
]
|
||||
@ -4041,9 +4057,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.7.6"
|
||||
version = "0.7.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "63d3fcd9bba44b03821e7d699eeee959f3126dcc4aa8e4ae18ec617c2a5cea10"
|
||||
checksum = "d9fb597c990f03753e08d3c29efbfcf2019a003b4bf4ba19225c158e1549f0f3"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
@ -4113,11 +4129,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.8.24"
|
||||
version = "0.8.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879"
|
||||
checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb"
|
||||
dependencies = [
|
||||
"zerocopy-derive 0.8.24",
|
||||
"zerocopy-derive 0.8.25",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -4133,9 +4149,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.8.24"
|
||||
version = "0.8.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be"
|
||||
checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -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]
|
||||
|
@ -24,6 +24,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
reloadPage();
|
||||
setCurrentdate(<HTMLInputElement>document.querySelector("#departure"));
|
||||
initDropdown();
|
||||
editReadOnlyField();
|
||||
});
|
||||
|
||||
function changeTheme() {
|
||||
@ -40,6 +41,30 @@ function changeTheme() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function editReadOnlyField() {
|
||||
const editBtns = document.querySelectorAll(
|
||||
'.edit-js'
|
||||
);
|
||||
if (editBtns) {
|
||||
Array.prototype.forEach.call(editBtns, (btn: HTMLButtonElement) => {
|
||||
btn.addEventListener("click", function () {
|
||||
let wrapper = btn.parentElement;
|
||||
let input = <HTMLInputElement> wrapper?.querySelector('input.input'),
|
||||
select = <HTMLSelectElement> wrapper?.querySelector('select.input'),
|
||||
attribute = 'readonly';
|
||||
|
||||
if(select) attribute = 'disabled';
|
||||
let element = input ? input : select;
|
||||
|
||||
element?.toggleAttribute(attribute);
|
||||
if(!element?.hasAttribute(attribute)) element?.focus();
|
||||
wrapper?.classList.toggle('editable');
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* init javascript
|
||||
* 1) detect native color scheme or use set theme in local storage
|
||||
|
@ -28,4 +28,8 @@
|
||||
&[aria-pressed='true'] {
|
||||
@apply outline outline-2 outline-offset-2 outline-primary-600 bg-primary-100 text-primary-950;
|
||||
}
|
||||
|
||||
&-hidden {
|
||||
@apply hidden;
|
||||
}
|
||||
}
|
||||
|
@ -4,4 +4,8 @@
|
||||
|
||||
.h2 {
|
||||
@apply font-bold uppercase tracking-wide text-center rounded-t-md text-primary-950 dark:text-white bg-gray-200 dark:bg-primary-950 bg-opacity-80 text-lg px-3 py-3;
|
||||
}
|
||||
|
||||
.h3 {
|
||||
@apply text-center text-xl uppercase tracking-wide font-bold text-primary-900 dark:text-white;
|
||||
}
|
@ -2,3 +2,12 @@
|
||||
border-top-left-radius: 0px !important;
|
||||
border-top-right-radius: 0px !important;
|
||||
}
|
||||
|
||||
.rounded-l-none-important {
|
||||
border-bottom-left-radius: 0px !important;
|
||||
border-top-left-radius: 0px !important;
|
||||
}
|
||||
|
||||
.rounded-none-important {
|
||||
border-radius: 0px !important;
|
||||
}
|
||||
|
@ -2,6 +2,26 @@
|
||||
@apply relative block w-full bg-white dark:bg-black border-0 py-1.5 px-2 text-gray-900 dark:text-white ring-1 ring-inset ring-gray-300 dark:ring-black placeholder:text-gray-400 focus:z-10 focus:ring-2 focus:ring-inset focus:ring-primary-600 sm:text-sm sm:leading-6;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
@apply flex;
|
||||
|
||||
input[readonly],
|
||||
select[disabled] {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
&.editable {
|
||||
input[type="reset"],
|
||||
input[type="submit"] {
|
||||
@apply block;
|
||||
}
|
||||
|
||||
button[type="button"] {
|
||||
@apply hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
select {
|
||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
|
||||
background-repeat: no-repeat;
|
||||
|
@ -10,4 +10,12 @@
|
||||
&-white {
|
||||
@apply text-white hover:text-primary-100 underline;
|
||||
}
|
||||
|
||||
&-black {
|
||||
@apply text-black hover:text-primary-950 dark:text-white hover:dark:text-primary-300 underline;
|
||||
}
|
||||
|
||||
&-no-underline {
|
||||
@apply no-underline;
|
||||
}
|
||||
}
|
||||
|
@ -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(() => {});
|
||||
});
|
||||
|
@ -28,7 +28,10 @@ CREATE TABLE IF NOT EXISTS "family" (
|
||||
CREATE TABLE IF NOT EXISTS "role" (
|
||||
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"name" text NOT NULL UNIQUE,
|
||||
"cluster" text
|
||||
"formatted_name" text,
|
||||
"desc" text,
|
||||
"cluster" text,
|
||||
"hide_in_lists" BOOLEAN NOT NULL DEFAULT false
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "user_role" (
|
||||
@ -222,6 +225,15 @@ CREATE TABLE IF NOT EXISTS "distance" (
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "activity" (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
text TEXT NOT NULL,
|
||||
relevant_for TEXT NOT NULL, -- e.g. user_id=123;trip_id=456
|
||||
keep_until DATETIME
|
||||
);
|
||||
|
||||
|
||||
CREATE TRIGGER IF NOT EXISTS prevent_multiple_roles_same_cluster
|
||||
BEFORE INSERT ON user_role
|
||||
BEGIN
|
||||
|
73
src/lib.rs
73
src/lib.rs
@ -1,5 +1,7 @@
|
||||
#![allow(clippy::blocks_in_conditions)]
|
||||
|
||||
use std::ops::Deref;
|
||||
|
||||
pub mod model;
|
||||
|
||||
#[cfg(feature = "rowing-tera")]
|
||||
@ -21,6 +23,77 @@ 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);
|
||||
|
||||
impl NonEmptyString {
|
||||
pub fn new(s: String) -> Option<Self> {
|
||||
if s.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(NonEmptyString(s))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_str(&self) -> &str {
|
||||
&self.0
|
||||
}
|
||||
|
||||
pub fn into_string(self) -> String {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
// Implement Deref to allow automatic dereferencing to &str
|
||||
impl Deref for NonEmptyString {
|
||||
type Target = str;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
// This allows &NonEmptyString to be converted to &str
|
||||
impl AsRef<str> for NonEmptyString {
|
||||
fn as_ref(&self) -> &str {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
// This allows NonEmptyString to be converted to String with .into()
|
||||
impl From<NonEmptyString> for String {
|
||||
fn from(s: NonEmptyString) -> Self {
|
||||
s.0
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<&str> for NonEmptyString {
|
||||
type Error = &'static str;
|
||||
|
||||
fn try_from(s: &str) -> Result<Self, Self::Error> {
|
||||
if s.is_empty() {
|
||||
Err("String cannot be empty")
|
||||
} else {
|
||||
Ok(NonEmptyString(s.to_string()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<String> for NonEmptyString {
|
||||
type Error = &'static str;
|
||||
|
||||
fn try_from(s: String) -> Result<Self, Self::Error> {
|
||||
if s.is_empty() {
|
||||
Err("String cannot be empty")
|
||||
} else {
|
||||
Ok(NonEmptyString(s))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[macro_export]
|
||||
|
@ -8,7 +8,7 @@ use rot::rest;
|
||||
use rot::tera;
|
||||
use rot::{scheduled, tera::Config};
|
||||
|
||||
use sqlx::{pool::PoolOptions, sqlite::SqliteConnectOptions, ConnectOptions};
|
||||
use sqlx::{ConnectOptions, pool::PoolOptions, sqlite::SqliteConnectOptions};
|
||||
|
||||
#[macro_use]
|
||||
extern crate rocket;
|
||||
|
270
src/model/activity.rs
Normal file
270
src/model/activity.rs
Normal file
@ -0,0 +1,270 @@
|
||||
use std::ops::DerefMut;
|
||||
|
||||
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};
|
||||
|
||||
#[derive(FromRow, Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Activity {
|
||||
pub id: i64,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub text: String,
|
||||
pub relevant_for: String,
|
||||
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,
|
||||
keep_until: Option<NaiveDateTime>,
|
||||
}
|
||||
|
||||
impl ActivityBuilder {
|
||||
/// TODO: maybe make this private, and only allow specific acitivites defined in `Reason`
|
||||
#[must_use]
|
||||
pub fn new(text: &str) -> Self {
|
||||
Self {
|
||||
text: text.into(),
|
||||
relevant_for: String::new(),
|
||||
keep_until: None,
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn user(self, user: &User) -> Self {
|
||||
Self {
|
||||
relevant_for: format!("{}user-{};", self.relevant_for, user.id),
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
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;
|
||||
}
|
||||
|
||||
pub async fn save_tx(self, db: &mut Transaction<'_, Sqlite>) {
|
||||
Activity::create_with_tx(db, &self.text, &self.relevant_for, self.keep_until).await;
|
||||
}
|
||||
}
|
||||
|
||||
impl Activity {
|
||||
pub async fn find_by_id(db: &SqlitePool, id: i64) -> Option<Self> {
|
||||
sqlx::query_as!(
|
||||
Self,
|
||||
"SELECT id, created_at, text, relevant_for, keep_until FROM activity WHERE id like ?",
|
||||
id
|
||||
)
|
||||
.fetch_one(db)
|
||||
.await
|
||||
.ok()
|
||||
}
|
||||
pub(super) async fn create_with_tx(
|
||||
db: &mut Transaction<'_, Sqlite>,
|
||||
text: &str,
|
||||
relevant_for: &str,
|
||||
keep_until: Option<NaiveDateTime>,
|
||||
) {
|
||||
sqlx::query!(
|
||||
"INSERT INTO activity(text, relevant_for, keep_until) VALUES (?, ?, ?)",
|
||||
text,
|
||||
relevant_for,
|
||||
keep_until
|
||||
)
|
||||
.execute(db.deref_mut())
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub(super) async fn create(
|
||||
db: &SqlitePool,
|
||||
text: &str,
|
||||
relevant_for: &str,
|
||||
keep_until: Option<NaiveDateTime>,
|
||||
) {
|
||||
let mut tx = db.begin().await.unwrap();
|
||||
Self::create_with_tx(&mut tx, text, relevant_for, keep_until).await;
|
||||
tx.commit().await.unwrap();
|
||||
}
|
||||
|
||||
pub async fn for_user(db: &SqlitePool, user: &User) -> Vec<Activity> {
|
||||
let user_str = format!("user-{};", user.id);
|
||||
sqlx::query_as!(
|
||||
Self,
|
||||
"
|
||||
SELECT id, created_at, text, relevant_for, keep_until FROM activity
|
||||
WHERE
|
||||
relevant_for like CONCAT('%', ?, '%')
|
||||
ORDER BY created_at DESC;
|
||||
",
|
||||
user_str
|
||||
)
|
||||
.fetch_all(db)
|
||||
.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,15 +1,15 @@
|
||||
use std::ops::DerefMut;
|
||||
|
||||
use chrono::NaiveDateTime;
|
||||
use itertools::Itertools;
|
||||
use rocket::serde::{Deserialize, Serialize};
|
||||
use rocket::FromForm;
|
||||
use rocket::serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||
|
||||
use crate::model::boathouse::Boathouse;
|
||||
|
||||
use super::location::Location;
|
||||
use super::user::User;
|
||||
use std::fmt::Display;
|
||||
|
||||
#[derive(FromRow, Debug, Serialize, Deserialize, Eq, Hash, PartialEq, Clone)]
|
||||
pub struct Boat {
|
||||
@ -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> {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::model::{boat::Boat, user::User};
|
||||
use chrono::NaiveDateTime;
|
||||
use rocket::serde::{Deserialize, Serialize};
|
||||
use rocket::FromForm;
|
||||
use rocket::serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, SqlitePool};
|
||||
|
||||
use super::log::Log;
|
||||
|
@ -1,13 +1,13 @@
|
||||
use std::ops::DerefMut;
|
||||
|
||||
use serde::Serialize;
|
||||
use sqlx::{sqlite::SqliteQueryResult, FromRow, Sqlite, SqlitePool, Transaction};
|
||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction, sqlite::SqliteQueryResult};
|
||||
|
||||
use super::user::User;
|
||||
|
||||
#[derive(FromRow, Serialize, Clone)]
|
||||
pub struct Family {
|
||||
id: i64,
|
||||
pub(crate) id: i64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
@ -86,9 +86,23 @@ 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()
|
||||
}
|
||||
|
||||
pub async fn clean_families_without_members(db: &SqlitePool) {
|
||||
sqlx::query(
|
||||
"DELETE FROM family
|
||||
WHERE id NOT IN (
|
||||
SELECT DISTINCT family_id
|
||||
FROM user
|
||||
WHERE family_id IS NOT NULL
|
||||
);",
|
||||
)
|
||||
.execute(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,15 +1,22 @@
|
||||
use std::ops::DerefMut;
|
||||
use std::{fmt::Display, ops::DerefMut};
|
||||
|
||||
use chrono::{Datelike, Duration, Local, NaiveDateTime};
|
||||
use rocket::FromForm;
|
||||
use serde::Serialize;
|
||||
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,
|
||||
};
|
||||
use crate::model::user::VecUser;
|
||||
|
||||
#[derive(FromRow, Serialize, Clone, Debug)]
|
||||
#[derive(FromRow, Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct Logbook {
|
||||
pub id: i64,
|
||||
pub boat_id: i64,
|
||||
@ -105,7 +112,7 @@ impl TryFrom<LogToAdd> for LogToFinalize {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct LogbookWithBoatAndRowers {
|
||||
#[serde(flatten)]
|
||||
pub logbook: 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();
|
||||
@ -367,7 +422,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 +453,6 @@ ORDER BY departure DESC
|
||||
}
|
||||
}
|
||||
}
|
||||
if exclude_last_log {
|
||||
ret.pop();
|
||||
}
|
||||
|
||||
ret
|
||||
}
|
||||
@ -811,37 +862,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,
|
||||
@ -856,8 +892,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
|
||||
|
@ -1,15 +1,15 @@
|
||||
use std::{error::Error, fs};
|
||||
|
||||
use lettre::{
|
||||
message::{header::ContentType, Attachment, MultiPart, SinglePart},
|
||||
Address, Message, SmtpTransport, Transport,
|
||||
message::{Attachment, MultiPart, SinglePart, header::ContentType},
|
||||
transport::smtp::authentication::Credentials,
|
||||
Message, SmtpTransport, Transport,
|
||||
};
|
||||
use sqlx::{Sqlite, SqlitePool, Transaction};
|
||||
|
||||
use crate::tera::admin::mail::MailToSend;
|
||||
|
||||
use super::{family::Family, log::Log, role::Role, user::User};
|
||||
use super::{activity::ActivityBuilder, family::Family, log::Log, role::Role, user::User};
|
||||
|
||||
pub struct Mail {}
|
||||
|
||||
@ -79,7 +79,9 @@ impl Mail {
|
||||
.build();
|
||||
|
||||
// Send the email
|
||||
mailer.send(&email).unwrap();
|
||||
if let Err(e) = mailer.send(&email) {
|
||||
Log::create_with_tx(db, format!("Mail nicht versandt: {e:?}")).await;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -159,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();
|
||||
@ -251,6 +258,12 @@ Der Vorstand");
|
||||
|
||||
// Send the email
|
||||
mailer.send(&email).unwrap();
|
||||
ActivityBuilder::new(&format!(
|
||||
"{user} hat die Info-Mail bzgl. Gebühren gesendet bekommen."
|
||||
))
|
||||
.user(&user)
|
||||
.save(db)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -265,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;
|
||||
@ -367,6 +385,12 @@ Der Vorstand");
|
||||
|
||||
// Send the email
|
||||
mailer.send(&email).unwrap();
|
||||
ActivityBuilder::new(&format!(
|
||||
"{user} hat die Mahn-Mail bzgl. Gebühren gesendet bekommen."
|
||||
))
|
||||
.user(&user)
|
||||
.save(db)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -374,3 +398,13 @@ Der Vorstand");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn valid_mails(mails: &str) -> bool {
|
||||
let splitted = mails.split(',');
|
||||
for single_rec in splitted {
|
||||
if single_rec.parse::<Address>().is_err() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
@ -5,21 +5,20 @@ 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;
|
||||
pub mod boat;
|
||||
pub mod boatdamage;
|
||||
pub mod boathouse;
|
||||
pub mod boatreservation;
|
||||
pub mod distance;
|
||||
pub mod event;
|
||||
pub mod family;
|
||||
pub mod location;
|
||||
pub mod log;
|
||||
@ -28,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,12 +226,14 @@ ORDER BY read_at DESC, created_at DESC;
|
||||
mod test {
|
||||
use crate::{
|
||||
model::{
|
||||
event::{Event, EventUpdate, Registration},
|
||||
notification::Notification,
|
||||
trip::Trip,
|
||||
tripdetails::{TripDetails, TripDetailsToAdd},
|
||||
planned::{
|
||||
event::{Event, EventUpdate, Registration},
|
||||
trip::Trip,
|
||||
tripdetails::{TripDetails, TripDetailsToAdd},
|
||||
usertrip::UserTrip,
|
||||
},
|
||||
user::{EventUser, SteeringUser, User},
|
||||
usertrip::UserTrip,
|
||||
},
|
||||
testdb,
|
||||
};
|
||||
@ -256,7 +258,7 @@ mod test {
|
||||
let trip_details = TripDetails::find_by_id(&pool, tripdetails_id)
|
||||
.await
|
||||
.unwrap();
|
||||
let user = EventUser::new(&pool, User::find_by_id(&pool, 1).await.unwrap())
|
||||
let user = EventUser::new(&pool, &User::find_by_id(&pool, 1).await.unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
Event::create(&pool, &user, "new-event".into(), 2, false, &trip_details).await;
|
||||
@ -269,7 +271,7 @@ mod test {
|
||||
UserTrip::create(&pool, &rower, &trip_details, None)
|
||||
.await
|
||||
.unwrap();
|
||||
let cox = SteeringUser::new(&pool, User::find_by_name(&pool, "cox").await.unwrap())
|
||||
let cox = SteeringUser::new(&pool, &User::find_by_name(&pool, "cox").await.unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
Trip::new_join(&pool, &cox, &event).await.unwrap();
|
||||
@ -284,7 +286,7 @@ mod test {
|
||||
is_locked: event.is_locked,
|
||||
trip_type_id: None,
|
||||
};
|
||||
event.update(&pool, &cancel_update).await;
|
||||
event.update(&pool, &user, &cancel_update).await;
|
||||
|
||||
// Rower received notification
|
||||
let notifications = Notification::for_user(&pool, &rower).await;
|
||||
@ -314,12 +316,12 @@ mod test {
|
||||
is_locked: event.is_locked,
|
||||
trip_type_id: None,
|
||||
};
|
||||
event.update(&pool, &update).await;
|
||||
event.update(&pool, &user, &update).await;
|
||||
assert!(Notification::for_user(&pool, &rower).await.is_empty());
|
||||
assert!(Notification::for_user(&pool, &cox.user).await.is_empty());
|
||||
|
||||
// Cancel event again
|
||||
event.update(&pool, &cancel_update).await;
|
||||
event.update(&pool, &user, &cancel_update).await;
|
||||
|
||||
// Rower is removed if notification is accepted
|
||||
assert!(event.is_rower_registered(&pool, &rower).await);
|
||||
|
@ -1,9 +1,17 @@
|
||||
use std::io::Write;
|
||||
|
||||
use ics::{components::Property, ICalendar};
|
||||
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::{
|
||||
properties::{DtEnd, DtStart, Summary},
|
||||
ICalendar,
|
||||
};
|
||||
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);
|
||||
@ -313,7 +318,7 @@ WHERE trip_details.id=?
|
||||
}
|
||||
|
||||
//TODO: create unit test
|
||||
pub async fn update(&self, db: &SqlitePool, update: &EventUpdate<'_>) {
|
||||
pub async fn update(&self, db: &SqlitePool, user: &EventUser, update: &EventUpdate<'_>) {
|
||||
sqlx::query!(
|
||||
"UPDATE planned_event SET name = ?, planned_amount_cox = ? WHERE id = ?",
|
||||
update.name,
|
||||
@ -340,6 +345,20 @@ WHERE trip_details.id=?
|
||||
.await
|
||||
.unwrap(); //Okay, as planned_event can only be created with proper DB backing
|
||||
|
||||
Log::create(
|
||||
db,
|
||||
format!(
|
||||
"{} updated the event {} on {} at {} from {:?} to {:?}",
|
||||
user.user.name,
|
||||
self.name,
|
||||
tripdetails.day,
|
||||
tripdetails.planned_starting_time,
|
||||
self,
|
||||
update
|
||||
),
|
||||
)
|
||||
.await;
|
||||
|
||||
if !tripdetails.always_show && update.always_show {
|
||||
Self::advertise(
|
||||
db,
|
||||
@ -452,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
|
||||
@ -514,7 +482,7 @@ WHERE trip_details.id=?
|
||||
mod test {
|
||||
use crate::{
|
||||
model::{
|
||||
tripdetails::TripDetails,
|
||||
planned::tripdetails::TripDetails,
|
||||
user::{EventUser, User},
|
||||
},
|
||||
testdb,
|
||||
@ -538,7 +506,7 @@ mod test {
|
||||
|
||||
let trip_details = TripDetails::find_by_id(&pool, 1).await.unwrap();
|
||||
|
||||
let admin = EventUser::new(&pool, User::find_by_id(&pool, 1).await.unwrap())
|
||||
let admin = EventUser::new(&pool, &User::find_by_id(&pool, 1).await.unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
Event::create(&pool, &admin, "new-event".into(), 2, false, &trip_details).await;
|
||||
@ -564,6 +532,11 @@ mod test {
|
||||
|
||||
let today = Local::now().date_naive().format("%Y%m%d").to_string();
|
||||
let actual = Event::get_ics_feed(&pool).await;
|
||||
assert_eq!(format!("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:ics-rs\r\nBEGIN:VEVENT\r\nUID:event-1@rudernlinz.at\r\nDTSTAMP:19900101T180000\r\nDTSTART:{today}T100000\r\nDTEND:{today}T130000\r\nSUMMARY:test-planned-event \r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"), actual);
|
||||
assert_eq!(
|
||||
format!(
|
||||
"BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:ics-rs\r\nBEGIN:VEVENT\r\nUID:event-1@rudernlinz.at\r\nDTSTAMP:19900101T180000\r\nDTSTART:{today}T100000\r\nDTEND:{today}T130000\r\nSUMMARY:test-planned-event \r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"
|
||||
),
|
||||
actual
|
||||
);
|
||||
}
|
||||
}
|
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;
|
76
src/model/planned/trip/create.rs
Normal file
76
src/model/planned/trip/create.rs
Normal file
@ -0,0 +1,76 @@
|
||||
use super::Trip;
|
||||
use crate::model::{
|
||||
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;
|
||||
|
||||
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>,
|
||||
@ -47,7 +50,7 @@ pub struct TripUpdate<'a> {
|
||||
pub is_locked: bool,
|
||||
}
|
||||
|
||||
impl<'a> TripUpdate<'a> {
|
||||
impl TripUpdate<'_> {
|
||||
fn cancelled(&self) -> bool {
|
||||
self.max_people == -1
|
||||
}
|
||||
@ -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,12 +413,14 @@ pub enum TripUpdateError {
|
||||
mod test {
|
||||
use crate::{
|
||||
model::{
|
||||
event::Event,
|
||||
notification::Notification,
|
||||
trip::{self, TripDeleteError},
|
||||
tripdetails::TripDetails,
|
||||
planned::{
|
||||
event::Event,
|
||||
trip::{self, TripDeleteError},
|
||||
tripdetails::TripDetails,
|
||||
usertrip::UserTrip,
|
||||
},
|
||||
user::{SteeringUser, User},
|
||||
usertrip::UserTrip,
|
||||
},
|
||||
testdb,
|
||||
};
|
||||
@ -532,7 +436,7 @@ mod test {
|
||||
|
||||
let cox = SteeringUser::new(
|
||||
&pool,
|
||||
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||
&User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
@ -549,7 +453,7 @@ mod test {
|
||||
let pool = testdb!();
|
||||
let cox = SteeringUser::new(
|
||||
&pool,
|
||||
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||
&User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
@ -558,7 +462,7 @@ mod test {
|
||||
|
||||
let cox2 = SteeringUser::new(
|
||||
&pool,
|
||||
User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
||||
&User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
@ -567,9 +471,11 @@ mod test {
|
||||
|
||||
let last_notification = &Notification::for_user(&pool, &cox).await[0];
|
||||
|
||||
assert!(last_notification
|
||||
.message
|
||||
.starts_with("cox2 hat eine Ausfahrt zur selben Zeit"));
|
||||
assert!(
|
||||
last_notification
|
||||
.message
|
||||
.starts_with("cox2 hat eine Ausfahrt zur selben Zeit")
|
||||
);
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
@ -587,7 +493,7 @@ mod test {
|
||||
|
||||
let cox = SteeringUser::new(
|
||||
&pool,
|
||||
User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
||||
&User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
@ -603,7 +509,7 @@ mod test {
|
||||
|
||||
let cox = SteeringUser::new(
|
||||
&pool,
|
||||
User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
||||
&User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
@ -620,7 +526,7 @@ mod test {
|
||||
|
||||
let cox = SteeringUser::new(
|
||||
&pool,
|
||||
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||
&User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
@ -648,7 +554,7 @@ mod test {
|
||||
|
||||
let cox = SteeringUser::new(
|
||||
&pool,
|
||||
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||
&User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
@ -676,7 +582,7 @@ mod test {
|
||||
|
||||
let cox = SteeringUser::new(
|
||||
&pool,
|
||||
User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
||||
&User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
@ -701,7 +607,7 @@ mod test {
|
||||
|
||||
let cox = SteeringUser::new(
|
||||
&pool,
|
||||
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||
&User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
@ -724,7 +630,7 @@ mod test {
|
||||
|
||||
let cox = SteeringUser::new(
|
||||
&pool,
|
||||
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||
&User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
@ -742,7 +648,7 @@ mod test {
|
||||
|
||||
let cox = SteeringUser::new(
|
||||
&pool,
|
||||
User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
||||
&User::find_by_name(&pool, "cox2".into()).await.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
@ -764,7 +670,7 @@ mod test {
|
||||
|
||||
let cox = SteeringUser::new(
|
||||
&pool,
|
||||
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||
&User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
@ -1,11 +1,10 @@
|
||||
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,
|
||||
};
|
||||
@ -303,7 +302,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 {
|
||||
@ -197,7 +199,7 @@ impl UserTrip {
|
||||
let mut add_info = "";
|
||||
if let Some(trip) = &trip_to_delete {
|
||||
let cox = User::find_by_id(db, trip.cox_id as i32).await.unwrap();
|
||||
trip.delete(db, &SteeringUser::new(db, cox).await.unwrap())
|
||||
trip.delete(db, &SteeringUser::new(db, &cox).await.unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
add_info = " Das war die letzte angemeldete Person. Nachdem nun alle Bescheid wissen, wird die Ausfahrt ab sofort nicht mehr angezeigt.";
|
||||
@ -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,
|
||||
};
|
||||
@ -355,7 +359,7 @@ mod test {
|
||||
|
||||
let cox = SteeringUser::new(
|
||||
&pool,
|
||||
User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||
&User::find_by_name(&pool, "cox".into()).await.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
@ -1,5 +1,6 @@
|
||||
use std::ops::DerefMut;
|
||||
use std::{cmp::Ordering, fmt::Display, ops::DerefMut};
|
||||
|
||||
use super::{activity::ActivityBuilder, user::AdminUser};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||
|
||||
@ -7,22 +8,83 @@ use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||
pub struct Role {
|
||||
pub(crate) id: i64,
|
||||
pub(crate) name: String,
|
||||
pub(crate) formatted_name: Option<String>,
|
||||
pub(crate) desc: Option<String>,
|
||||
pub(crate) hide_in_lists: bool,
|
||||
pub(crate) cluster: Option<String>,
|
||||
}
|
||||
|
||||
// Implement PartialEq to compare roles based only on id
|
||||
impl PartialEq for Role {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.id == other.id
|
||||
}
|
||||
}
|
||||
|
||||
// Implement Eq to indicate that equality is reflexive
|
||||
impl Eq for Role {}
|
||||
|
||||
// Implement PartialOrd if you need to sort or compare roles
|
||||
impl PartialOrd for Role {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.id.cmp(&other.id))
|
||||
}
|
||||
}
|
||||
|
||||
// Implement Ord if you need total ordering (for sorting)
|
||||
impl Ord for Role {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
self.id.cmp(&other.id)
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
pub async fn all(db: &SqlitePool) -> Vec<Role> {
|
||||
sqlx::query_as!(Role, "SELECT id, name, cluster FROM role")
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap()
|
||||
sqlx::query_as!(
|
||||
Role,
|
||||
"SELECT id, name, formatted_name, desc, hide_in_lists, cluster FROM role"
|
||||
)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub async fn all_cluster(db: &SqlitePool, cluster: &str) -> Vec<Role> {
|
||||
sqlx::query_as!(
|
||||
Role,
|
||||
r#"SELECT id,
|
||||
CASE WHEN formatted_name IS NOT NULL AND formatted_name != ''
|
||||
THEN formatted_name
|
||||
ELSE name
|
||||
END AS "name!: String",
|
||||
'' as formatted_name,
|
||||
desc,
|
||||
hide_in_lists,
|
||||
cluster
|
||||
FROM role
|
||||
WHERE cluster = ?"#,
|
||||
cluster
|
||||
)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub async fn find_by_id(db: &SqlitePool, name: i32) -> Option<Self> {
|
||||
sqlx::query_as!(
|
||||
Self,
|
||||
"
|
||||
SELECT id, name, cluster
|
||||
SELECT id, name, formatted_name, desc, hide_in_lists, cluster
|
||||
FROM role
|
||||
WHERE id like ?
|
||||
",
|
||||
@ -36,7 +98,7 @@ WHERE id like ?
|
||||
sqlx::query_as!(
|
||||
Self,
|
||||
"
|
||||
SELECT id, name, cluster
|
||||
SELECT id, name, formatted_name, desc, hide_in_lists, cluster
|
||||
FROM role
|
||||
WHERE id like ?
|
||||
",
|
||||
@ -47,26 +109,11 @@ WHERE id like ?
|
||||
.ok()
|
||||
}
|
||||
|
||||
pub async fn find_by_cluster_tx(db: &mut Transaction<'_, Sqlite>, name: i32) -> Option<Self> {
|
||||
sqlx::query_as!(
|
||||
Self,
|
||||
"
|
||||
SELECT id, name, cluster
|
||||
FROM role
|
||||
WHERE cluster = ?
|
||||
",
|
||||
name
|
||||
)
|
||||
.fetch_one(db.deref_mut())
|
||||
.await
|
||||
.ok()
|
||||
}
|
||||
|
||||
pub async fn find_by_name(db: &SqlitePool, name: &str) -> Option<Self> {
|
||||
sqlx::query_as!(
|
||||
Self,
|
||||
"
|
||||
SELECT id, name, cluster
|
||||
SELECT id, name, formatted_name, desc, hide_in_lists, cluster
|
||||
FROM role
|
||||
WHERE name like ?
|
||||
",
|
||||
@ -81,7 +128,7 @@ WHERE name like ?
|
||||
sqlx::query_as!(
|
||||
Self,
|
||||
"
|
||||
SELECT id, name, cluster
|
||||
SELECT id, name, formatted_name, desc, hide_in_lists, cluster
|
||||
FROM role
|
||||
WHERE name like ?
|
||||
",
|
||||
@ -92,6 +139,30 @@ WHERE name like ?
|
||||
.ok()
|
||||
}
|
||||
|
||||
pub async fn update(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
updated_by: &AdminUser,
|
||||
formatted_name: &str,
|
||||
desc: &str,
|
||||
) -> Result<(), String> {
|
||||
sqlx::query!(
|
||||
"UPDATE role SET formatted_name=?, desc=? WHERE id=?",
|
||||
formatted_name,
|
||||
desc,
|
||||
self.id
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{updated_by} hat Rolle {self} von {self:#?} auf FORMATTED_NAME={formatted_name}, DESC={desc} aktualisiert."
|
||||
)).role(self).save(db).await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn names_from_role(&self, db: &SqlitePool) -> Vec<String> {
|
||||
let query = format!(
|
||||
"SELECT u.name
|
||||
|
@ -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=?)
|
||||
",
|
||||
|
553
src/model/user/basic.rs
Normal file
553
src/model/user/basic.rs
Normal file
@ -0,0 +1,553 @@
|
||||
// TODO: put back in `src/model/user/mod.rs` once that is cleaned up
|
||||
|
||||
use super::{AllowedToEditPaymentStatusUser, ManageUserUser, User};
|
||||
use crate::model::{
|
||||
activity::{self, ActivityBuilder},
|
||||
family::Family,
|
||||
mail::valid_mails,
|
||||
notification::Notification,
|
||||
role::Role,
|
||||
};
|
||||
use chrono::NaiveDate;
|
||||
use rocket::{fs::TempFile, tokio::io::AsyncReadExt};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
impl User {
|
||||
pub(crate) async fn add_note(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
updated_by: &ManageUserUser,
|
||||
note: &str,
|
||||
) -> Result<(), String> {
|
||||
let note = note.trim();
|
||||
|
||||
ActivityBuilder::from(activity::Reason::UserDataChange(
|
||||
updated_by,
|
||||
self,
|
||||
note.to_string(),
|
||||
))
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn update_mail(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
updated_by: &ManageUserUser,
|
||||
new_mail: &str,
|
||||
) -> Result<(), String> {
|
||||
let new_mail = new_mail.trim();
|
||||
|
||||
if !valid_mails(new_mail) {
|
||||
return Err(format!(
|
||||
"{new_mail} ist kein gültiges Format für eine Mailadresse"
|
||||
));
|
||||
}
|
||||
|
||||
sqlx::query!("UPDATE user SET mail = ? where id = ?", new_mail, self.id)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap(); //Okay, because we can only create a User of a valid id
|
||||
|
||||
let msg = match &self.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::from(activity::Reason::UserDataChange(updated_by, self, msg))
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn update_phone(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
updated_by: &ManageUserUser,
|
||||
new_phone: &str,
|
||||
) {
|
||||
let new_phone = new_phone.trim();
|
||||
|
||||
let query = if new_phone.is_empty() {
|
||||
if self.phone.is_none() {
|
||||
return; // nothing to do
|
||||
}
|
||||
sqlx::query!("UPDATE user SET phone = NULL where id = ?", self.id)
|
||||
} else {
|
||||
if let Some(old_phone) = &self.phone {
|
||||
if old_phone == new_phone {
|
||||
return; //nothing to do
|
||||
}
|
||||
}
|
||||
sqlx::query!("UPDATE user SET phone = ? where id = ?", new_phone, self.id)
|
||||
};
|
||||
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!("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::from(activity::Reason::UserDataChange(updated_by, self, msg))
|
||||
.save(db)
|
||||
.await;
|
||||
}
|
||||
|
||||
pub(crate) async fn update_address(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
updated_by: &ManageUserUser,
|
||||
new_address: &str,
|
||||
) {
|
||||
let new_address = new_address.trim();
|
||||
|
||||
let query = if new_address.is_empty() {
|
||||
if self.address.is_none() {
|
||||
return; // nothing to do
|
||||
}
|
||||
sqlx::query!("UPDATE user SET address = NULL where id = ?", self.id)
|
||||
} else {
|
||||
if let Some(old_address) = &self.address {
|
||||
if old_address == new_address {
|
||||
return; //nothing to do
|
||||
}
|
||||
}
|
||||
sqlx::query!(
|
||||
"UPDATE user SET address = ? where id = ?",
|
||||
new_address,
|
||||
self.id
|
||||
)
|
||||
};
|
||||
query.execute(db).await.unwrap(); //Okay, because we can only create a User of a valid id
|
||||
|
||||
let msg = match &self.address {
|
||||
Some(old_address) if new_address.is_empty() => format!(
|
||||
"{updated_by} hat die Adresse von {self} entfernt (alte Adresse: {old_address})"
|
||||
),
|
||||
Some(old_address) => format!(
|
||||
"{updated_by} hat die Adresse von {self} von {old_address} auf {new_address} geändert."
|
||||
),
|
||||
None => format!("{updated_by} hat eine Adresse für {self} hinzugefügt: {new_address}"),
|
||||
};
|
||||
|
||||
ActivityBuilder::new(&msg).user(self).save(db).await;
|
||||
}
|
||||
|
||||
pub(crate) async fn update_nickname(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
updated_by: &ManageUserUser,
|
||||
new_nickname: &str,
|
||||
) -> Result<(), String> {
|
||||
let new_nickname = new_nickname.trim();
|
||||
|
||||
let query = if new_nickname.is_empty() {
|
||||
sqlx::query!("UPDATE user SET nickname = NULL where id = ?", self.id)
|
||||
} else {
|
||||
sqlx::query!(
|
||||
"UPDATE user SET nickname = ? where id = ?",
|
||||
new_nickname,
|
||||
self.id
|
||||
)
|
||||
};
|
||||
query.execute(db).await.unwrap(); //Okay, because we can only create a User of a valid id
|
||||
|
||||
let msg = match &self.nickname {
|
||||
Some(old_nickname) if new_nickname.is_empty() => format!(
|
||||
"{updated_by} hat den Sitznamen von {self} entfernt (alter Spitzname: {old_nickname})"
|
||||
),
|
||||
Some(old_nickname) => format!(
|
||||
"{updated_by} hat den Spitznamen von {self} von {old_nickname} auf {new_nickname} geändert."
|
||||
),
|
||||
None => format!(
|
||||
"{updated_by} hat einen neuen Spitznamen für {self} hinzugefügt: {new_nickname}"
|
||||
),
|
||||
};
|
||||
ActivityBuilder::new(&msg).user(self).save(db).await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn update_member_since(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
updated_by: &ManageUserUser,
|
||||
new_member_since_date: &NaiveDate,
|
||||
) {
|
||||
sqlx::query!(
|
||||
"UPDATE user SET member_since_date = ? where id = ?",
|
||||
new_member_since_date,
|
||||
self.id
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap(); //Okay, because we can only create a User of a valid id
|
||||
|
||||
let msg = match &self.member_since_date {
|
||||
Some(old_member_since_date) => format!(
|
||||
"{updated_by} hat das Beitrittsdatum von {self} von {old_member_since_date} auf {new_member_since_date} geändert."
|
||||
),
|
||||
None => format!(
|
||||
"{updated_by} hat ein neues Beitrittsdatum für {self} hinzugefügt: {new_member_since_date}"
|
||||
),
|
||||
};
|
||||
|
||||
ActivityBuilder::new(&msg).user(self).save(db).await;
|
||||
}
|
||||
|
||||
pub(crate) async fn update_birthdate(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
updated_by: &ManageUserUser,
|
||||
new_birthdate: &NaiveDate,
|
||||
) {
|
||||
sqlx::query!(
|
||||
"UPDATE user SET birthdate = ? where id = ?",
|
||||
new_birthdate,
|
||||
self.id
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap(); //Okay, because we can only create a User of a valid id
|
||||
|
||||
let msg = match &self.birthdate {
|
||||
Some(old_birthdate) => format!(
|
||||
"{updated_by} hat das Geburtsdatum von {self} von {old_birthdate} auf {new_birthdate} geändert."
|
||||
),
|
||||
None => {
|
||||
format!("{updated_by} hat ein Geburtsdatum für {self} hinzugefügt: {new_birthdate}")
|
||||
}
|
||||
};
|
||||
|
||||
ActivityBuilder::new(&msg).user(self).save(db).await;
|
||||
}
|
||||
|
||||
pub(crate) async fn update_family(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
updated_by: &ManageUserUser,
|
||||
family: Option<Family>,
|
||||
) {
|
||||
if let Some(family) = family {
|
||||
let family_id = family.id;
|
||||
sqlx::query!(
|
||||
"UPDATE user SET family_id = ? where id = ?",
|
||||
family_id,
|
||||
self.id
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap();
|
||||
ActivityBuilder::new(&format!(
|
||||
"{updated_by} hat {self} zu einer Familie hinzugefügt."
|
||||
))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
} else {
|
||||
sqlx::query!("UPDATE user SET family_id = NULL where id = ?", self.id)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap();
|
||||
ActivityBuilder::new(&format!(
|
||||
"{updated_by} hat die Familienzugehörigkeit von {self} gelöscht."
|
||||
))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
};
|
||||
|
||||
Family::clean_families_without_members(db).await;
|
||||
}
|
||||
|
||||
pub(crate) async fn change_skill(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
updated_by: &ManageUserUser,
|
||||
skill: Option<Role>,
|
||||
) -> Result<(), String> {
|
||||
let old_skill = self.skill(db).await;
|
||||
|
||||
let member = Role::find_by_name(db, "Donau Linz").await.unwrap();
|
||||
let cox = Role::find_by_name(db, "cox").await.unwrap();
|
||||
let bootsfuehrer = Role::find_by_name(db, "Bootsführer").await.unwrap();
|
||||
|
||||
match (old_skill, skill) {
|
||||
(None, new) if new == Some(cox.clone()) => {
|
||||
self.add_role(db, updated_by, &cox).await?;
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
&member,
|
||||
&format!(
|
||||
"Liebes Vereinsmitglied, {self} ist ab sofort Steuerperson 🎉 Hip hip ...!"
|
||||
),
|
||||
"Neue Steuerperson",
|
||||
None,
|
||||
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"))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
}
|
||||
(old, new) if old == Some(cox.clone()) && new == Some(bootsfuehrer.clone()) => {
|
||||
self.remove_role(db, updated_by, &cox).await?;
|
||||
self.add_role(db, updated_by, &bootsfuehrer).await?;
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
&member,
|
||||
&format!(
|
||||
"Liebes Vereinsmitglied, {self} ist ab sofort Bootsführer:in 🎉 Hip hip ...!"
|
||||
),
|
||||
"Neue:r Bootsführer:in",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
ActivityBuilder::new(&format!("{updated_by} hat {self} zum Bootsführer gemacht"))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
}
|
||||
(old, None) => {
|
||||
if let Some(old) = old {
|
||||
self.remove_role(db, updated_by, &old).await?;
|
||||
let vorstand = Role::find_by_name(db, "Vorstand").await.unwrap();
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
&vorstand,
|
||||
&format!("Lieber Vorstand, {self} ist ab sofort kein {old} mehr."),
|
||||
"Steuerperson--;",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
ActivityBuilder::new(&format!("{updated_by} hat {self} zum normalen Mitglied gemacht (keine Steuerperson/Schiffsführer mehr)"))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
(old, new) => return Err(format!("Not allowed to change from {old:?} to {new:?}")),
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn change_financial(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
updated_by: &ManageUserUser,
|
||||
financial: Option<Role>,
|
||||
) -> Result<(), String> {
|
||||
let mut new = String::new();
|
||||
let mut old = String::new();
|
||||
|
||||
if let Some(old_financial) = self.financial(db).await {
|
||||
self.remove_role(db, updated_by, &old_financial).await?;
|
||||
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.to_string());
|
||||
} else {
|
||||
new.push_str("Keine Ermäßigung");
|
||||
}
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{updated_by} hat die Ermäßigung von {self} von {old} auf {new} geändert"
|
||||
))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn remove_role(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
updated_by: &ManageUserUser,
|
||||
role: &Role,
|
||||
) -> Result<(), String> {
|
||||
if !self.has_role(db, &role.name).await {
|
||||
return Err(format!(
|
||||
"Kann Rolle {role} von User {self} nicht entfernen, da der User die Rolle gar nicht hat"
|
||||
));
|
||||
}
|
||||
|
||||
sqlx::query!(
|
||||
"DELETE FROM user_role WHERE user_id = ? and role_id = ?",
|
||||
self.id,
|
||||
role.id
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
if !role.hide_in_lists && role.cluster.is_none() {
|
||||
ActivityBuilder::new(&format!(
|
||||
"{updated_by} hat die Rolle {role} von {self} entfernt."
|
||||
))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn has_not_paid(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
updated_by: &AllowedToEditPaymentStatusUser,
|
||||
) {
|
||||
let paid = Role::find_by_name(db, "paid").await.unwrap();
|
||||
|
||||
sqlx::query!(
|
||||
"DELETE FROM user_role WHERE user_id = ? and role_id = ?",
|
||||
self.id,
|
||||
paid.id
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{updated_by} hat den Bezahlstatus von {self} auf 'nicht bezahlt' gesetzt."
|
||||
))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
}
|
||||
pub(crate) async fn has_paid(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
updated_by: &AllowedToEditPaymentStatusUser,
|
||||
) {
|
||||
let paid = Role::find_by_name(db, "paid").await.unwrap();
|
||||
|
||||
sqlx::query!(
|
||||
"INSERT INTO user_role(user_id, role_id) VALUES (?, ?)",
|
||||
self.id,
|
||||
paid.id
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.expect("paid role has no group");
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{updated_by} hat den Bezahlstatus von {self} auf 'bezahlt' gesetzt."
|
||||
))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
}
|
||||
|
||||
pub(crate) async fn add_role(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
updated_by: &ManageUserUser,
|
||||
role: &Role,
|
||||
) -> Result<(), String> {
|
||||
if self.has_role(db, &role.name).await {
|
||||
return Err(format!(
|
||||
"Kann Rolle {role} von User {self} nicht hinzufügen, da der User die Rolle schon hat"
|
||||
));
|
||||
}
|
||||
|
||||
sqlx::query!(
|
||||
"INSERT INTO user_role(user_id, role_id) VALUES (?, ?)",
|
||||
self.id,
|
||||
role.id
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.map_err(|_| {
|
||||
format!(
|
||||
"User already has a role in the cluster '{}'",
|
||||
role.cluster
|
||||
.clone()
|
||||
.expect("db trigger can't activate on empty string")
|
||||
)
|
||||
})?;
|
||||
|
||||
if !role.hide_in_lists && role.cluster.is_none() {
|
||||
ActivityBuilder::new(&format!(
|
||||
"{updated_by} hat die Rolle '{role}' dem Benutzer {self} hinzugefügt."
|
||||
))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
}
|
||||
|
||||
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,
|
||||
updated_by: &ManageUserUser,
|
||||
membership_pdf: &TempFile<'_>,
|
||||
) -> Result<(), String> {
|
||||
if self.has_membership_pdf(db).await {
|
||||
return Err(format!("User {self} hat bereits eine Beitrittserklärung."));
|
||||
}
|
||||
if membership_pdf.len() == 0 {
|
||||
return Err("Keine Beitrittserklärung mitgeschickt.".to_string());
|
||||
}
|
||||
|
||||
let mut stream = membership_pdf.open().await.unwrap();
|
||||
let mut buffer = Vec::new();
|
||||
stream.read_to_end(&mut buffer).await.unwrap();
|
||||
sqlx::query!(
|
||||
"UPDATE user SET membership_pdf = ? where id = ?",
|
||||
buffer,
|
||||
self.id
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap(); //Okay, because we can only create a User of a valid id
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{updated_by} hat die Mitgliedserklärung (PDF) für user {self} hinzugefügt."
|
||||
))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
167
src/model/user/clubmember.rs
Normal file
167
src/model/user/clubmember.rs
Normal file
@ -0,0 +1,167 @@
|
||||
use super::User;
|
||||
use crate::{
|
||||
model::{
|
||||
activity::ActivityBuilder, notification::Notification, role::Role, user::ManageUserUser,
|
||||
},
|
||||
special_user,
|
||||
};
|
||||
use rocket::async_trait;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
special_user!(ClubMemberUser, +"Donau Linz", +"Förderndes Mitglied", +"Unterstützend");
|
||||
|
||||
impl ClubMemberUser {
|
||||
async fn add_membership_role(&self, db: &SqlitePool, role: &Role) {
|
||||
sqlx::query!(
|
||||
"INSERT INTO user_role(user_id, role_id) VALUES (?, ?)",
|
||||
self.id,
|
||||
role.id
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
async fn remove_membership_role(&self, db: &SqlitePool) {
|
||||
let role = Role::find_by_name(db, "Förderndes Mitglied").await.unwrap();
|
||||
sqlx::query!(
|
||||
"DELETE FROM user_role WHERE user_id = ? and role_id = ?",
|
||||
self.id,
|
||||
role.id
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let role = Role::find_by_name(db, "Unterstützend").await.unwrap();
|
||||
sqlx::query!(
|
||||
"DELETE FROM user_role WHERE user_id = ? and role_id = ?",
|
||||
self.id,
|
||||
role.id
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let role = Role::find_by_name(db, "Donau Linz").await.unwrap();
|
||||
sqlx::query!(
|
||||
"DELETE FROM user_role WHERE user_id = ? and role_id = ?",
|
||||
self.id,
|
||||
role.id
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
async fn new_membership_role(&self, db: &SqlitePool, role: &str) -> Result<(), String> {
|
||||
let role = Role::find_by_name(db, role).await.unwrap();
|
||||
self.remove_membership_role(db).await;
|
||||
self.add_membership_role(db, &role).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn move_to_regular(
|
||||
self,
|
||||
db: &SqlitePool,
|
||||
modified_by: &ManageUserUser,
|
||||
) -> Result<(), String> {
|
||||
if self.has_role(db, "Donau Linz").await {
|
||||
return Err(format!("User {self} ist bereits reguläres Mitglied."));
|
||||
}
|
||||
|
||||
self.new_membership_role(db, "Donau Linz").await?;
|
||||
|
||||
Notification::create_for_steering_people(
|
||||
db,
|
||||
&format!(
|
||||
"Liebe Steuerberechtigte, {} hat upgegraded und ist nun ein neues reguläres Mitglied. 🎉",
|
||||
self.name,
|
||||
),
|
||||
"Neues Vereinsmitglied",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{modified_by} hat {self} zu einem regulären hochgestuft."
|
||||
))
|
||||
.user(&self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn move_to_unterstuetzend(
|
||||
self,
|
||||
db: &SqlitePool,
|
||||
modified_by: &ManageUserUser,
|
||||
) -> Result<(), String> {
|
||||
if self.has_role(db, "Unterstützend").await {
|
||||
return Err(format!("User {self} ist bereits unterstützendes Mitglied."));
|
||||
}
|
||||
|
||||
self.new_membership_role(db, "Unterstützend").await?;
|
||||
|
||||
if let Some(vorstand) = Role::find_by_name(db, "vorstand").await {
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
&vorstand,
|
||||
&format!(
|
||||
"Lieber Vorstand, der Mitgliedstatus von {} hat sich geändert auf 'Unterstützendes Mitglied'.",
|
||||
self.name,
|
||||
),
|
||||
"Neues unterstützendes Vereinsmitglied",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{modified_by} hat {self} zu einem unterstützenden Mitglied gemacht."
|
||||
))
|
||||
.user(&self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn move_to_foerdernd(
|
||||
self,
|
||||
db: &SqlitePool,
|
||||
modified_by: &ManageUserUser,
|
||||
) -> Result<(), String> {
|
||||
if self.has_role(db, "Förderndes Mitglied").await {
|
||||
return Err(format!("User {self} ist bereits förderndes Mitglied."));
|
||||
}
|
||||
|
||||
self.new_membership_role(db, "Förderndes Mitglied").await?;
|
||||
|
||||
if let Some(vorstand) = Role::find_by_name(db, "vorstand").await {
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
&vorstand,
|
||||
&format!(
|
||||
"Lieber Vorstand, der Mitgliedstatus von {} hat sich geändert auf 'Förderndes Mitglied'.",
|
||||
self.name,
|
||||
),
|
||||
"Neues förderndes Vereinsmitglied",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{modified_by} hat {self} zu ein förderndes Mitglied gemacht."
|
||||
))
|
||||
.user(&self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
@ -1,5 +1,12 @@
|
||||
use super::User;
|
||||
use crate::{
|
||||
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;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct Fee {
|
||||
@ -56,3 +63,154 @@ impl Fee {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl User {
|
||||
pub async fn fee(&self, db: &SqlitePool) -> Option<Fee> {
|
||||
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;
|
||||
}
|
||||
if self.deleted {
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut fee = Fee::new();
|
||||
|
||||
if let Some(family) = Family::find_by_opt_id(db, self.family_id).await {
|
||||
for member in family.members(db).await {
|
||||
fee.add_person(&member);
|
||||
if member.has_role(db, "paid").await {
|
||||
fee.paid();
|
||||
}
|
||||
fee.merge(member.fee_without_families(db).await);
|
||||
}
|
||||
if family.amount_family_members(db).await > 2 {
|
||||
fee.add("Familie 3+ Personen".into(), FAMILY_THREE_OR_MORE);
|
||||
} else {
|
||||
fee.add("Familie 2 Personen".into(), FAMILY_TWO);
|
||||
}
|
||||
} else {
|
||||
fee.add_person(self);
|
||||
if self.has_role(db, "paid").await {
|
||||
fee.paid();
|
||||
}
|
||||
fee.merge(self.fee_without_families(db).await);
|
||||
}
|
||||
|
||||
Some(fee)
|
||||
}
|
||||
|
||||
async fn fee_without_families(&self, db: &SqlitePool) -> Fee {
|
||||
let mut fee = Fee::new();
|
||||
|
||||
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;
|
||||
}
|
||||
if self.has_role(db, "Rennrudern").await {
|
||||
if self.has_role(db, "half-rennrudern").await {
|
||||
fee.add("Rennruderbeitrag (1/2 Preis) ".into(), RENNRUDERBEITRAG / 2);
|
||||
} else if !self.has_role(db, "renntrainer").await {
|
||||
fee.add("Rennruderbeitrag".into(), RENNRUDERBEITRAG);
|
||||
}
|
||||
}
|
||||
|
||||
let amount_boats = self.amount_boats(db).await;
|
||||
if amount_boats > 0 {
|
||||
fee.add(
|
||||
format!("{}x Bootsplatz", amount_boats),
|
||||
amount_boats * BOAT_STORAGE,
|
||||
);
|
||||
}
|
||||
|
||||
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 member_since_date.year() == Local::now().year()
|
||||
&& !self.has_role(db, "no-einschreibgebuehr").await
|
||||
{
|
||||
fee.add("Einschreibgebühr".into(), EINSCHREIBGEBUEHR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let halfprice = if let Some(member_since_date) = &self.member_since_date {
|
||||
match NaiveDate::parse_from_str(member_since_date, "%Y-%m-%d") {
|
||||
Ok(member_since_date) => {
|
||||
let halfprice_startdate =
|
||||
NaiveDate::from_ymd_opt(Local::now().year(), 7, 1).unwrap();
|
||||
member_since_date >= halfprice_startdate
|
||||
}
|
||||
Err(_) => false,
|
||||
}
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
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);
|
||||
} else if Family::find_by_opt_id(db, self.family_id).await.is_none() {
|
||||
if self.has_role(db, "Student").await || self.has_role(db, "Schüler").await {
|
||||
if halfprice {
|
||||
fee.add("Schüler/Student (Halbpreis)".into(), STUDENT_OR_PUPIL / 2);
|
||||
} else {
|
||||
fee.add("Schüler/Student".into(), STUDENT_OR_PUPIL);
|
||||
}
|
||||
} 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 {
|
||||
fee.add("Mitgliedsbeitrag".into(), REGULAR);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
101
src/model/user/foerdernd.rs
Normal file
101
src/model/user/foerdernd.rs
Normal file
@ -0,0 +1,101 @@
|
||||
use super::{ManageUserUser, User, regular::ClubMember};
|
||||
use crate::{
|
||||
NonEmptyString,
|
||||
model::{activity::ActivityBuilder, mail::Mail, notification::Notification, role::Role},
|
||||
special_user,
|
||||
};
|
||||
use chrono::NaiveDate;
|
||||
use rocket::{async_trait, fs::TempFile};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
special_user!(FoerderndUser, +"Förderndes Mitglied");
|
||||
|
||||
impl ClubMember for FoerderndUser {}
|
||||
|
||||
impl FoerderndUser {
|
||||
pub(crate) async fn send_welcome_mail_to_user(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
smtp_pw: &str,
|
||||
) -> Result<(), String> {
|
||||
let Some(mail) = &self.mail else {
|
||||
return Err(format!(
|
||||
"Couldn't send welcome mail, as the user {self} has no mail..."
|
||||
));
|
||||
};
|
||||
|
||||
Mail::send_single(
|
||||
db,
|
||||
mail,
|
||||
"Willkommen im ASKÖ Ruderverein Donau Linz!",
|
||||
format!(
|
||||
"Hallo {0},
|
||||
|
||||
herzlich willkommen im ASKÖ Ruderverein Donau Linz! Wir freuen uns sehr, dich als neues Mitglied in unserem Verein begrüßen zu dürfen.
|
||||
|
||||
Um dir den Einstieg zu erleichtern, findest du in unserem Handbuch alle wichtigen Informationen über unseren Verein: https://rudernlinz.at/book. Bei weiteren Fragen stehen dir die Adressen info@rudernlinz.at (für allgemeine Fragen) und it@rudernlinz.at (bei technischen Fragen) jederzeit zur Verfügung.
|
||||
|
||||
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.
|
||||
|
||||
Riemen- & Dollenbruch
|
||||
ASKÖ Ruderverein Donau Linz", self.name),
|
||||
smtp_pw,
|
||||
).await?;
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"User {self} hat die Info-Mail bzgl. neues förderndes Mitglied (Handbuch und WLAN Infos) an {mail} gesendet bekommen"
|
||||
))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn create(
|
||||
db: &SqlitePool,
|
||||
created_by: &ManageUserUser,
|
||||
smtp_pw: &str,
|
||||
name: NonEmptyString,
|
||||
mail: &str,
|
||||
financial: Option<Role>,
|
||||
birthdate: &NaiveDate,
|
||||
member_since: &NaiveDate,
|
||||
phone: NonEmptyString,
|
||||
address: NonEmptyString,
|
||||
membership_pdf: &TempFile<'_>,
|
||||
) -> Result<(), String> {
|
||||
let role = Role::find_by_name(db, "Förderndes Mitglied").await.unwrap();
|
||||
let user = Self::create_member(
|
||||
db,
|
||||
created_by,
|
||||
&role,
|
||||
name,
|
||||
mail,
|
||||
financial,
|
||||
birthdate,
|
||||
member_since,
|
||||
phone,
|
||||
address,
|
||||
membership_pdf,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let user = Self::new(db, &user).await.unwrap();
|
||||
user.send_welcome_mail_to_user(db, smtp_pw).await?;
|
||||
|
||||
if let Some(vorstand) = Role::find_by_name(db, "Vorstand").await {
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
&vorstand,
|
||||
&format!("Lieber Vorstand, es gibt ein neues förderndes Mitglied: {user}"),
|
||||
"Neues unterstützendes Vereinsmitglied",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
54
src/model/user/member.rs
Normal file
54
src/model/user/member.rs
Normal file
@ -0,0 +1,54 @@
|
||||
use super::ScheckbuchUser;
|
||||
use crate::model::{
|
||||
logbook::{Logbook, LogbookWithBoatAndRowers},
|
||||
user::User,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub(crate) enum Member {
|
||||
SchnupperInterest(User),
|
||||
Schnupperant(User),
|
||||
Scheckbuch(Vec<LogbookWithBoatAndRowers>),
|
||||
Regular(User),
|
||||
Foerdernd(User),
|
||||
Unterstuetzend(User),
|
||||
}
|
||||
|
||||
impl Member {
|
||||
pub(crate) async fn from(db: &SqlitePool, user: User) -> Self {
|
||||
if ScheckbuchUser::new(db, &user).await.is_some() {
|
||||
Self::Scheckbuch(Logbook::completed_with_user(db, &user).await)
|
||||
} else if user.has_role(db, "schnupper-interessierte").await {
|
||||
Self::SchnupperInterest(user)
|
||||
} else if user.has_role(db, "schnupperant").await {
|
||||
Self::Schnupperant(user)
|
||||
} else if user.has_role(db, "Donau Linz").await {
|
||||
Self::Regular(user)
|
||||
} else if user.has_role(db, "Förderndes Mitglied").await {
|
||||
Self::Foerdernd(user)
|
||||
} else if user.has_role(db, "Unterstützend").await {
|
||||
Self::Unterstuetzend(user)
|
||||
} else {
|
||||
panic!("User {user} has no membership_type!!");
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn is_club_member(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Member::Regular(_) | Member::Foerdernd(_) | Member::Unterstuetzend(_)
|
||||
)
|
||||
}
|
||||
pub(crate) fn supposed_to_pay(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Member::Schnupperant(_)
|
||||
| Member::Scheckbuch(_)
|
||||
| Member::Regular(_)
|
||||
| Member::Foerdernd(_)
|
||||
| Member::Unterstuetzend(_)
|
||||
)
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
156
src/model/user/regular.rs
Normal file
156
src/model/user/regular.rs
Normal file
@ -0,0 +1,156 @@
|
||||
use super::{ManageUserUser, User};
|
||||
use crate::{
|
||||
NonEmptyString,
|
||||
model::{activity::ActivityBuilder, mail::Mail, notification::Notification, role::Role},
|
||||
special_user,
|
||||
};
|
||||
use chrono::NaiveDate;
|
||||
use rocket::{async_trait, fs::TempFile, tokio::io::AsyncReadExt};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
special_user!(RegularUser, +"Donau Linz");
|
||||
|
||||
pub trait ClubMember {
|
||||
async fn create_member(
|
||||
db: &SqlitePool,
|
||||
created_by: &ManageUserUser,
|
||||
role: &Role,
|
||||
name: NonEmptyString,
|
||||
mail: &str,
|
||||
financial: Option<Role>,
|
||||
birthdate: &NaiveDate,
|
||||
member_since: &NaiveDate,
|
||||
phone: NonEmptyString,
|
||||
address: NonEmptyString,
|
||||
membership_pdf: &TempFile<'_>,
|
||||
) -> Result<User, String> {
|
||||
if membership_pdf.len() == 0 {
|
||||
return Err("Keine Beitrittserklärung mitgeschickt.".to_string());
|
||||
}
|
||||
|
||||
let mut stream = membership_pdf.open().await.unwrap();
|
||||
let mut buffer = Vec::new();
|
||||
stream.read_to_end(&mut buffer).await.unwrap();
|
||||
|
||||
let name = name.as_str();
|
||||
let phone = phone.as_str();
|
||||
let address = address.as_str();
|
||||
|
||||
sqlx::query!(
|
||||
"INSERT INTO user(name, member_since_date, birthdate, mail, phone, address, membership_pdf)
|
||||
VALUES (?,?,?,?,?,?,?)",
|
||||
name, member_since, birthdate, mail, phone, address,buffer
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
let user = User::find_by_name(db, name).await.unwrap();
|
||||
user.change_financial(db, created_by, financial).await?;
|
||||
user.add_role(db, created_by, role).await?;
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{created_by} hat Mitglied {user} mit der Rolle {role} angelegt."
|
||||
))
|
||||
.user(&user)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(user)
|
||||
}
|
||||
}
|
||||
|
||||
impl ClubMember for RegularUser {}
|
||||
|
||||
impl RegularUser {
|
||||
pub(crate) async fn send_welcome_mail_to_user(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
smtp_pw: &str,
|
||||
) -> Result<(), String> {
|
||||
let Some(mail) = &self.mail else {
|
||||
return Err(format!(
|
||||
"Couldn't send welcome mail, as the user {self} has no mail..."
|
||||
));
|
||||
};
|
||||
|
||||
Mail::send_single(
|
||||
db,
|
||||
mail,
|
||||
"Willkommen im ASKÖ Ruderverein Donau Linz!",
|
||||
format!(
|
||||
"Hallo {0},
|
||||
|
||||
herzlich willkommen im ASKÖ Ruderverein Donau Linz! Wir freuen uns sehr, dich als neues Mitglied in unserem Verein begrüßen zu dürfen.
|
||||
|
||||
Um dir den Einstieg zu erleichtern, findest du in unserem Handbuch alle wichtigen Informationen über unseren Verein: https://rudernlinz.at/book. Bei weiteren Fragen stehen dir die Adressen info@rudernlinz.at (für allgemeine Fragen) und it@rudernlinz.at (bei technischen Fragen) jederzeit zur Verfügung.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
Wir freuen uns darauf, dich bald am Wasser zu sehen und gemeinsam tolle Erfahrungen zu sammeln!
|
||||
|
||||
Riemen- & Dollenbruch
|
||||
ASKÖ Ruderverein Donau Linz", self.name),
|
||||
smtp_pw,
|
||||
).await?;
|
||||
|
||||
ActivityBuilder::new(&format!("Willkommensmail für {self} wurde an {mail} verschickt (Handbuch, Signal-Gruppe, App-Info, Fingerprint, WLAN)."))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn create(
|
||||
db: &SqlitePool,
|
||||
created_by: &ManageUserUser,
|
||||
smtp_pw: &str,
|
||||
name: NonEmptyString,
|
||||
mail: &str,
|
||||
financial: Option<Role>,
|
||||
birthdate: &NaiveDate,
|
||||
member_since: &NaiveDate,
|
||||
phone: NonEmptyString,
|
||||
address: NonEmptyString,
|
||||
membership_pdf: &TempFile<'_>,
|
||||
) -> Result<(), String> {
|
||||
let role = Role::find_by_name(db, "Donau Linz").await.unwrap();
|
||||
let user = Self::create_member(
|
||||
db,
|
||||
created_by,
|
||||
&role,
|
||||
name,
|
||||
mail,
|
||||
financial,
|
||||
birthdate,
|
||||
member_since,
|
||||
phone,
|
||||
address,
|
||||
membership_pdf,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let user = Self::new(db, &user).await.unwrap();
|
||||
user.send_welcome_mail_to_user(db, smtp_pw).await?;
|
||||
|
||||
Notification::create_for_steering_people(
|
||||
db,
|
||||
&format!("Liebe Steuerberechtigte, es gibt ein neues Mitglied: {user} 🎉"),
|
||||
"Neues Vereinsmitglied",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
304
src/model/user/scheckbuch.rs
Normal file
304
src/model/user/scheckbuch.rs
Normal file
@ -0,0 +1,304 @@
|
||||
use super::foerdernd::FoerderndUser;
|
||||
use super::regular::RegularUser;
|
||||
use super::unterstuetzend::UnterstuetzendUser;
|
||||
use super::{ManageUserUser, User};
|
||||
use crate::NonEmptyString;
|
||||
use crate::model::activity::ActivityBuilder;
|
||||
use crate::model::role::Role;
|
||||
use crate::{
|
||||
SCHECKBUCH,
|
||||
model::{mail::Mail, notification::Notification},
|
||||
special_user,
|
||||
};
|
||||
use chrono::NaiveDate;
|
||||
use rocket::async_trait;
|
||||
use rocket::fs::TempFile;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
special_user!(ScheckbuchUser, +"scheckbuch");
|
||||
|
||||
impl ScheckbuchUser {
|
||||
async fn set_data_for_clubmember(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
changed_by: &ManageUserUser,
|
||||
member_since: &NaiveDate,
|
||||
birthdate: &NaiveDate,
|
||||
phone: NonEmptyString,
|
||||
address: NonEmptyString,
|
||||
membership_pdf: &TempFile<'_>,
|
||||
) -> Result<(), String> {
|
||||
self.user.update_birthdate(db, changed_by, birthdate).await;
|
||||
self.user
|
||||
.update_member_since(db, changed_by, member_since)
|
||||
.await;
|
||||
|
||||
self.user.update_phone(db, changed_by, &phone).await;
|
||||
self.user.update_address(db, changed_by, &address).await;
|
||||
self.user
|
||||
.add_membership_pdf(db, changed_by, membership_pdf)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
pub(crate) async fn convert_to_regular_user(
|
||||
self,
|
||||
db: &SqlitePool,
|
||||
smtp_pw: &str,
|
||||
changed_by: &ManageUserUser,
|
||||
member_since: &NaiveDate,
|
||||
birthdate: &NaiveDate,
|
||||
phone: NonEmptyString,
|
||||
address: NonEmptyString,
|
||||
membership_pdf: &TempFile<'_>,
|
||||
) -> Result<(), String> {
|
||||
self.set_data_for_clubmember(
|
||||
db,
|
||||
changed_by,
|
||||
member_since,
|
||||
birthdate,
|
||||
phone,
|
||||
address,
|
||||
membership_pdf,
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Change roles
|
||||
let regular = Role::find_by_name(db, "Donau Linz").await.unwrap();
|
||||
let scheckbook = Role::find_by_name(db, "scheckbuch").await.unwrap();
|
||||
self.user.remove_role(db, changed_by, &scheckbook).await?;
|
||||
self.user.add_role(db, changed_by, ®ular).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, {} hatte ein Scheckbuch und ist nun seit {} ein neues reguläres Mitglied. 🎉",
|
||||
self.name,
|
||||
member_since
|
||||
),
|
||||
"Neues Vereinsmitglied",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{changed_by} hat den Scheckbuch-User {self} auf ein reguläres Mitglied upgegraded! Die Steuerpersonen wurden via Notification informiert."
|
||||
))
|
||||
.user(&self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn convert_to_unterstuetzend_user(
|
||||
self,
|
||||
db: &SqlitePool,
|
||||
smtp_pw: &str,
|
||||
changed_by: &ManageUserUser,
|
||||
member_since: &NaiveDate,
|
||||
birthdate: &NaiveDate,
|
||||
phone: NonEmptyString,
|
||||
address: NonEmptyString,
|
||||
membership_pdf: &TempFile<'_>,
|
||||
) -> Result<(), String> {
|
||||
// Set data
|
||||
self.set_data_for_clubmember(
|
||||
db,
|
||||
changed_by,
|
||||
member_since,
|
||||
birthdate,
|
||||
phone,
|
||||
address,
|
||||
membership_pdf,
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Change roles
|
||||
let unterstuetzend = Role::find_by_name(db, "Unterstützend").await.unwrap();
|
||||
let scheckbook = Role::find_by_name(db, "scheckbuch").await.unwrap();
|
||||
self.user.remove_role(db, changed_by, &scheckbook).await?;
|
||||
self.user.add_role(db, changed_by, &unterstuetzend).await?;
|
||||
|
||||
let unterstuetzend = UnterstuetzendUser::new(db, &self.user).await.unwrap();
|
||||
unterstuetzend
|
||||
.send_welcome_mail_to_user(db, smtp_pw)
|
||||
.await?;
|
||||
if let Some(vorstand) = Role::find_by_name(db, "vorstand").await {
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
&vorstand,
|
||||
&format!(
|
||||
"Lieber Vorstand, {} hatte ein Scheckbuch und ist nun seit {} ein neues unterstützendes Mitglied.",
|
||||
self.name,
|
||||
member_since
|
||||
),
|
||||
"Neues unterstützendes Vereinsmitglied",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
ActivityBuilder::new(&format!("{changed_by} hat den Scheckbuch-User {self} auf ein unterstützendes Mitglied upgegraded!"))
|
||||
.user(&self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn convert_to_foerdernd_user(
|
||||
self,
|
||||
db: &SqlitePool,
|
||||
smtp_pw: &str,
|
||||
changed_by: &ManageUserUser,
|
||||
member_since: &NaiveDate,
|
||||
birthdate: &NaiveDate,
|
||||
phone: NonEmptyString,
|
||||
address: NonEmptyString,
|
||||
membership_pdf: &TempFile<'_>,
|
||||
) -> Result<(), String> {
|
||||
// Set data
|
||||
self.set_data_for_clubmember(
|
||||
db,
|
||||
changed_by,
|
||||
member_since,
|
||||
birthdate,
|
||||
phone,
|
||||
address,
|
||||
membership_pdf,
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Change roles
|
||||
let unterstuetzend = Role::find_by_name(db, "Förderndes Mitglied").await.unwrap();
|
||||
let scheckbook = Role::find_by_name(db, "scheckbuch").await.unwrap();
|
||||
self.user.remove_role(db, changed_by, &scheckbook).await?;
|
||||
self.user.add_role(db, changed_by, &unterstuetzend).await?;
|
||||
|
||||
let foerdernd = FoerderndUser::new(db, &self.user).await.unwrap();
|
||||
foerdernd.send_welcome_mail_to_user(db, smtp_pw).await?;
|
||||
if let Some(vorstand) = Role::find_by_name(db, "vorstand").await {
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
&vorstand,
|
||||
&format!(
|
||||
"Lieber Vorstand, {} hatte ein Scheckbuch und ist nun seit {} ein neues förderndes Mitglied.",
|
||||
self.name,
|
||||
member_since
|
||||
),
|
||||
"Neues förderndes Vereinsmitglied",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
ActivityBuilder::new(&format!(
|
||||
"{changed_by} hat den Scheckbuch-User {self} auf ein förderndes Mitglied upgegraded!"
|
||||
))
|
||||
.user(&self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// 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.send_welcome_mail_to_user(db, smtp_pw).await?;
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{self} hat eine Info-Mail bekommen (Erklärung Scheckbuch, Ruderapp) und alle Steuerberechtigten wurden informiert."
|
||||
))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn send_welcome_mail_to_user(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
smtp_pw: &str,
|
||||
) -> Result<(), String> {
|
||||
let Some(mail) = &self.mail else {
|
||||
return Err(
|
||||
"Kann Mail nicht versenden, weil der User keine Mailadresse hinterlegt hat.".into(),
|
||||
);
|
||||
};
|
||||
Mail::send_single(
|
||||
db,
|
||||
mail,
|
||||
"ASKÖ Ruderverein Donau Linz | Dein Scheckbuch wartet auf Dich",
|
||||
format!(
|
||||
"Hallo {0},
|
||||
|
||||
herzlich willkommen beim ASKÖ Ruderverein Donau Linz! Wir freuen uns sehr, dass Du Dich entschieden hast, das Rudern bei uns auszuprobieren. Mit Deinem Scheckbuch kannst Du jetzt an fünf Ausfahrten teilnehmen und so diesen Sport in seiner vollen Vielfalt erleben. Falls du die {1} € noch nicht bezahlt hast, nimm diese bitte zur nächsten Ausfahrt mit (oder überweise sie auf unser Bankkonto [dieses findest du auf https://rudernlinz.at]).
|
||||
|
||||
Für die Organisation unserer Ausfahrten nutzen wir app.rudernlinz.at. Logge Dich bitte mit Deinem Namen ('{0}', ohne Anführungszeichen) ein. Beim ersten Mal kannst Du das Passwortfeld leer lassen. Unter 'Geplante Ausfahrten' kannst Du Dich jederzeit für eine Ausfahrt anmelden. Wir bieten mindestens einmal pro Woche Ausfahrten an, sowohl für Anfänger als auch für Fortgeschrittene (A+F Rudern). Zusätzliche Ausfahrten werden von unseren Steuerleuten ausgeschrieben, öfters reinschauen kann sich also lohnen :-)
|
||||
|
||||
Nach deinen 5 Ausfahrten würden wir uns freuen, dich als Mitglied in unserem Verein begrüßen zu dürfen.
|
||||
|
||||
Wir freuen uns darauf, Dich bald am Wasser zu sehen und gemeinsam tolle Erfahrungen zu sammeln!
|
||||
|
||||
Riemen- & Dollenbruch,
|
||||
ASKÖ Ruderverein Donau Linz", self.name, SCHECKBUCH/100),
|
||||
smtp_pw,
|
||||
).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn notify_coxes_about_new_scheckbuch(&self, db: &SqlitePool) {
|
||||
Notification::create_for_steering_people(
|
||||
db,
|
||||
&format!(
|
||||
"Liebe Steuerberechtigte, {} hat nun ein Scheckbuch. Wie immer, freuen wir uns wenn du uns beim A+F Rudern unterstützt oder selber Ausfahrten ausschreibst. Bitte beachte, dass Scheckbuch-Personen nur Ausfahrten sehen, bei denen 'Scheckbuch-Anmeldungen erlauben' ausgewählt wurde.",
|
||||
self.name
|
||||
),
|
||||
"Neues Scheckbuch",
|
||||
None,None
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
pub(crate) async fn create(
|
||||
db: &SqlitePool,
|
||||
created_by: &ManageUserUser,
|
||||
smtp_pw: &str,
|
||||
name: NonEmptyString,
|
||||
mail: &str,
|
||||
) -> Result<(), String> {
|
||||
let role = Role::find_by_name(db, "scheckbuch").await.unwrap();
|
||||
|
||||
let name = name.as_str();
|
||||
sqlx::query!(
|
||||
"INSERT INTO user(name, mail)
|
||||
VALUES (?,?)",
|
||||
name,
|
||||
mail
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
let user = User::find_by_name(db, name).await.unwrap();
|
||||
user.add_role(db, created_by, &role).await?;
|
||||
|
||||
let user = Self::new(db, &user).await.unwrap();
|
||||
user.notify(db, smtp_pw).await?;
|
||||
|
||||
ActivityBuilder::new(&format!("{created_by} hat Scheckbuch {user} angelegt."))
|
||||
.user(&user)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
432
src/model/user/schnupperant.rs
Normal file
432
src/model/user/schnupperant.rs
Normal file
@ -0,0 +1,432 @@
|
||||
use super::foerdernd::FoerderndUser;
|
||||
use super::regular::RegularUser;
|
||||
use super::scheckbuch::ScheckbuchUser;
|
||||
use super::schnupperinterest::SchnupperInterestUser;
|
||||
use super::unterstuetzend::UnterstuetzendUser;
|
||||
use super::{ManageUserUser, User};
|
||||
use crate::NonEmptyString;
|
||||
use crate::model::activity::ActivityBuilder;
|
||||
use crate::model::role::Role;
|
||||
use crate::{
|
||||
model::{mail::Mail, notification::Notification},
|
||||
special_user,
|
||||
};
|
||||
use chrono::NaiveDate;
|
||||
use rocket::async_trait;
|
||||
use rocket::fs::TempFile;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
special_user!(SchnupperantUser, +"schnupperant");
|
||||
|
||||
impl SchnupperantUser {
|
||||
async fn set_data_for_clubmember(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
changed_by: &ManageUserUser,
|
||||
member_since: &NaiveDate,
|
||||
birthdate: &NaiveDate,
|
||||
phone: NonEmptyString,
|
||||
address: NonEmptyString,
|
||||
membership_pdf: &TempFile<'_>,
|
||||
) -> Result<(), String> {
|
||||
self.user.update_birthdate(db, changed_by, birthdate).await;
|
||||
self.user
|
||||
.update_member_since(db, changed_by, member_since)
|
||||
.await;
|
||||
|
||||
self.user.update_phone(db, changed_by, &phone).await;
|
||||
self.user.update_address(db, changed_by, &address).await;
|
||||
self.user
|
||||
.add_membership_pdf(db, changed_by, membership_pdf)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
pub(crate) async fn convert_to_regular_user(
|
||||
self,
|
||||
db: &SqlitePool,
|
||||
smtp_pw: &str,
|
||||
changed_by: &ManageUserUser,
|
||||
member_since: &NaiveDate,
|
||||
birthdate: &NaiveDate,
|
||||
phone: NonEmptyString,
|
||||
address: NonEmptyString,
|
||||
membership_pdf: &TempFile<'_>,
|
||||
) -> Result<(), String> {
|
||||
self.set_data_for_clubmember(
|
||||
db,
|
||||
changed_by,
|
||||
member_since,
|
||||
birthdate,
|
||||
phone,
|
||||
address,
|
||||
membership_pdf,
|
||||
)
|
||||
.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 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 {member_since} ein neues reguläres Mitglied. 🎉",
|
||||
self.name
|
||||
),
|
||||
"Neues Vereinsmitglied",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{changed_by} hat den Schnupperant {self} auf ein reguläres Mitglied upgegraded!"
|
||||
))
|
||||
.user(&self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn move_to_scheckbook(
|
||||
self,
|
||||
db: &SqlitePool,
|
||||
changed_by: &ManageUserUser,
|
||||
smtp_pw: &str,
|
||||
) -> Result<(), String> {
|
||||
let schnupperant = Role::find_by_name(db, "schnupperant").await.unwrap();
|
||||
let scheckbook = Role::find_by_name(db, "scheckbuch").await.unwrap();
|
||||
self.user.remove_role(db, changed_by, &schnupperant).await?;
|
||||
self.user.add_role(db, changed_by, &scheckbook).await?;
|
||||
|
||||
if let Some(no_einschreibgebuehr) = Role::find_by_name(db, "no-einschreibgebuehr").await {
|
||||
self.add_role(db, changed_by, &no_einschreibgebuehr)
|
||||
.await
|
||||
.expect("role doesn't have a group");
|
||||
}
|
||||
|
||||
let scheckbook = ScheckbuchUser::new(db, &self.user).await.unwrap();
|
||||
scheckbook.notify(db, smtp_pw).await?;
|
||||
|
||||
Notification::create_for_steering_people(
|
||||
db,
|
||||
&format!(
|
||||
"Liebe Steuerberechtigte, {} hat unseren Schnupperkurs absolviert und nun ein Scheckbuch. Wie immer, freuen wir uns wenn du uns beim A+F Rudern unterstützt oder selber Ausfahrten ausschreibst. Bitte beachte, dass Scheckbuch-Personen nur Ausfahrten sehen, bei denen 'Scheckbuch-Anmeldungen erlauben' ausgewählt wurde.",
|
||||
self.name
|
||||
),
|
||||
"Neues Scheckbuch",
|
||||
None,None
|
||||
)
|
||||
.await;
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{changed_by} hat dem ehemaligen Schnupperant {self} nun ein Scheckbuch gegeben"
|
||||
))
|
||||
.user(&self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn move_to_schnupperinterest(
|
||||
self,
|
||||
db: &SqlitePool,
|
||||
changed_by: &ManageUserUser,
|
||||
) -> Result<(), String> {
|
||||
let schnupperinterest = Role::find_by_name(db, "schnupper-interessierte")
|
||||
.await
|
||||
.unwrap();
|
||||
let schnupperant = Role::find_by_name(db, "schnupperant").await.unwrap();
|
||||
self.user.remove_role(db, changed_by, &schnupperant).await?;
|
||||
self.user
|
||||
.add_role(db, changed_by, &schnupperinterest)
|
||||
.await?;
|
||||
|
||||
let schnupperinterest = SchnupperInterestUser::new(db, &self.user).await.unwrap();
|
||||
schnupperinterest.notify(db).await?;
|
||||
|
||||
if let Some(role) = Role::find_by_name(db, "schnupper-betreuer").await {
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
&role,
|
||||
&format!(
|
||||
"Lieber Schnupperbetreuer, {} hat sich vom Schnupperkurs abgemeldet.",
|
||||
self.name
|
||||
),
|
||||
"Schnupperkurs Abmeldung",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{changed_by} hat dem eigentlichen Schnupperanten {self} wieder auf die 'Interessierten'-Liste zurückgegeben."
|
||||
))
|
||||
.user(&self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn convert_to_unterstuetzend_user(
|
||||
self,
|
||||
db: &SqlitePool,
|
||||
smtp_pw: &str,
|
||||
changed_by: &ManageUserUser,
|
||||
member_since: &NaiveDate,
|
||||
birthdate: &NaiveDate,
|
||||
phone: NonEmptyString,
|
||||
address: NonEmptyString,
|
||||
membership_pdf: &TempFile<'_>,
|
||||
) -> Result<(), String> {
|
||||
// Set data
|
||||
self.set_data_for_clubmember(
|
||||
db,
|
||||
changed_by,
|
||||
member_since,
|
||||
birthdate,
|
||||
phone,
|
||||
address,
|
||||
membership_pdf,
|
||||
)
|
||||
.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?;
|
||||
self.user.add_role(db, changed_by, &unterstuetzend).await?;
|
||||
if let Some(no_einschreibgebuehr) = Role::find_by_name(db, "no-einschreibgebuehr").await {
|
||||
self.add_role(db, changed_by, &no_einschreibgebuehr)
|
||||
.await
|
||||
.expect("role doesn't have a group");
|
||||
}
|
||||
|
||||
let unterstuetzend = UnterstuetzendUser::new(db, &self.user).await.unwrap();
|
||||
unterstuetzend
|
||||
.send_welcome_mail_to_user(db, smtp_pw)
|
||||
.await?;
|
||||
if let Some(vorstand) = Role::find_by_name(db, "vorstand").await {
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
&vorstand,
|
||||
&format!(
|
||||
"Lieber Vorstand, {} nahm am Schnupperkurs teil und ist nun seit {} es ein neues unterstützendes Mitglied.",
|
||||
self.name,
|
||||
self.member_since_date.clone().unwrap()
|
||||
),
|
||||
"Neues unterstützendes Vereinsmitglied",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{changed_by} hat den Schnupperant {self} auf ein unterstützendes Mitglied upgegraded!"
|
||||
))
|
||||
.user(&self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn convert_to_foerdernd_user(
|
||||
self,
|
||||
db: &SqlitePool,
|
||||
smtp_pw: &str,
|
||||
changed_by: &ManageUserUser,
|
||||
member_since: &NaiveDate,
|
||||
birthdate: &NaiveDate,
|
||||
phone: NonEmptyString,
|
||||
address: NonEmptyString,
|
||||
membership_pdf: &TempFile<'_>,
|
||||
) -> Result<(), String> {
|
||||
// Set data
|
||||
self.set_data_for_clubmember(
|
||||
db,
|
||||
changed_by,
|
||||
member_since,
|
||||
birthdate,
|
||||
phone,
|
||||
address,
|
||||
membership_pdf,
|
||||
)
|
||||
.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?;
|
||||
self.user.add_role(db, changed_by, &unterstuetzend).await?;
|
||||
if let Some(no_einschreibgebuehr) = Role::find_by_name(db, "no-einschreibgebuehr").await {
|
||||
self.add_role(db, changed_by, &no_einschreibgebuehr)
|
||||
.await
|
||||
.expect("role doesn't have a group");
|
||||
}
|
||||
|
||||
let foerdernd = FoerderndUser::new(db, &self.user).await.unwrap();
|
||||
foerdernd.send_welcome_mail_to_user(db, smtp_pw).await?;
|
||||
if let Some(vorstand) = Role::find_by_name(db, "vorstand").await {
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
&vorstand,
|
||||
&format!(
|
||||
"Lieber Vorstand, {} nahm am Schnupperkurs teil und ist nun seit {} es ein neues förderndes Mitglied.",
|
||||
self.name,
|
||||
self.member_since_date.clone().unwrap()
|
||||
),
|
||||
"Neues förderndes Vereinsmitglied",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{changed_by} hat den Schnupperant {self} auf ein förderndes Mitglied upgegraded!"
|
||||
))
|
||||
.user(&self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// TODO: make private
|
||||
pub(crate) async fn notify(&self, db: &SqlitePool, smtp_pw: &str) -> Result<(), String> {
|
||||
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."
|
||||
))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn send_welcome_mail_to_user(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
smtp_pw: &str,
|
||||
) -> Result<(), String> {
|
||||
let Some(mail) = &self.mail else {
|
||||
return Err(format!(
|
||||
"Couldn't send mail, because user {self} has no mail"
|
||||
));
|
||||
};
|
||||
Mail::send_single(
|
||||
db,
|
||||
mail,
|
||||
"ASKÖ Ruderverein Donau Linz | Anmeldung Schnupperkurs",
|
||||
format!(
|
||||
"Hallo {0},
|
||||
|
||||
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,
|
||||
self.fee(db).await.unwrap().sum_in_cents/100
|
||||
),
|
||||
smtp_pw,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
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,
|
||||
&role,
|
||||
&format!(
|
||||
"Lieber Schnupperbetreuer, {} hat sich zum Schnupperkurs angemeldet.",
|
||||
self.name
|
||||
),
|
||||
"Neuer Schnupperant",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn create(
|
||||
db: &SqlitePool,
|
||||
created_by: &ManageUserUser,
|
||||
smtp_pw: &str,
|
||||
name: NonEmptyString,
|
||||
mail: &str,
|
||||
) -> Result<(), String> {
|
||||
let role = Role::find_by_name(db, "schnupperant").await.unwrap();
|
||||
|
||||
let name = name.as_str();
|
||||
sqlx::query!(
|
||||
"INSERT INTO user(name, mail)
|
||||
VALUES (?,?)",
|
||||
name,
|
||||
mail
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
let user = User::find_by_name(db, name).await.unwrap();
|
||||
user.add_role(db, created_by, &role).await?;
|
||||
|
||||
let user = Self::new(db, &user).await.unwrap();
|
||||
user.notify(db, smtp_pw).await?;
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{created_by} hat {user} zur fixen Schnupperkurs-Anmeldung hinzugefügt."
|
||||
))
|
||||
.user(&user)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
162
src/model/user/schnupperinterest.rs
Normal file
162
src/model/user/schnupperinterest.rs
Normal file
@ -0,0 +1,162 @@
|
||||
use super::scheckbuch::ScheckbuchUser;
|
||||
use super::schnupperant::SchnupperantUser;
|
||||
use super::{ManageUserUser, User};
|
||||
use crate::NonEmptyString;
|
||||
use crate::model::activity::ActivityBuilder;
|
||||
use crate::model::role::Role;
|
||||
use crate::{model::notification::Notification, special_user};
|
||||
use rocket::async_trait;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
special_user!(SchnupperInterestUser, +"schnupper-interessierte");
|
||||
|
||||
impl SchnupperInterestUser {
|
||||
pub(crate) async fn move_to_scheckbook(
|
||||
self,
|
||||
db: &SqlitePool,
|
||||
changed_by: &ManageUserUser,
|
||||
smtp_pw: &str,
|
||||
) -> Result<(), String> {
|
||||
let schnupperinterest = Role::find_by_name(db, "schnupper-interessierte")
|
||||
.await
|
||||
.unwrap();
|
||||
let scheckbook = Role::find_by_name(db, "scheckbuch").await.unwrap();
|
||||
self.user
|
||||
.remove_role(db, changed_by, &schnupperinterest)
|
||||
.await?;
|
||||
self.user.add_role(db, changed_by, &scheckbook).await?;
|
||||
|
||||
let scheckbook = ScheckbuchUser::new(db, &self.user).await.unwrap();
|
||||
scheckbook.notify(db, smtp_pw).await?;
|
||||
|
||||
Notification::create_for_steering_people(
|
||||
db,
|
||||
&format!(
|
||||
"Liebe Steuerberechtigte, {} wollte unseren Schnupperkurs absolviert und nun ein Scheckbuch. Wie immer, freuen wir uns wenn du uns beim A+F Rudern unterstützt oder selber Ausfahrten ausschreibst. Bitte beachte, dass Scheckbuch-Personen nur Ausfahrten sehen, bei denen 'Scheckbuch-Anmeldungen erlauben' ausgewählt wurde.",
|
||||
self.name
|
||||
),
|
||||
"Neues Scheckbuch",
|
||||
None,
|
||||
None
|
||||
)
|
||||
.await;
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"Der Schnupperinteressierte {self} hat sich (ohne Schnupperkurs) doch gleich direkt für ein Scheckbuch entschieden. {changed_by} hat dieses eingerichtet."
|
||||
))
|
||||
.user(&self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn move_to_schnupperant(
|
||||
self,
|
||||
db: &SqlitePool,
|
||||
changed_by: &ManageUserUser,
|
||||
smtp_pw: &str,
|
||||
) -> Result<(), String> {
|
||||
let schnupperinterest = Role::find_by_name(db, "schnupper-interessierte")
|
||||
.await
|
||||
.unwrap();
|
||||
let schnupperant = Role::find_by_name(db, "schnupperant").await.unwrap();
|
||||
self.user
|
||||
.remove_role(db, changed_by, &schnupperinterest)
|
||||
.await?;
|
||||
self.user.add_role(db, changed_by, &schnupperant).await?;
|
||||
|
||||
let schnupperant = SchnupperantUser::new(db, &self.user).await.unwrap();
|
||||
schnupperant.notify(db, smtp_pw).await?;
|
||||
|
||||
if let Some(role) = Role::find_by_name(db, "schnupper-betreuer").await {
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
&role,
|
||||
&format!(
|
||||
"Lieber Schnupperbetreuer, {} hat sich zum Schnupperkurs angemeldet.",
|
||||
self.name
|
||||
),
|
||||
"Neuer Schnupper-Interessierte:r",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
ActivityBuilder::new(&format!(
|
||||
"Der Schnupperinteressierte {self} hat sich zum Schnupperkurs angemeldet."
|
||||
))
|
||||
.user(&self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn notify(&self, db: &SqlitePool) -> Result<(), String> {
|
||||
self.notify_schnupperbetreuer_about_new_interest(db).await;
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"Der Schnupperbetreuer hat eine Info via Notification bekommen, dass {self} Interesse an einen Schnupperkurs hat."
|
||||
))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn notify_schnupperbetreuer_about_new_interest(&self, db: &SqlitePool) {
|
||||
if let Some(role) = Role::find_by_name(db, "schnupper-betreuer").await {
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
&role,
|
||||
&format!(
|
||||
"Lieber Schnupperbetreuer, {} hat Interesse zum Schnupperkurs bekundet.",
|
||||
self.name
|
||||
),
|
||||
"Neuer Schnupper-Interessierte:r",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn create(
|
||||
db: &SqlitePool,
|
||||
created_by: &ManageUserUser,
|
||||
name: NonEmptyString,
|
||||
mail: &str,
|
||||
) -> Result<(), String> {
|
||||
let role = Role::find_by_name(db, "schnupper-interessierte")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let name = name.as_str();
|
||||
sqlx::query!(
|
||||
"INSERT INTO user(name, mail)
|
||||
VALUES (?,?)",
|
||||
name,
|
||||
mail
|
||||
)
|
||||
.execute(db)
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
let user = User::find_by_name(db, name).await.unwrap();
|
||||
user.add_role(db, created_by, &role).await?;
|
||||
|
||||
let user = Self::new(db, &user).await.unwrap();
|
||||
user.notify(db).await?;
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{created_by} hat Schnupper-Interessierten {user} angelegt."
|
||||
))
|
||||
.user(&user)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
101
src/model/user/unterstuetzend.rs
Normal file
101
src/model/user/unterstuetzend.rs
Normal file
@ -0,0 +1,101 @@
|
||||
use super::{ManageUserUser, User, regular::ClubMember};
|
||||
use crate::{
|
||||
NonEmptyString,
|
||||
model::{activity::ActivityBuilder, mail::Mail, notification::Notification, role::Role},
|
||||
special_user,
|
||||
};
|
||||
use chrono::NaiveDate;
|
||||
use rocket::{async_trait, fs::TempFile};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
special_user!(UnterstuetzendUser, +"Unterstützend");
|
||||
|
||||
impl ClubMember for UnterstuetzendUser {}
|
||||
|
||||
impl UnterstuetzendUser {
|
||||
pub(crate) async fn send_welcome_mail_to_user(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
smtp_pw: &str,
|
||||
) -> Result<(), String> {
|
||||
let Some(mail) = &self.mail else {
|
||||
return Err(format!(
|
||||
"Couldn't send welcome mail, as the user {self} has no mail..."
|
||||
));
|
||||
};
|
||||
|
||||
Mail::send_single(
|
||||
db,
|
||||
mail,
|
||||
"Willkommen im ASKÖ Ruderverein Donau Linz!",
|
||||
format!(
|
||||
"Hallo {0},
|
||||
|
||||
herzlich willkommen im ASKÖ Ruderverein Donau Linz! Wir freuen uns sehr, dich als neues Mitglied in unserem Verein begrüßen zu dürfen.
|
||||
|
||||
Um dir den Einstieg zu erleichtern, findest du in unserem Handbuch alle wichtigen Informationen über unseren Verein: https://rudernlinz.at/book. Bei weiteren Fragen stehen dir die Adressen info@rudernlinz.at (für allgemeine Fragen) und it@rudernlinz.at (bei technischen Fragen) jederzeit zur Verfügung.
|
||||
|
||||
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.
|
||||
|
||||
Riemen- & Dollenbruch
|
||||
ASKÖ Ruderverein Donau Linz", self.name),
|
||||
smtp_pw,
|
||||
).await?;
|
||||
|
||||
ActivityBuilder::new(&format!(
|
||||
"{self} hat eine Mail an {mail} bekommen, mit Infos dass er/sie nun ein unterstützendes Mitglied ist (Handbuch, WLAN)."
|
||||
))
|
||||
.user(self)
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn create(
|
||||
db: &SqlitePool,
|
||||
created_by: &ManageUserUser,
|
||||
smtp_pw: &str,
|
||||
name: NonEmptyString,
|
||||
mail: &str,
|
||||
financial: Option<Role>,
|
||||
birthdate: &NaiveDate,
|
||||
member_since: &NaiveDate,
|
||||
phone: NonEmptyString,
|
||||
address: NonEmptyString,
|
||||
membership_pdf: &TempFile<'_>,
|
||||
) -> Result<(), String> {
|
||||
let role = Role::find_by_name(db, "Unterstützend").await.unwrap();
|
||||
let user = Self::create_member(
|
||||
db,
|
||||
created_by,
|
||||
&role,
|
||||
name,
|
||||
mail,
|
||||
financial,
|
||||
birthdate,
|
||||
member_since,
|
||||
phone,
|
||||
address,
|
||||
membership_pdf,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let user = Self::new(db, &user).await.unwrap();
|
||||
user.send_welcome_mail_to_user(db, smtp_pw).await?;
|
||||
|
||||
if let Some(vorstand) = Role::find_by_name(db, "Vorstand").await {
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
&vorstand,
|
||||
&format!("Lieber Vorstand, es gibt ein neues unterstützendes Mitglied: {user}"),
|
||||
"Neues unterstützendes Vereinsmitglied",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
use rocket::{form::Form, post, routes, Build, FromForm, Rocket, State};
|
||||
use rocket::{Build, FromForm, Rocket, State, form::Form, post, routes};
|
||||
use serde_json::json;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
|
@ -96,7 +96,9 @@ struct DailyWeather {
|
||||
}
|
||||
|
||||
fn fetch(api_key: &str) -> Result<Data, String> {
|
||||
let url = format!("https://api.openweathermap.org/data/3.0/onecall?lat=48.31970&lon=14.29451&units=metric&exclude=current,minutely,hourly,alert&appid={api_key}");
|
||||
let url = format!(
|
||||
"https://api.openweathermap.org/data/3.0/onecall?lat=48.31970&lon=14.29451&units=metric&exclude=current,minutely,hourly,alert&appid={api_key}"
|
||||
);
|
||||
|
||||
match ureq::get(&url).call() {
|
||||
Ok(mut response) => {
|
||||
|
@ -5,13 +5,14 @@ use crate::model::{
|
||||
user::{User, UserWithDetails, VorstandUser},
|
||||
};
|
||||
use rocket::{
|
||||
Route, State,
|
||||
form::Form,
|
||||
get, post,
|
||||
request::FlashMessage,
|
||||
response::{Flash, Redirect},
|
||||
routes, Route, State,
|
||||
routes,
|
||||
};
|
||||
use rocket_dyn_templates::{tera::Context, Template};
|
||||
use rocket_dyn_templates::{Template, tera::Context};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[get("/boat")]
|
||||
@ -245,9 +246,11 @@ mod test {
|
||||
|
||||
let rocket = rocket::build().manage(db.clone());
|
||||
let rocket = crate::tera::config(rocket);
|
||||
assert!(Boat::find_by_name(&db, "completely-new-boat".into())
|
||||
.await
|
||||
.is_none());
|
||||
assert!(
|
||||
Boat::find_by_name(&db, "completely-new-boat".into())
|
||||
.await
|
||||
.is_none()
|
||||
);
|
||||
|
||||
let client = Client::tracked(rocket).await.unwrap();
|
||||
let login = client
|
||||
|
@ -1,15 +1,18 @@
|
||||
use rocket::{
|
||||
FromForm, Route, State,
|
||||
form::Form,
|
||||
get, post, put,
|
||||
response::{Flash, Redirect},
|
||||
routes, FromForm, Route, State,
|
||||
routes,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::{
|
||||
event::{self, Event},
|
||||
tripdetails::{TripDetails, TripDetailsToAdd},
|
||||
planned::{
|
||||
event::{self, Event},
|
||||
tripdetails::{TripDetails, TripDetailsToAdd},
|
||||
},
|
||||
user::EventUser,
|
||||
};
|
||||
|
||||
@ -32,8 +35,8 @@ async fn create(
|
||||
|
||||
let trip_details_id = TripDetails::create(db, data.tripdetails).await;
|
||||
let trip_details = TripDetails::find_by_id(db, trip_details_id).await.unwrap(); //Okay, bc. we
|
||||
//just created
|
||||
//the object
|
||||
//just created
|
||||
//the object
|
||||
|
||||
Event::create(
|
||||
db,
|
||||
@ -65,7 +68,7 @@ struct UpdateEventForm<'r> {
|
||||
async fn update(
|
||||
db: &State<SqlitePool>,
|
||||
data: Form<UpdateEventForm<'_>>,
|
||||
_admin: EventUser,
|
||||
user: EventUser,
|
||||
) -> Flash<Redirect> {
|
||||
let update = event::EventUpdate {
|
||||
name: data.name,
|
||||
@ -78,7 +81,7 @@ async fn update(
|
||||
};
|
||||
match Event::find_by_id(db, data.id).await {
|
||||
Some(planned_event) => {
|
||||
planned_event.update(db, &update).await;
|
||||
planned_event.update(db, &user, &update).await;
|
||||
Flash::success(Redirect::to("/planned"), "Event erfolgreich bearbeitet")
|
||||
}
|
||||
None => Flash::error(Redirect::to("/planned"), "Planned event id not found"),
|
||||
|
@ -1,9 +1,9 @@
|
||||
use rocket::form::Form;
|
||||
use rocket::fs::TempFile;
|
||||
use rocket::response::{Flash, Redirect};
|
||||
use rocket::{get, request::FlashMessage, routes, Route, State};
|
||||
use rocket::{post, FromForm};
|
||||
use rocket_dyn_templates::{tera::Context, Template};
|
||||
use rocket::{FromForm, post};
|
||||
use rocket::{Route, State, get, request::FlashMessage, routes};
|
||||
use rocket_dyn_templates::{Template, tera::Context};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::log::Log;
|
||||
|
@ -1,32 +1,21 @@
|
||||
use csv::ReaderBuilder;
|
||||
use rocket::{form::Form, get, post, routes, FromForm, Route, State};
|
||||
use rocket_dyn_templates::{context, Template};
|
||||
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;
|
||||
pub mod mail;
|
||||
pub mod notification;
|
||||
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")]
|
||||
@ -81,6 +70,7 @@ pub fn routes() -> Vec<Route> {
|
||||
ret.append(&mut notification::routes());
|
||||
ret.append(&mut mail::routes());
|
||||
ret.append(&mut event::routes());
|
||||
ret.append(&mut routes![rss, show_rss, show_list, list]);
|
||||
ret.append(&mut role::routes());
|
||||
ret.append(&mut routes![show_activities, show_list, list]);
|
||||
ret
|
||||
}
|
||||
|
@ -6,13 +6,14 @@ use crate::model::{
|
||||
};
|
||||
use itertools::Itertools;
|
||||
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("/notification")]
|
||||
|
65
src/tera/admin/role.rs
Normal file
65
src/tera/admin/role.rs
Normal file
@ -0,0 +1,65 @@
|
||||
use crate::model::{
|
||||
role::Role,
|
||||
user::{AdminUser, UserWithDetails, VorstandUser},
|
||||
};
|
||||
use rocket::{
|
||||
FromForm, Route, State,
|
||||
form::Form,
|
||||
get, post,
|
||||
request::FlashMessage,
|
||||
response::{Flash, Redirect},
|
||||
routes,
|
||||
};
|
||||
use rocket_dyn_templates::{Template, tera::Context};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[get("/role")]
|
||||
async fn index(
|
||||
db: &State<SqlitePool>,
|
||||
admin: VorstandUser,
|
||||
flash: Option<FlashMessage<'_>>,
|
||||
) -> Template {
|
||||
let roles = Role::all(db).await;
|
||||
|
||||
let mut context = Context::new();
|
||||
if let Some(msg) = flash {
|
||||
context.insert("flash", &msg.into_inner());
|
||||
}
|
||||
context.insert("roles", &roles);
|
||||
context.insert(
|
||||
"loggedin_user",
|
||||
&UserWithDetails::from_user(admin.user, db).await,
|
||||
);
|
||||
|
||||
Template::render("admin/role", context.into_json())
|
||||
}
|
||||
#[derive(FromForm)]
|
||||
pub struct RoleToUpdate<'r> {
|
||||
pub formatted_name: &'r str,
|
||||
pub desc: &'r str,
|
||||
}
|
||||
|
||||
#[post("/role/<role_id>", data = "<data>")]
|
||||
async fn update(
|
||||
db: &State<SqlitePool>,
|
||||
data: Form<RoleToUpdate<'_>>,
|
||||
role_id: i32,
|
||||
admin: AdminUser,
|
||||
) -> Flash<Redirect> {
|
||||
let role = Role::find_by_id(db, role_id).await;
|
||||
let Some(role) = role else {
|
||||
return Flash::error(Redirect::to("/admin/role"), "Role does not exist!");
|
||||
};
|
||||
|
||||
match role
|
||||
.update(db, &admin, &data.formatted_name, &data.desc)
|
||||
.await
|
||||
{
|
||||
Ok(_) => Flash::success(Redirect::to("/admin/role"), "Rolle bearbeitet"),
|
||||
Err(e) => Flash::error(Redirect::to("/admin/role"), e),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn routes() -> Vec<Route> {
|
||||
routes![index, update]
|
||||
}
|
@ -3,8 +3,8 @@ use crate::model::{
|
||||
user::{SchnupperBetreuerUser, User, UserWithDetails},
|
||||
};
|
||||
use futures::future::join_all;
|
||||
use rocket::{get, request::FlashMessage, routes, Route, State};
|
||||
use rocket_dyn_templates::{tera::Context, Template};
|
||||
use rocket::{Route, State, get, request::FlashMessage, routes};
|
||||
use rocket_dyn_templates::{Template, tera::Context};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[get("/schnupper")]
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,5 @@
|
||||
use rocket::{
|
||||
FromForm, Request, Route, State,
|
||||
form::Form,
|
||||
get,
|
||||
http::{Cookie, CookieJar},
|
||||
@ -8,12 +9,12 @@ use rocket::{
|
||||
response::{Flash, Redirect},
|
||||
routes,
|
||||
time::{Duration, OffsetDateTime},
|
||||
FromForm, Request, Route, State,
|
||||
};
|
||||
use rocket_dyn_templates::{context, tera, Template};
|
||||
use rocket_dyn_templates::{Template, context, tera};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::{
|
||||
activity::{ActivityBuilder, ReasonAuth},
|
||||
log::Log,
|
||||
user::{LoginError, User},
|
||||
};
|
||||
@ -73,20 +74,18 @@ async fn login(
|
||||
);
|
||||
}
|
||||
Err(_) => {
|
||||
return Flash::error(Redirect::to("/auth"), "Falscher Benutzername/Passwort. Du bist Vereinsmitglied und der Login klappt nicht? Kontaktiere unseren Schriftführer oder schreibe eine Mail an info@rudernlinz.at!");
|
||||
return Flash::error(
|
||||
Redirect::to("/auth"),
|
||||
"Falscher Benutzername/Passwort. Du bist Vereinsmitglied und der Login klappt nicht? Kontaktiere unseren Schriftführer oder schreibe eine Mail an info@rudernlinz.at!",
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
cookies.add_private(Cookie::new("loggedin_user", format!("{}", user.id)));
|
||||
|
||||
Log::create(
|
||||
db,
|
||||
format!(
|
||||
"Succ login of {} with this useragent: {}",
|
||||
login.name, agent.0
|
||||
),
|
||||
)
|
||||
.await;
|
||||
ActivityBuilder::from(ReasonAuth::SuccLogin(&user, agent.0))
|
||||
.save(db)
|
||||
.await;
|
||||
|
||||
// Check for redirect_url cookie and redirect accordingly
|
||||
match cookies.get_private("redirect_url") {
|
||||
|
@ -3,8 +3,8 @@ use crate::model::{
|
||||
role::Role,
|
||||
user::{User, UserWithDetails, VorstandUser},
|
||||
};
|
||||
use rocket::{get, request::FlashMessage, routes, Route, State};
|
||||
use rocket_dyn_templates::{tera::Context, Template};
|
||||
use rocket::{Route, State, get, request::FlashMessage, routes};
|
||||
use rocket_dyn_templates::{Template, tera::Context};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[get("/achievement")]
|
||||
|
@ -4,13 +4,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("/boathouse")]
|
||||
|
@ -1,9 +1,10 @@
|
||||
use rocket::{
|
||||
FromForm, Route, State,
|
||||
form::Form,
|
||||
get, post,
|
||||
request::FlashMessage,
|
||||
response::{Flash, Redirect},
|
||||
routes, FromForm, Route, State,
|
||||
routes,
|
||||
};
|
||||
use rocket_dyn_templates::Template;
|
||||
use sqlx::SqlitePool;
|
||||
|
@ -1,10 +1,11 @@
|
||||
use chrono::NaiveDate;
|
||||
use rocket::{
|
||||
FromForm, Route, State,
|
||||
form::Form,
|
||||
get, post,
|
||||
request::FlashMessage,
|
||||
response::{Flash, Redirect},
|
||||
routes, FromForm, Route, State,
|
||||
routes,
|
||||
};
|
||||
use rocket_dyn_templates::Template;
|
||||
use sqlx::SqlitePool;
|
||||
|
@ -1,16 +1,19 @@
|
||||
use rocket::{
|
||||
FromForm, Route, State,
|
||||
form::Form,
|
||||
get, post,
|
||||
response::{Flash, Redirect},
|
||||
routes, FromForm, Route, State,
|
||||
routes,
|
||||
};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::{
|
||||
event::Event,
|
||||
log::Log,
|
||||
trip::{self, CoxHelpError, Trip, TripDeleteError, TripHelpDeleteError, TripUpdateError},
|
||||
tripdetails::{TripDetails, TripDetailsToAdd},
|
||||
planned::{
|
||||
event::Event,
|
||||
trip::{self, CoxHelpError, Trip, TripDeleteError, TripHelpDeleteError, TripUpdateError},
|
||||
tripdetails::{TripDetails, TripDetailsToAdd},
|
||||
},
|
||||
user::{AllowedToUpdateTripToAlwaysBeShownUser, ErgoUser, SteeringUser, User},
|
||||
};
|
||||
|
||||
@ -22,21 +25,13 @@ async fn create_ergo(
|
||||
) -> Flash<Redirect> {
|
||||
let trip_details_id = TripDetails::create(db, data.into_inner()).await;
|
||||
let trip_details = TripDetails::find_by_id(db, trip_details_id).await.unwrap(); //Okay, bc just
|
||||
//created
|
||||
//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>,
|
||||
@ -45,18 +40,9 @@ async fn create(
|
||||
) -> Flash<Redirect> {
|
||||
let trip_details_id = TripDetails::create(db, data.into_inner()).await;
|
||||
let trip_details = TripDetails::find_by_id(db, trip_details_id).await.unwrap(); //Okay, bc just
|
||||
//created
|
||||
//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.")
|
||||
}
|
||||
|
||||
@ -137,9 +123,10 @@ async fn join(db: &State<SqlitePool>, planned_event_id: i64, cox: SteeringUser)
|
||||
.await;
|
||||
Flash::success(Redirect::to("/planned"), "Danke für's helfen!")
|
||||
}
|
||||
Err(CoxHelpError::CanceledEvent) => {
|
||||
Flash::error(Redirect::to("/planned"), "Die Ausfahrt wurde leider abgesagt...")
|
||||
}
|
||||
Err(CoxHelpError::CanceledEvent) => Flash::error(
|
||||
Redirect::to("/planned"),
|
||||
"Die Ausfahrt wurde leider abgesagt...",
|
||||
),
|
||||
Err(CoxHelpError::AlreadyRegisteredAsCox) => {
|
||||
Flash::error(Redirect::to("/planned"), "Du hilfst bereits aus!")
|
||||
}
|
||||
@ -147,9 +134,10 @@ async fn join(db: &State<SqlitePool>, planned_event_id: i64, cox: SteeringUser)
|
||||
Redirect::to("/planned"),
|
||||
"Du hast dich bereits als Ruderer angemeldet!",
|
||||
),
|
||||
Err(CoxHelpError::DetailsLocked) => {
|
||||
Flash::error(Redirect::to("/planned"), "Die Bootseinteilung wurde bereits gemacht. Wenn du noch steuern möchtest, frag bitte bei einer bereits angemeldeten Steuerperson nach, ob das noch möglich ist.")
|
||||
}
|
||||
Err(CoxHelpError::DetailsLocked) => Flash::error(
|
||||
Redirect::to("/planned"),
|
||||
"Die Bootseinteilung wurde bereits gemacht. Wenn du noch steuern möchtest, frag bitte bei einer bereits angemeldeten Steuerperson nach, ob das noch möglich ist.",
|
||||
),
|
||||
}
|
||||
} else {
|
||||
Flash::error(Redirect::to("/planned"), "Event gibt's nicht")
|
||||
@ -197,9 +185,10 @@ async fn remove(
|
||||
|
||||
Flash::success(Redirect::to("/planned"), "Erfolgreich abgemeldet!")
|
||||
}
|
||||
Err(TripHelpDeleteError::DetailsLocked) => {
|
||||
Flash::error(Redirect::to("/planned"), "Die Bootseinteilung wurde bereits gemacht. Wenn du doch nicht steuern kannst, melde dich bitte unbedingt schnellstmöglich bei einer anderen Steuerperson!")
|
||||
}
|
||||
Err(TripHelpDeleteError::DetailsLocked) => Flash::error(
|
||||
Redirect::to("/planned"),
|
||||
"Die Bootseinteilung wurde bereits gemacht. Wenn du doch nicht steuern kannst, melde dich bitte unbedingt schnellstmöglich bei einer anderen Steuerperson!",
|
||||
),
|
||||
Err(TripHelpDeleteError::CoxNotHelping) => {
|
||||
Flash::error(Redirect::to("/planned"), "Steuermann hilft nicht aus...")
|
||||
}
|
||||
@ -230,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() {
|
||||
|
@ -1,7 +1,8 @@
|
||||
use std::env;
|
||||
|
||||
use chrono::{Datelike, Utc};
|
||||
use chrono::Utc;
|
||||
use rocket::{
|
||||
FromForm, Route, State,
|
||||
form::Form,
|
||||
fs::TempFile,
|
||||
get,
|
||||
@ -9,9 +10,9 @@ use rocket::{
|
||||
post,
|
||||
request::FlashMessage,
|
||||
response::{Flash, Redirect},
|
||||
routes, FromForm, Route, State,
|
||||
routes,
|
||||
};
|
||||
use rocket_dyn_templates::{context, Template};
|
||||
use rocket_dyn_templates::{Template, context};
|
||||
use serde::Serialize;
|
||||
use sqlx::SqlitePool;
|
||||
use tera::Context;
|
||||
@ -145,47 +146,47 @@ pub struct UserAdd {
|
||||
sex: String,
|
||||
}
|
||||
|
||||
#[post("/set-data", data = "<data>")]
|
||||
async fn new_user(db: &State<SqlitePool>, data: Form<UserAdd>, user: User) -> Flash<Redirect> {
|
||||
if user.has_role(db, "ergo").await {
|
||||
return Flash::error(Redirect::to("/ergo"), "Du hast deine Daten schon eingegeben. Wenn du sie updaten willst, melde dich bitte bei it@rudernlinz.at");
|
||||
}
|
||||
|
||||
// check data
|
||||
if data.birthyear < 1900 || data.birthyear > chrono::Utc::now().year() - 5 {
|
||||
return Flash::error(Redirect::to("/ergo"), "Bitte überprüfe dein Geburtsjahr...");
|
||||
}
|
||||
if data.weight < 20 || data.weight > 200 {
|
||||
return Flash::error(Redirect::to("/ergo"), "Bitte überprüfe dein Gewicht...");
|
||||
}
|
||||
if &data.sex != "f" && &data.sex != "m" {
|
||||
return Flash::error(Redirect::to("/ergo"), "Bitte überprüfe dein Geschlecht...");
|
||||
}
|
||||
|
||||
// set data
|
||||
user.update_ergo(db, data.birthyear, data.weight, &data.sex)
|
||||
.await;
|
||||
|
||||
// inform all other `ergo` users
|
||||
let ergo = Role::find_by_name(db, "ergo").await.unwrap();
|
||||
Notification::create_for_role(
|
||||
db,
|
||||
&ergo,
|
||||
&format!("{} nimmt heuer an der Ergochallenge teil 💪", user.name),
|
||||
"Ergo Challenge",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
|
||||
// add to `ergo` group
|
||||
user.add_role(db, &ergo).await.unwrap();
|
||||
|
||||
Flash::success(
|
||||
Redirect::to("/ergo"),
|
||||
"Du hast deine Daten erfolgreich eingegeben. Viel Spaß beim Schwitzen :-)",
|
||||
)
|
||||
}
|
||||
//#[post("/set-data", data = "<data>")]
|
||||
//async fn new_user(db: &State<SqlitePool>, data: Form<UserAdd>, user: User) -> Flash<Redirect> {
|
||||
// if user.has_role(db, "ergo").await {
|
||||
// return Flash::error(Redirect::to("/ergo"), "Du hast deine Daten schon eingegeben. Wenn du sie updaten willst, melde dich bitte bei it@rudernlinz.at");
|
||||
// }
|
||||
//
|
||||
// // check data
|
||||
// if data.birthyear < 1900 || data.birthyear > chrono::Utc::now().year() - 5 {
|
||||
// return Flash::error(Redirect::to("/ergo"), "Bitte überprüfe dein Geburtsjahr...");
|
||||
// }
|
||||
// if data.weight < 20 || data.weight > 200 {
|
||||
// return Flash::error(Redirect::to("/ergo"), "Bitte überprüfe dein Gewicht...");
|
||||
// }
|
||||
// if &data.sex != "f" && &data.sex != "m" {
|
||||
// return Flash::error(Redirect::to("/ergo"), "Bitte überprüfe dein Geschlecht...");
|
||||
// }
|
||||
//
|
||||
// // set data
|
||||
// user.update_ergo(db, data.birthyear, data.weight, &data.sex)
|
||||
// .await;
|
||||
//
|
||||
// // inform all other `ergo` users
|
||||
// let ergo = Role::find_by_name(db, "ergo").await.unwrap();
|
||||
// Notification::create_for_role(
|
||||
// db,
|
||||
// &ergo,
|
||||
// &format!("{} nimmt heuer an der Ergochallenge teil 💪", user.name),
|
||||
// "Ergo Challenge",
|
||||
// None,
|
||||
// None,
|
||||
// )
|
||||
// .await;
|
||||
//
|
||||
// // add to `ergo` group
|
||||
// user.add_role(db, &ergo).await.unwrap();
|
||||
//
|
||||
// Flash::success(
|
||||
// Redirect::to("/ergo"),
|
||||
// "Du hast deine Daten erfolgreich eingegeben. Viel Spaß beim Schwitzen :-)",
|
||||
// )
|
||||
//}
|
||||
|
||||
#[derive(FromForm, Debug)]
|
||||
pub struct ErgoToAdd<'a> {
|
||||
@ -358,7 +359,10 @@ async fn new_dozen(
|
||||
}
|
||||
|
||||
pub fn routes() -> Vec<Route> {
|
||||
routes![index, new_thirty, new_dozen, send, reset, update, new_user]
|
||||
routes![
|
||||
index, new_thirty, new_dozen, send, reset, update,
|
||||
// new_user
|
||||
]
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
204
src/tera/log.rs
204
src/tera/log.rs
@ -1,6 +1,7 @@
|
||||
use std::net::IpAddr;
|
||||
|
||||
use rocket::{
|
||||
Request, Route, State,
|
||||
form::Form,
|
||||
get,
|
||||
http::{Cookie, CookieJar},
|
||||
@ -9,9 +10,8 @@ use rocket::{
|
||||
response::{Flash, Redirect},
|
||||
routes,
|
||||
time::{Duration, OffsetDateTime},
|
||||
Request, Route, State,
|
||||
};
|
||||
use rocket_dyn_templates::{context, Template};
|
||||
use rocket_dyn_templates::{Template, context};
|
||||
use sqlx::SqlitePool;
|
||||
use tera::Context;
|
||||
|
||||
@ -26,7 +26,7 @@ use crate::{
|
||||
LogbookCreateError, LogbookDeleteError, LogbookUpdateError,
|
||||
},
|
||||
logtype::LogType,
|
||||
trip::Trip,
|
||||
planned::trip::Trip,
|
||||
user::{DonauLinzUser, User, UserWithDetails, VorstandUser},
|
||||
},
|
||||
tera::Config,
|
||||
@ -108,23 +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, 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")]
|
||||
@ -215,31 +242,77 @@ async fn create_logbook(
|
||||
user: &DonauLinzUser,
|
||||
smtp_pw: &str,
|
||||
) -> Flash<Redirect> {
|
||||
match Logbook::create(
|
||||
db,
|
||||
data.into_inner(),
|
||||
user, smtp_pw
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(msg) => Flash::success(Redirect::to("/log"), format!("Ausfahrt erfolgreich hinzugefügt{msg}")),
|
||||
Err(LogbookCreateError::BoatAlreadyOnWater) => Flash::error(Redirect::to("/log"), "Boot schon am Wasser"),
|
||||
Err(LogbookCreateError::RowerAlreadyOnWater(rower)) => Flash::error(Redirect::to("/log"), format!("Ruderer {} schon am Wasser", rower.name)),
|
||||
Err(LogbookCreateError::BoatLocked) => Flash::error(Redirect::to("/log"),"Boot gesperrt"),
|
||||
Err(LogbookCreateError::BoatNotFound) => Flash::error(Redirect::to("/log"), "Boot gibt's ned"),
|
||||
Err(LogbookCreateError::TooManyRowers(expected, actual)) => Flash::error(Redirect::to("/log"), format!("Zu viele Ruderer (Boot fasst maximal {expected}, es wurden jedoch {actual} Ruderer ausgewählt)")),
|
||||
Err(LogbookCreateError::RowerCreateError(rower, e)) => Flash::error(Redirect::to("/log"), format!("Fehler bei Ruderer {rower}: {e}")),
|
||||
Err(LogbookCreateError::ArrivalNotAfterDeparture) => Flash::error(Redirect::to("/log"), "Ankunftszeit kann nicht vor der Abfahrtszeit sein"),
|
||||
Err(LogbookCreateError::UserNotAllowedToUseBoat) => Flash::error(Redirect::to("/log"), "Schiffsführer darf dieses Boot nicht verwenden"),
|
||||
Err(LogbookCreateError::SteeringPersonNotInRowers) => Flash::error(Redirect::to("/log"), "Steuerperson nicht in Liste der Ruderer!"),
|
||||
Err(LogbookCreateError::ShipmasterNotInRowers) => Flash::error(Redirect::to("/log"), "Schiffsführer nicht in Liste der Ruderer!"),
|
||||
Err(LogbookCreateError::NotYourEntry) => Flash::error(Redirect::to("/log"), "Nicht deine Ausfahrt!"),
|
||||
Err(LogbookCreateError::ArrivalSetButNotRemainingTwo) => Flash::error(Redirect::to("/log"), "Ankunftszeit gesetzt aber nicht Distanz + Strecke"),
|
||||
Err(LogbookCreateError::OnlyAllowedToEndTripsEndingToday) => Flash::error(Redirect::to("/log"), "Nur Ausfahrten, die in der letzten Woche enden dürfen eingetragen werden. Für einen Nachtrag schreibe alle Daten an den Vorstand (info@rudernlinz.at)."),
|
||||
Err(LogbookCreateError::CantChangeHandoperatableStatusForThisBoat) => Flash::error(Redirect::to("/log"), "Handsteuer-Status dieses Boots kann nicht verändert werden."),
|
||||
Err(LogbookCreateError::TooFast(km, min)) => Flash::error(Redirect::to("/log"), format!("KM zu groß für die eingegebene Dauer ({km} km in {min} Minuten). Bitte überprüfe deine Start- und Endzeit und versuche es erneut.")),
|
||||
Err(LogbookCreateError::AlreadyFinalized) => Flash::error(Redirect::to("/log"), "Logbucheintrag wurde bereits abgeschlossen."),
|
||||
Err(LogbookCreateError::ExternalSteeringPersonMustSteerOrShipmaster) => Flash::error(Redirect::to("/log"), "Wenn du eine 'Externe Steuerperson' hinzufügst, muss diese steuern oder Schiffsführer sein!"),
|
||||
match Logbook::create(db, data.into_inner(), user, smtp_pw).await {
|
||||
Ok(msg) => Flash::success(
|
||||
Redirect::to("/log"),
|
||||
format!("Ausfahrt erfolgreich hinzugefügt{msg}"),
|
||||
),
|
||||
Err(LogbookCreateError::BoatAlreadyOnWater) => {
|
||||
Flash::error(Redirect::to("/log"), "Boot schon am Wasser")
|
||||
}
|
||||
Err(LogbookCreateError::RowerAlreadyOnWater(rower)) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
format!("Ruderer {} schon am Wasser", rower.name),
|
||||
),
|
||||
Err(LogbookCreateError::BoatLocked) => Flash::error(Redirect::to("/log"), "Boot gesperrt"),
|
||||
Err(LogbookCreateError::BoatNotFound) => {
|
||||
Flash::error(Redirect::to("/log"), "Boot gibt's ned")
|
||||
}
|
||||
Err(LogbookCreateError::TooManyRowers(expected, actual)) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
format!(
|
||||
"Zu viele Ruderer (Boot fasst maximal {expected}, es wurden jedoch {actual} Ruderer ausgewählt)"
|
||||
),
|
||||
),
|
||||
Err(LogbookCreateError::RowerCreateError(rower, e)) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
format!("Fehler bei Ruderer {rower}: {e}"),
|
||||
),
|
||||
Err(LogbookCreateError::ArrivalNotAfterDeparture) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
"Ankunftszeit kann nicht vor der Abfahrtszeit sein",
|
||||
),
|
||||
Err(LogbookCreateError::UserNotAllowedToUseBoat) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
"Schiffsführer darf dieses Boot nicht verwenden",
|
||||
),
|
||||
Err(LogbookCreateError::SteeringPersonNotInRowers) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
"Steuerperson nicht in Liste der Ruderer!",
|
||||
),
|
||||
Err(LogbookCreateError::ShipmasterNotInRowers) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
"Schiffsführer nicht in Liste der Ruderer!",
|
||||
),
|
||||
Err(LogbookCreateError::NotYourEntry) => {
|
||||
Flash::error(Redirect::to("/log"), "Nicht deine Ausfahrt!")
|
||||
}
|
||||
Err(LogbookCreateError::ArrivalSetButNotRemainingTwo) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
"Ankunftszeit gesetzt aber nicht Distanz + Strecke",
|
||||
),
|
||||
Err(LogbookCreateError::OnlyAllowedToEndTripsEndingToday) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
"Nur Ausfahrten, die in der letzten Woche enden dürfen eingetragen werden. Für einen Nachtrag schreibe alle Daten an den Vorstand (info@rudernlinz.at).",
|
||||
),
|
||||
Err(LogbookCreateError::CantChangeHandoperatableStatusForThisBoat) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
"Handsteuer-Status dieses Boots kann nicht verändert werden.",
|
||||
),
|
||||
Err(LogbookCreateError::TooFast(km, min)) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
format!(
|
||||
"KM zu groß für die eingegebene Dauer ({km} km in {min} Minuten). Bitte überprüfe deine Start- und Endzeit und versuche es erneut."
|
||||
),
|
||||
),
|
||||
Err(LogbookCreateError::AlreadyFinalized) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
"Logbucheintrag wurde bereits abgeschlossen.",
|
||||
),
|
||||
Err(LogbookCreateError::ExternalSteeringPersonMustSteerOrShipmaster) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
"Wenn du eine 'Externe Steuerperson' hinzufügst, muss diese steuern oder Schiffsführer sein!",
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,7 +369,7 @@ async fn create_kiosk(
|
||||
create_logbook(
|
||||
db,
|
||||
data,
|
||||
&DonauLinzUser::new(db, creator).await.unwrap(),
|
||||
&DonauLinzUser::new(db, &creator).await.unwrap(),
|
||||
&config.smtp_pw,
|
||||
)
|
||||
.await
|
||||
@ -312,7 +385,13 @@ async fn update(
|
||||
let data = data.into_inner();
|
||||
|
||||
let Some(logbook) = Logbook::find_by_id(db, data.id).await else {
|
||||
return Flash::error(Redirect::to("/log"), format!("Logbucheintrag kann nicht bearbeitet werden, da es einen Logbuch-Eintrag mit ID={} nicht gibt", data.id));
|
||||
return Flash::error(
|
||||
Redirect::to("/log"),
|
||||
format!(
|
||||
"Logbucheintrag kann nicht bearbeitet werden, da es einen Logbuch-Eintrag mit ID={} nicht gibt",
|
||||
data.id
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
match logbook.update(db, data.clone(), &user.user).await {
|
||||
@ -353,14 +432,36 @@ async fn home_logbook(
|
||||
);
|
||||
};
|
||||
|
||||
match logbook.home(db,user, data.into_inner(), smtp_pw).await {
|
||||
match logbook.home(db, user, data.into_inner(), smtp_pw).await {
|
||||
Ok(_) => Flash::success(Redirect::to("/log"), "Ausfahrt korrekt eingetragen"),
|
||||
Err(LogbookUpdateError::TooManyRowers(expected, actual)) => Flash::error(Redirect::to("/log"), format!("Zu viele Ruderer (Boot fasst maximal {expected}, es wurden jedoch {actual} Ruderer ausgewählt)")),
|
||||
Err(LogbookUpdateError::OnlyAllowedToEndTripsEndingToday) => Flash::error(Redirect::to("/log"), "Nur Ausfahrten, die heute enden dürfen eingetragen werden. Für einen Nachtrag schreibe alle Daten dem Vorstand an info@rudernlinz.at."),
|
||||
Err(LogbookUpdateError::TooFast(km, min)) => Flash::error(Redirect::to("/log"), format!("KM zu groß für die eingegebene Dauer ({km} km in {min} Minuten). Bitte überprüfe deine Start- und Endzeit und versuche es erneut.")),
|
||||
Err(LogbookUpdateError::AlreadyFinalized) => Flash::error(Redirect::to("/log"), "Logbucheintrag wurde bereits abgeschlossen."),
|
||||
Err(LogbookUpdateError::ExternalSteeringPersonMustSteerOrShipmaster) => Flash::error(Redirect::to("/log"), "Wenn du eine 'Externe Steuerperson' hinzufügst, muss diese steuern oder Schiffsführer sein!"),
|
||||
Err(LogbookUpdateError::BoatAlreadyOnWater) => Flash::error(Redirect::to("/log"), "Das Boot war in diesem Zeitraum schon am Wasser. Bitte überprüfe das Datum und die Zeit."),
|
||||
Err(LogbookUpdateError::TooManyRowers(expected, actual)) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
format!(
|
||||
"Zu viele Ruderer (Boot fasst maximal {expected}, es wurden jedoch {actual} Ruderer ausgewählt)"
|
||||
),
|
||||
),
|
||||
Err(LogbookUpdateError::OnlyAllowedToEndTripsEndingToday) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
"Nur Ausfahrten, die heute enden dürfen eingetragen werden. Für einen Nachtrag schreibe alle Daten dem Vorstand an info@rudernlinz.at.",
|
||||
),
|
||||
Err(LogbookUpdateError::TooFast(km, min)) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
format!(
|
||||
"KM zu groß für die eingegebene Dauer ({km} km in {min} Minuten). Bitte überprüfe deine Start- und Endzeit und versuche es erneut."
|
||||
),
|
||||
),
|
||||
Err(LogbookUpdateError::AlreadyFinalized) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
"Logbucheintrag wurde bereits abgeschlossen.",
|
||||
),
|
||||
Err(LogbookUpdateError::ExternalSteeringPersonMustSteerOrShipmaster) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
"Wenn du eine 'Externe Steuerperson' hinzufügst, muss diese steuern oder Schiffsführer sein!",
|
||||
),
|
||||
Err(LogbookUpdateError::BoatAlreadyOnWater) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
"Das Boot war in diesem Zeitraum schon am Wasser. Bitte überprüfe das Datum und die Zeit.",
|
||||
),
|
||||
Err(e) => Flash::error(
|
||||
Redirect::to("/log"),
|
||||
format!("Eintrag {logbook_id} konnte nicht abgesendet werden (Fehler: {e:?})!"),
|
||||
@ -390,7 +491,7 @@ async fn home_kiosk(
|
||||
logbook_id,
|
||||
&DonauLinzUser::new(
|
||||
db,
|
||||
User::find_by_id(db, logbook.shipmaster as i32)
|
||||
&User::find_by_id(db, logbook.shipmaster as i32)
|
||||
.await
|
||||
.unwrap(),
|
||||
)
|
||||
@ -436,10 +537,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!",
|
||||
@ -508,7 +606,7 @@ mod test {
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::logbook::Logbook;
|
||||
use crate::tera::{log::Boat, User};
|
||||
use crate::tera::{User, log::Boat};
|
||||
use crate::testdb;
|
||||
|
||||
#[sqlx::test]
|
||||
|
@ -1,7 +1,7 @@
|
||||
use rocket::{get, http::ContentType, routes, Route, State};
|
||||
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) {
|
||||
|
@ -2,7 +2,7 @@ use std::{fs::OpenOptions, io::Write};
|
||||
|
||||
use chrono::{Datelike, Local};
|
||||
use rocket::{
|
||||
catch, catchers,
|
||||
Build, Data, FromForm, Request, Rocket, State, catch, catchers,
|
||||
fairing::{AdHoc, Fairing, Info, Kind},
|
||||
form::Form,
|
||||
fs::FileServer,
|
||||
@ -13,7 +13,6 @@ use rocket::{
|
||||
response::{Flash, Redirect},
|
||||
routes,
|
||||
time::{Duration, OffsetDateTime},
|
||||
Build, Data, FromForm, Request, Rocket, State,
|
||||
};
|
||||
use rocket_dyn_templates::Template;
|
||||
use serde::Deserialize;
|
||||
@ -21,6 +20,7 @@ use sqlx::SqlitePool;
|
||||
use tera::Context;
|
||||
|
||||
use crate::{
|
||||
SCHECKBUCH,
|
||||
model::{
|
||||
logbook::Logbook,
|
||||
notification::Notification,
|
||||
@ -28,7 +28,6 @@ use crate::{
|
||||
role::Role,
|
||||
user::{User, UserWithDetails},
|
||||
},
|
||||
SCHECKBUCH,
|
||||
};
|
||||
|
||||
pub(crate) mod admin;
|
||||
@ -202,7 +201,10 @@ async fn blogpost_unpublished(
|
||||
|
||||
#[catch(403)] //forbidden
|
||||
fn forbidden_error() -> Flash<Redirect> {
|
||||
Flash::error(Redirect::to("/"), "Keine Berechtigung für diese Aktion. Wenn du der Meinung bist, dass du das machen darfst, melde dich bitte bei it@rudernlinz.at.")
|
||||
Flash::error(
|
||||
Redirect::to("/"),
|
||||
"Keine Berechtigung für diese Aktion. Wenn du der Meinung bist, dass du das machen darfst, melde dich bitte bei it@rudernlinz.at.",
|
||||
)
|
||||
}
|
||||
|
||||
struct Usage {}
|
||||
@ -328,11 +330,13 @@ mod test {
|
||||
|
||||
assert_eq!(response.status(), Status::Ok);
|
||||
|
||||
assert!(response
|
||||
.into_string()
|
||||
.await
|
||||
.unwrap()
|
||||
.contains("Ruderassistent"));
|
||||
assert!(
|
||||
response
|
||||
.into_string()
|
||||
.await
|
||||
.unwrap()
|
||||
.contains("Ruderassistent")
|
||||
);
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
|
@ -1,7 +1,7 @@
|
||||
use rocket::{
|
||||
get,
|
||||
Route, State, get,
|
||||
response::{Flash, Redirect},
|
||||
routes, Route, State,
|
||||
routes,
|
||||
};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
|
@ -1,22 +1,24 @@
|
||||
use rocket::{
|
||||
get,
|
||||
Route, State, get,
|
||||
request::FlashMessage,
|
||||
response::{Flash, Redirect},
|
||||
routes, Route, State,
|
||||
routes,
|
||||
};
|
||||
use rocket_dyn_templates::Template;
|
||||
use sqlx::SqlitePool;
|
||||
use tera::Context;
|
||||
|
||||
use crate::{
|
||||
AMOUNT_DAYS_TO_SHOW_TRIPS_AHEAD,
|
||||
model::{
|
||||
log::Log,
|
||||
tripdetails::TripDetails,
|
||||
triptype::TripType,
|
||||
planned::{
|
||||
tripdetails::TripDetails,
|
||||
triptype::TripType,
|
||||
usertrip::{UserTrip, UserTripDeleteError, UserTripError},
|
||||
},
|
||||
user::{AllowedForPlannedTripsUser, User, UserWithDetails},
|
||||
usertrip::{UserTrip, UserTripDeleteError, UserTripError},
|
||||
},
|
||||
AMOUNT_DAYS_TO_SHOW_TRIPS_AHEAD,
|
||||
};
|
||||
|
||||
#[get("/")]
|
||||
@ -81,14 +83,15 @@ async fn join(
|
||||
),
|
||||
)
|
||||
.await;
|
||||
}else{
|
||||
} else {
|
||||
Log::create(
|
||||
db,
|
||||
format!(
|
||||
"User {} registered the guest '{}' for trip_details.id={}",
|
||||
user.name, registered_user, trip_details_id
|
||||
),
|
||||
).await;
|
||||
)
|
||||
.await;
|
||||
}
|
||||
Flash::success(Redirect::to("/planned"), "Erfolgreich angemeldet!")
|
||||
}
|
||||
@ -98,9 +101,10 @@ async fn join(
|
||||
Err(UserTripError::AlreadyRegistered) => {
|
||||
Flash::error(Redirect::to("/planned"), "Du nimmst bereits teil!")
|
||||
}
|
||||
Err(UserTripError::AlreadyRegisteredAsCox) => {
|
||||
Flash::error(Redirect::to("/planned"), "Du hilfst bereits als Steuerperson aus!")
|
||||
}
|
||||
Err(UserTripError::AlreadyRegisteredAsCox) => Flash::error(
|
||||
Redirect::to("/planned"),
|
||||
"Du hilfst bereits als Steuerperson aus!",
|
||||
),
|
||||
Err(UserTripError::CantRegisterAtOwnEvent) => Flash::error(
|
||||
Redirect::to("/planned"),
|
||||
"Du kannst bei einer selbst ausgeschriebenen Fahrt nicht mitrudern ;)",
|
||||
@ -160,7 +164,10 @@ async fn remove_guest(
|
||||
)
|
||||
.await;
|
||||
|
||||
Flash::error(Redirect::to("/planned"), "Die Bootseinteilung wurde bereits gemacht. Wenn du doch nicht mitrudern kannst, melde dich bitte unbedingt schnellstmöglich bei einer angemeldeten Steuerperson!")
|
||||
Flash::error(
|
||||
Redirect::to("/planned"),
|
||||
"Die Bootseinteilung wurde bereits gemacht. Wenn du doch nicht mitrudern kannst, melde dich bitte unbedingt schnellstmöglich bei einer angemeldeten Steuerperson!",
|
||||
)
|
||||
}
|
||||
Err(UserTripDeleteError::GuestNotParticipating) => {
|
||||
Flash::error(Redirect::to("/planned"), "Gast nicht angemeldet.")
|
||||
@ -211,7 +218,10 @@ async fn remove(
|
||||
)
|
||||
.await;
|
||||
|
||||
Flash::error(Redirect::to("/planned"), "Das Boot ist bereits eingeteilt. Bitte kontaktiere den Schiffsführer (Nummern siehe Signalgruppe) falls du dich doch abmelden willst.")
|
||||
Flash::error(
|
||||
Redirect::to("/planned"),
|
||||
"Das Boot ist bereits eingeteilt. Bitte kontaktiere den Schiffsführer (Nummern siehe Signalgruppe) falls du dich doch abmelden willst.",
|
||||
)
|
||||
}
|
||||
Err(UserTripDeleteError::NotVisibleToUser) => {
|
||||
Log::create(
|
||||
@ -223,7 +233,10 @@ async fn remove(
|
||||
)
|
||||
.await;
|
||||
|
||||
Flash::error(Redirect::to("/planned"), "Abmeldung nicht möglich, da du dieses Event eigentlich gar nicht sehen solltest...")
|
||||
Flash::error(
|
||||
Redirect::to("/planned"),
|
||||
"Abmeldung nicht möglich, da du dieses Event eigentlich gar nicht sehen solltest...",
|
||||
)
|
||||
}
|
||||
Err(_) => {
|
||||
panic!("Not possible to be here");
|
||||
|
@ -1,5 +1,5 @@
|
||||
use rocket::{get, routes, Route, State};
|
||||
use rocket_dyn_templates::{context, Template};
|
||||
use rocket::{Route, State, get, routes};
|
||||
use rocket_dyn_templates::{Template, context};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::{
|
||||
|
@ -1,10 +1,11 @@
|
||||
use chrono::NaiveDate;
|
||||
use rocket::{
|
||||
FromForm, Route, State,
|
||||
form::Form,
|
||||
get, post,
|
||||
request::FlashMessage,
|
||||
response::{Flash, Redirect},
|
||||
routes, FromForm, Route, State,
|
||||
routes,
|
||||
};
|
||||
use rocket_dyn_templates::Template;
|
||||
use sqlx::SqlitePool;
|
||||
|
@ -26,26 +26,24 @@
|
||||
role="alert">
|
||||
<h2 class="h2">Mitglieds-Beitrags-Info</h2>
|
||||
<div class="p-3 grid gap-3">
|
||||
<a class="btn btn-primary" href="/admin/mail/fee/test">
|
||||
Test-Mail an mich versenden
|
||||
</a>
|
||||
<a class="btn btn-alert" href="/admin/mail/fee"
|
||||
onclick="return confirm('Hast du die Gebührenauflistung geprüft und willst du die Mail an alle ausschicken?');">
|
||||
An ALLE Mitglieder versenden
|
||||
</a>
|
||||
<a class="btn btn-primary" href="/admin/mail/fee/test">Test-Mail an mich versenden</a>
|
||||
<a class="btn btn-alert"
|
||||
href="/admin/mail/fee"
|
||||
onclick="return confirm('Hast du die Gebührenauflistung geprüft und willst du die Mail an alle ausschicken?');">
|
||||
An ALLE Mitglieder versenden
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"
|
||||
role="alert">
|
||||
<h2 class="h2">Unfreundliche Zahlungsaufforderung</h2>
|
||||
<div class="p-3 grid gap-3">
|
||||
<a class="btn btn-primary" href="/admin/mail/fee-final/test">
|
||||
Test-Mail an mich versenden
|
||||
</a>
|
||||
<a class="btn btn-alert" href="/admin/mail/fee-final"
|
||||
onclick="return confirm('Hast du die Gebührenauflistung geprüft, gecheckt ob alle die bereits bezahlt haben auch eingetragen wurden und willst du die Mail an alle, die noch nicht bezahlt haben ausschicken?');">
|
||||
An ALLE Mitglieder versenden, die noch nicht bezahlt haben
|
||||
</a>
|
||||
<a class="btn btn-primary" href="/admin/mail/fee-final/test">Test-Mail an mich versenden</a>
|
||||
<a class="btn btn-alert"
|
||||
href="/admin/mail/fee-final"
|
||||
onclick="return confirm('Hast du die Gebührenauflistung geprüft, gecheckt ob alle die bereits bezahlt haben auch eingetragen wurden und willst du die Mail an alle, die noch nicht bezahlt haben ausschicken?');">
|
||||
An ALLE Mitglieder versenden, die noch nicht bezahlt haben
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
44
templates/admin/role.html.tera
Normal file
44
templates/admin/role.html.tera
Normal file
@ -0,0 +1,44 @@
|
||||
{% import "includes/macros" as macros %}
|
||||
{% import "includes/forms/boat" as boat %}
|
||||
{% extends "base" %}
|
||||
{% block content %}
|
||||
<div class="max-w-screen-lg w-full dark:text-white">
|
||||
<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 }} {{ role.formatted_name }}"
|
||||
class="w-full border-t">
|
||||
<form action="/admin/role/{{ role.id }}"
|
||||
data-filterable="true"
|
||||
method="post"
|
||||
class="bg-white dark:bg-primary-900 p-4 w-full">
|
||||
<div class="w-full">
|
||||
<input type="hidden" name="id" value="{{ role.id }}" />
|
||||
<div class="font-bold mb-1 text-black dark:text-white">
|
||||
{{ role.name }}
|
||||
<br />
|
||||
</div>
|
||||
<div class="grid md:grid-cols-3 gap-3">
|
||||
{{ 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) }}
|
||||
<div class="flex items-end">
|
||||
<input value="Ändern" type="submit" class="w-full btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
@ -5,28 +5,134 @@
|
||||
<h1 class="h1">Users</h1>
|
||||
{% if allowed_to_edit %}
|
||||
<details class="mt-5 bg-gray-200 dark:bg-primary-600 p-3 rounded-md">
|
||||
<summary class="px-3 cursor-pointer text-md font-bold text-primary-950 dark:text-white">Neue Person hinzufügen</summary>
|
||||
<form action="/admin/user/new"
|
||||
onsubmit="return confirm('Willst du wirklich einen neuen Benutzer anlegen?');"
|
||||
method="post"
|
||||
class="flex mt-4 rounded-md sm:flex items-end justify-between">
|
||||
<div class="w-full">
|
||||
<div>
|
||||
<label for="name" class="sr-only">Name</label>
|
||||
<input type="text"
|
||||
name="name"
|
||||
class="input rounded-md w-100"
|
||||
placeholder="Name" />
|
||||
<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>
|
||||
<button type="button"
|
||||
onclick="document.getElementById('add-scheckbuch').showModal()"
|
||||
class="btn btn-dark">🧑🏫 Scheckbuch</button>
|
||||
<button type="button"
|
||||
onclick="document.getElementById('add-schnupperkurs').showModal()"
|
||||
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"
|
||||
onclick="document.getElementById('add-clubuser').close()">
|
||||
<div onclick="event.stopPropagation();" class="p-3">
|
||||
<button type="button"
|
||||
onclick="document.getElementById('add-clubuser').close()"
|
||||
title="Schließen"
|
||||
class="sidebar-close border-0 bg-primary-100 focus:bg-primary-50 text-black flex items-center justify-center transform rotate-45 absolute right-0 mr-3">
|
||||
<svg class="inline h-5 w-5"
|
||||
width="16"
|
||||
height="16"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 16 16">
|
||||
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
<div class="mt-8">
|
||||
<h2 class="h3 mb-3">Neues Vereinsmitglied</h2>
|
||||
<form action="/admin/user/new/clubmember"
|
||||
method="post"
|
||||
enctype="multipart/form-data"
|
||||
class="grid gap-3">
|
||||
<div>
|
||||
<label for="membertype" class="text-sm text-gray-600 dark:text-gray-100">Mitgliedstyp</label>
|
||||
<select name="membertype" id="membertype" class="input rounded-md ">
|
||||
<option selected="" value="regular">Reguläres Vereinsmitglied</option>
|
||||
<option value="unterstuetzend">Unterstützendes Vereinsmitglied</option>
|
||||
<option value="foerdernd">Förderndes Vereinsmitglied</option>
|
||||
</select>
|
||||
</div>
|
||||
{{ macros::input(label='Name', name='name', type="text", required=true) }}
|
||||
{{ macros::input(label='Mailadresse', name='mail', type="email", required=true, placeholder='user@mail.at') }}
|
||||
{{ macros::select(label="Finanzielles", data=financial, name='financial_id', display=['name'], default="Keine Ermäßigung") }}
|
||||
{{ macros::input(label='Mitglied seit', name='member_since', type="date", value=now() | date(), required=true) }}
|
||||
{{ macros::input(label='Geburtsdatum', name='birthdate', type="date", required=true) }}
|
||||
{{ macros::input(label='Telefonnummer', name='phone', type="text", required=true) }}
|
||||
{{ macros::input(label='Adresse', name='address', type="text", required=true) }}
|
||||
{{ macros::input(label='Beitrittserklärung', name='membership_pdf', type="file", accept='application/pdf', required=true) }}
|
||||
<input value="Neues Vereinsmitglied anlegen"
|
||||
type="submit"
|
||||
class="btn btn-primary" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-right ml-3">
|
||||
<input value="Hinzufügen"
|
||||
type="submit"
|
||||
class="w-28 mt-2 sm:mt-0 rounded-md bg-primary-500 px-3 py-2 text-sm font-semibold text-white hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer" />
|
||||
</div>
|
||||
</form>
|
||||
</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()">
|
||||
<div onclick="event.stopPropagation();" class="p-3">
|
||||
<button type="button"
|
||||
onclick="document.getElementById('add-scheckbuch').close()"
|
||||
title="Schließen"
|
||||
class="sidebar-close border-0 bg-primary-100 focus:bg-primary-50 text-black flex items-center justify-center transform rotate-45 absolute right-0 mr-3">
|
||||
<svg class="inline h-5 w-5"
|
||||
width="16"
|
||||
height="16"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 16 16">
|
||||
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
<div class="mt-8">
|
||||
<h2 class="h3 mb-3">Neues Scheckbuch</h2>
|
||||
<form action="/admin/user/new/scheckbuch"
|
||||
method="post"
|
||||
enctype="multipart/form-data"
|
||||
class="grid gap-3">
|
||||
{{ macros::input(label='Name', name='name', type="text", required=true) }}
|
||||
{{ macros::input(label='Mailadresse', name='mail', type="email", required=true, placeholder='user@mail.at') }}
|
||||
<input value="Neues Scheckbuch anlegen"
|
||||
type="submit"
|
||||
class="btn btn-primary" />
|
||||
</form>
|
||||
</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()">
|
||||
<div onclick="event.stopPropagation();" class="p-3">
|
||||
<button type="button"
|
||||
onclick="document.getElementById('add-schnupperkurs').close()"
|
||||
title="Schließen"
|
||||
class="sidebar-close border-0 bg-primary-100 focus:bg-primary-50 text-black flex items-center justify-center transform rotate-45 absolute right-0 mr-3">
|
||||
<svg class="inline h-5 w-5"
|
||||
width="16"
|
||||
height="16"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 16 16">
|
||||
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
<div class="mt-8">
|
||||
<form action="/admin/user/new/schnupper"
|
||||
method="post"
|
||||
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 ">
|
||||
<option value="schnupperInterested">Interessiert am Schnupperkurs</option>
|
||||
<option value="schnupperant">Fixe Schnupperkurs-Anmeldung</option>
|
||||
</select>
|
||||
</div>
|
||||
{{ macros::input(label='Name', name='name', type="text", required=true) }}
|
||||
{{ macros::input(label='Mailadresse', name='mail', type="email", required=true, placeholder='user@mail.at') }}
|
||||
{{ macros::select(label="Finanzielles", data=financial, name='financial_id', display=['name'], default="Keine Ermäßigung") }}
|
||||
<input value="Hinzufügen" type="submit" class="btn btn-primary" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
</details>
|
||||
|
||||
{% endif %}
|
||||
<!-- START filterBar -->
|
||||
<div class="search-wrapper flex">
|
||||
@ -36,26 +142,29 @@
|
||||
id="filter-js"
|
||||
class="search-bar"
|
||||
placeholder="Suchen nach (Name, [yes|no]-role:<name>, has-[no-]membership-pdf)" />
|
||||
|
||||
<div class="relative">
|
||||
<button id="dropdownbtn" data-dropdown="dropdown" class="btn btn-dark ml-3" type="button">
|
||||
Sortieren
|
||||
</button>
|
||||
|
||||
<!-- Dropdown menu -->
|
||||
<div id="dropdown" class="z-10 hidden bg-white divide-y divide-gray-100 text-secondary-900 rounded-lg shadow-sm w-44 absolute right-0">
|
||||
<ul class="py-2 text-sm" aria-labelledby="dropdownbtn">
|
||||
<li>
|
||||
<a href="./user" class="block px-4 py-2 hover:bg-gray-100 hover:text-secondary-950">Zuletzt eingeloggt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="?sort=name&asc" class="block px-4 py-2 hover:bg-gray-100 hover:text-secondary-950">Name A-Z</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="?sort=name" class="block px-4 py-2 hover:bg-gray-100 hover:text-secondary-950">Name Z-A</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<button id="dropdownbtn"
|
||||
data-dropdown="dropdown"
|
||||
class="btn btn-dark ml-3"
|
||||
type="button">Sortieren</button>
|
||||
<!-- Dropdown menu -->
|
||||
<div id="dropdown"
|
||||
class="z-10 hidden bg-white divide-y divide-gray-100 text-secondary-900 rounded-lg shadow-sm w-44 absolute right-0">
|
||||
<ul class="py-2 text-sm" aria-labelledby="dropdownbtn">
|
||||
<li>
|
||||
<a href="./user"
|
||||
class="block px-4 py-2 hover:bg-gray-100 hover:text-secondary-950">Zuletzt eingeloggt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="?sort=name&asc"
|
||||
class="block px-4 py-2 hover:bg-gray-100 hover:text-secondary-950">Name A-Z</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="?sort=name"
|
||||
class="block px-4 py-2 hover:bg-gray-100 hover:text-secondary-950">Name Z-A</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END filterBar -->
|
||||
@ -63,113 +172,21 @@
|
||||
{% for user in users %}
|
||||
<div data-filterable="true"
|
||||
data-filter="{{ user.name }} {% for role in roles %} {% if role.name in user.roles %} yes-role:{{ role.name }} {% else %} no-role:{{ role.name }} {% endif %} role-{{ role }} {% endfor %} {% if user.membership_pdf %}has-membership-pdf{% else %}has-no-membership-pdf{% endif %}"
|
||||
class="border-t bg-white dark:bg-primary-900 py-3 px-4 relative">
|
||||
<details class="block dark:text-white w-full">
|
||||
<summary>
|
||||
<span class="text-black dark:text-white cursor-pointer">
|
||||
<span class="font-bold">
|
||||
{{ user.name }}
|
||||
{% if not user.last_access and allowed_to_edit and user.mail %}
|
||||
<form action="/admin/user"
|
||||
method="post"
|
||||
enctype="multipart/form-data"
|
||||
class="inline">
|
||||
• <a class="font-normal text-primary-600 dark:text-primary-200 hover:text-primary-900 dark:hover:text-primary-300 underline"
|
||||
href="/admin/user/{{ user.id }}/send-welcome-mail"
|
||||
onclick="return confirm('Willst du wirklich das Willkommensmail an {{ user.name }} ausschicken?');">Willkommensmail verschicken</a>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% if user.last_access %}• ⏳ {{ user.last_access | date }}{% endif %}
|
||||
</span>
|
||||
<small class="block text-gray-600 dark:text-gray-100">
|
||||
{% for role in user.roles -%}
|
||||
{{ role }}
|
||||
{%- if not loop.last %},
|
||||
{% endif -%}
|
||||
{% endfor %}
|
||||
</small>
|
||||
</span>
|
||||
</summary>
|
||||
<form action="/admin/user"
|
||||
method="post"
|
||||
enctype="multipart/form-data"
|
||||
class="w-full mt-2">
|
||||
{% if user.pw %}
|
||||
<a class="block my-1 font-normal text-[#f43f5e] dark:text-primary-200 hover:text-primary-900 dark:hover:text-primary-300 underline"
|
||||
href="/admin/user/{{ user.id }}/reset-pw"
|
||||
onclick="return confirm('Willst du wirklich das Passwort zurücksetzen?');">Passwort zurücksetzen</a>
|
||||
{% endif %}
|
||||
<div class="w-full grid gap-3 mt-3">
|
||||
<input type="hidden" name="id" value="{{ user.id }}" />
|
||||
<div class="grid sm:grid-cols-2 lg:grid-cols-4 gap-3">
|
||||
{% for cluster, cluster_roles in roles | group_by(attribute="cluster") %}
|
||||
<label for="cluster_{{ loop.index }}">{{ cluster }}</label>
|
||||
{# Determine the initially selected role within the cluster #}
|
||||
{% set_global selected_role_id = "none" %}
|
||||
{% for role in cluster_roles %}
|
||||
{% if selected_role_id == "none" and role.name in user.roles %}
|
||||
{% set_global selected_role_id = role.id %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{# Set default name to the selected role ID or first role if none selected #}
|
||||
<select id="cluster_{{ loop.index }}"
|
||||
{% if selected_role_id == 'none' %} {% else %} name="roles[{{ selected_role_id }}]" {% endif %}
|
||||
{% if allowed_to_edit == false %}disabled{% endif %}
|
||||
onchange=" if (this.value === '') { this.removeAttribute('name'); } else { this.name = 'roles[' + this.options[this.selectedIndex].getAttribute('data-role-id') + ']'; }">
|
||||
<option value=""
|
||||
data-role-id="none"
|
||||
{% if selected_role_id == 'none' %}selected="selected"{% endif %}>
|
||||
None
|
||||
</option>
|
||||
{% for role in cluster_roles %}
|
||||
<option value="on"
|
||||
data-role-id="{{ role.id }}"
|
||||
{% if role.id == selected_role_id %}selected="selected"{% endif %}>
|
||||
{{ role.name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% endfor %}
|
||||
{% for role in roles %}
|
||||
{% if not role.cluster %}
|
||||
{{ macros::checkbox(label=role.name, name="roles[" ~ role.id ~ "]", id=loop.index , checked=role.name in user.roles, disabled=allowed_to_edit == false) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<hr class="sm:col-span-2 lg:col-span-4 my-3" />
|
||||
{% if user.membership_pdf %}
|
||||
<a href="/admin/user/{{ user.id }}/membership"
|
||||
class="text-black dark:text-white">Beitrittserklärung herunterladen</a>
|
||||
{% else %}
|
||||
{{ macros::input(label='Beitrittserklärung', name='membership_pdf', id=loop.index, type="file", readonly=allowed_to_edit == false, accept='application/pdf') }}
|
||||
{% endif %}
|
||||
{{ macros::input(label='DOB', name='dob', id=loop.index, type="text", value=user.dob, readonly=allowed_to_edit == false) }}
|
||||
{{ macros::input(label='Weight (kg)', name='weight', id=loop.index, type="text", value=user.weight, readonly=allowed_to_edit == false) }}
|
||||
{{ macros::input(label='Sex', name='sex', id=loop.index, type="text", value=user.sex, readonly=allowed_to_edit == false) }}
|
||||
{{ macros::input(label='Mitglied seit', name='member_since_date', id=loop.index, type="text", value=user.member_since_date, readonly=allowed_to_edit == false) }}
|
||||
{{ macros::input(label='Geburtsdatum', name='birthdate', id=loop.index, type="text", value=user.birthdate, readonly=allowed_to_edit == false) }}
|
||||
{{ macros::input(label='Mail', name='mail', id=loop.index, type="text", value=user.mail, readonly=allowed_to_edit == false) }}
|
||||
{{ macros::input(label='Nickname', name='nickname', id=loop.index, type="text", value=user.nickname, readonly=allowed_to_edit == false) }}
|
||||
{{ macros::input(label='Notizen', name='notes', id=loop.index, type="text", value=user.notes, readonly=allowed_to_edit == false) }}
|
||||
{{ macros::input(label='Telefon', name='phone', id=loop.index, type="text", value=user.phone, readonly=allowed_to_edit == false) }}
|
||||
{{ macros::input(label='Adresse', name='address', id=loop.index, type="text", value=user.address, readonly=allowed_to_edit == false) }}
|
||||
{% if allowed_to_edit %}
|
||||
{{ macros::select(label="Familie", data=families, name='family_id', selected_id=user.family_id, display=['names'], default="Keine Familie", new_last_entry='Neue Familie anlegen') }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% if allowed_to_edit %}
|
||||
<div class="mt-3 text-right">
|
||||
<a href="/admin/user/{{ user.id }}/delete"
|
||||
class="w-28 btn btn-alert"
|
||||
onclick="return confirm('Wirklich löschen?');">
|
||||
{% include "includes/delete-icon" %}
|
||||
Löschen
|
||||
</a>
|
||||
<input value="Ändern" type="submit" class="w-28 btn btn-primary ml-1" />
|
||||
</div>
|
||||
{% endif %}
|
||||
</form>
|
||||
</details>
|
||||
class="border-t bg-white dark:bg-primary-900 py-3 px-4 relative flex justify-between items-center">
|
||||
<span class="text-black dark:text-white">
|
||||
<span class="font-bold">
|
||||
{{ user.name }}
|
||||
{% if user.last_access %}• ⏳ {{ user.last_access | date }}{% endif %}
|
||||
</span>
|
||||
<small class="block text-gray-600 dark:text-gray-100">
|
||||
{% for role in user.roles -%}
|
||||
{{ role }}
|
||||
{%- if not loop.last %},
|
||||
{% endif -%}
|
||||
{% endfor %}
|
||||
</small>
|
||||
</span>
|
||||
<a href="/admin/user/{{ user.id }}" class="btn btn-dark ml-3">{% include "includes/pencil" %}</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
@ -55,9 +55,11 @@
|
||||
<div class="grid sm:grid-cols-1 gap-3">
|
||||
<div style="width: 100%" class="col-span-2">
|
||||
<b>{{ user.name }} - Ausfahrten: {{ trips | length }}</b>
|
||||
{% for trip in trips %}
|
||||
<li>{{ log::show_old(log=trip, state="completed", only_ones=false, index=loop.index) }}</li>
|
||||
{% endfor %}
|
||||
<ul class="list-disc ms-4">
|
||||
{% for trip in trips %}
|
||||
<li>{{ log::show_old(log=trip, state="completed", only_ones=false, index=loop.index) }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% if "admin" in loggedin_user.roles or "kassier" in loggedin_user.roles %}
|
||||
<a href="/admin/user/fees/paid?user_ids[]={{ user.id }}">Zahlungsstatus ändern</a>
|
||||
|
437
templates/admin/user/view.html.tera
Normal file
437
templates/admin/user/view.html.tera
Normal file
@ -0,0 +1,437 @@
|
||||
{% import "includes/macros" as macros %}
|
||||
{% import "includes/forms/log" as log %}
|
||||
{% extends "base" %}
|
||||
{% 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">
|
||||
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow">
|
||||
<h2 class="h2">
|
||||
Grunddaten
|
||||
<br />
|
||||
<small class="inline-block text-xs text-gray-500 dark:text-gray-100 ">
|
||||
{% if user.last_access %}
|
||||
Zuletzt eingeloggt am {{ user.last_access | date(format="%d. %m. %Y") }}
|
||||
{% else %}
|
||||
App-Boykott 😢
|
||||
{% endif %}
|
||||
</small>
|
||||
</h2>
|
||||
<div class="mx-3 divide-y divide-gray-200 dark:divide-primary-600">
|
||||
<div class="py-3 grid gap-3">
|
||||
<form action="/admin/user/{{ user.id }}/change-mail" method="post">
|
||||
{{ macros::inputgroup(label='Mailadresse', name='mail', type="text", value=user.mail, readonly=not allowed_to_edit) }}
|
||||
</form>
|
||||
<form action="/admin/user/{{ user.id }}/change-phone" method="post">
|
||||
{{ macros::inputgroup(label='Telefonnummer', name='phone', type="text", value=user.phone, readonly=not allowed_to_edit) }}
|
||||
</form>
|
||||
<form action="/admin/user/{{ user.id }}/change-nickname" method="post">
|
||||
{{ macros::inputgroup(label='Spitzname', name='nickname', type="text", value=user.nickname, readonly=not allowed_to_edit) }}
|
||||
</form>
|
||||
<form action="/admin/user/{{ user.id }}/change-financial" method="post">
|
||||
{% if user_financial %}
|
||||
{{ macros::selectgroup(label="Finanzielles", data=financial, selected_id=user_financial.id, name='financial_id', display=['name'], default="Keine Ermäßigung", readonly=not allowed_to_edit) }}
|
||||
{% else %}
|
||||
{{ macros::selectgroup(label="Finanzielles", data=financial, name='financial_id', display=['name'], default="Keine Ermäßigung", readonly=not allowed_to_edit) }}
|
||||
{% endif %}
|
||||
</form>
|
||||
{% if allowed_to_edit %}
|
||||
<form action="/admin/user/{{ user.id }}/new-note" method="post">
|
||||
{{ macros::inputgroup(label='Neue Notiz', name='note', type="text") }}
|
||||
</form>
|
||||
{% endif %}
|
||||
{% if user.pw and allowed_to_edit %}
|
||||
<div>
|
||||
<a class="block my-1 font-normal text-[#f43f5e] dark:text-primary-200 hover:text-primary-900 dark:hover:text-primary-300 underline"
|
||||
href="/admin/user/{{ user.id }}/reset-pw"
|
||||
onclick="return confirm('Willst du wirklich das Passwort zurücksetzen?');">Passwort zurücksetzen</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow">
|
||||
<h2 class="h2">
|
||||
Mitgliedschaft
|
||||
<br />
|
||||
<small class="inline-block text-xs text-gray-500 dark:text-gray-100 ">
|
||||
{% if "SchnupperInterest" in member %}
|
||||
Interessiert am Schnupperkurs
|
||||
{% elif "Schnupperant" in member %}
|
||||
Beim nächsten Schnupperkurs angemeldet
|
||||
{% elif "Scheckbuch" in member %}
|
||||
{% set logbook = member["Scheckbuch"] %}
|
||||
Scheckbuch (Ausfahrten: {{ logbook | length }})
|
||||
{% elif "Regular" in member %}
|
||||
Reguläres Vereinsmitglied
|
||||
{% elif "Foerdernd" in member %}
|
||||
Förderndes Vereinsmitglied
|
||||
{% elif "Unterstuetzend" in member %}
|
||||
Unterstützendes Vereinsmitglied
|
||||
{% endif %}
|
||||
</small>
|
||||
</h2>
|
||||
<div class="mx-3">
|
||||
{% if is_clubmember %}
|
||||
<div class="py-3 grid gap-3">
|
||||
<form action="/admin/user/{{ user.id }}/change-member-since" method="post">
|
||||
{{ macros::inputgroup(label='Mitglied seit', name='member_since', type="date", value=user.member_since_date, readonly=not allowed_to_edit) }}
|
||||
</form>
|
||||
<form action="/admin/user/{{ user.id }}/change-birthdate" method="post">
|
||||
{{ macros::inputgroup(label='Geburtsdatum', name='birthdate', type="date", value=user.birthdate, readonly=not allowed_to_edit) }}
|
||||
</form>
|
||||
<form action="/admin/user/{{ user.id }}/change-address" method="post">
|
||||
{{ macros::inputgroup(label='Adresse', name='address', type="text", value=user.address, readonly=not allowed_to_edit) }}
|
||||
</form>
|
||||
<form action="/admin/user/{{ user.id }}/change-skill" method="post">
|
||||
{% if user_skill %}
|
||||
{{ macros::selectgroup(label="Steuererlaubnis", data=skill, selected_id=user_skill.id, name='skill_id', display=['name'], default="Keine Steuerberechtigung", readonly=not allowed_to_edit) }}
|
||||
{% else %}
|
||||
{{ macros::selectgroup(label="Steuererlaubnis", data=skill, name='skill_id', display=['name'], default="Keine Steuerberechtigung", readonly=not allowed_to_edit) }}
|
||||
{% endif %}
|
||||
</form>
|
||||
<form action="/admin/user/{{ user.id }}/change-family" method="post">
|
||||
{{ macros::selectgroup(label="Familie", data=families, name='family_id', selected_id=user.family_id, display=['names'], default="Keine Familie", new_last_entry='Neue Familie anlegen', readonly=not allowed_to_edit) }}
|
||||
</form>
|
||||
</div>
|
||||
<div class="py-3">
|
||||
{% if user.membership_pdf %}
|
||||
<a href="/admin/user/{{ user.id }}/membership"
|
||||
class="link link-primary link-no-underline">Beitrittserklärung herunterladen ↓</a>
|
||||
{% else %}
|
||||
⚠️ Aktuell gibt's keine Beitrittserklärung 😢
|
||||
{% if allowed_to_edit %}
|
||||
Das kannst du hier ändern ⤵️
|
||||
<form action="/admin/user/{{ user.id }}/add-membership-pdf"
|
||||
method="post"
|
||||
enctype="multipart/form-data"
|
||||
class="grid gap-3">
|
||||
<fieldset>
|
||||
{{ macros::input(label='Neue Beitrittserklärung hochladen', name='membership_pdf', type="file", accept='application/pdf') }}
|
||||
</fieldset>
|
||||
<input value="Hochladen" type="submit" class="btn btn-primary" />
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if allowed_to_edit %}
|
||||
<div class="py-3">
|
||||
<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 mt-3"
|
||||
onclick="return confirm('Ist {{ user.name }} wirklich aus dem Verein ausgetreten?');">
|
||||
{% include "includes/delete-icon" %}
|
||||
Mitglied ist ausgetreten
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<dialog id="change-member-type"
|
||||
class="max-w-screen-sm w-full dark:bg-primary-900 dark:text-white rounded-md"
|
||||
onclick="document.getElementById('change-member-type').close()">
|
||||
<div onclick="event.stopPropagation();" class="p-3">
|
||||
<button type="button"
|
||||
onclick="document.getElementById('change-member-type').close()"
|
||||
title="Schließen"
|
||||
class="sidebar-close border-0 bg-primary-100 focus:bg-primary-50 text-black flex items-center justify-center transform rotate-45 absolute right-0 mr-3">
|
||||
<svg class="inline h-5 w-5"
|
||||
width="16"
|
||||
height="16"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 16 16">
|
||||
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
<div class="mt-8">
|
||||
<form action="/admin/user/{{ user.id }}/change-membertype"
|
||||
method="post"
|
||||
enctype="multipart/form-data"
|
||||
class="grid gap-3">
|
||||
<div>
|
||||
<label for="membertype" class="text-sm text-gray-600 dark:text-gray-100">Mitgliedsstatus</label>
|
||||
<select name="membertype" id="membertype" class="input rounded-md ">
|
||||
<option selected="" value="regular">Reguläres Vereinsmitglied</option>
|
||||
<option value="unterstuetzend">Unterstützendes Vereinsmitglied</option>
|
||||
<option value="foerdernd">Förderndes Vereinsmitglied</option>
|
||||
</select>
|
||||
</div>
|
||||
<input value="Ändern" type="submit" class="btn btn-primary" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
{% endif %}
|
||||
{% elif "Scheckbuch" in member %}
|
||||
{% if allowed_to_edit %}
|
||||
<div class="grid gap-3 pb-3">
|
||||
<div class="max-h-60 overflow-y-scroll">
|
||||
{% for log in logbook %}
|
||||
{{ log::show_old(log=log, state="completed", only_ones=false, index=loop.index, allowed_to_edit=false) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid pt-3">
|
||||
<a href="/admin/user/{{ user.id }}/delete"
|
||||
class="btn btn-alert"
|
||||
onclick="return confirm('Willst du die Daten von {{ user.name }} wirklich? Seine restlichen Scheckbuch-Ausfahrten entfallen damit...');">
|
||||
{% include "includes/delete-icon" %}
|
||||
Daten löschen
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% elif "SchnupperInterest" in member %}
|
||||
{% if allowed_to_edit %}
|
||||
<div class="grid pt-3">
|
||||
<a href="/admin/user/{{ user.id }}/schnupperinterest-to-schnupperant"
|
||||
class="btn btn-dark"
|
||||
onclick="return confirm('Hat sich \'{{ user.name }}\' wirklich zum Kurs angemeldet?');">Zum Schnupperkurs angemeldet</a>
|
||||
</div>
|
||||
<div class="grid pt-3">
|
||||
<a href="/admin/user/{{ user.id }}/schnupperinterest-to-scheckbuch"
|
||||
class="btn btn-dark"
|
||||
onclick="return confirm('Willst du \'{{ user.name }}\' wirklich auf ein Scheckbuch umwandeln?');">In Scheckbuch umwandeln</a>
|
||||
</div>
|
||||
<div class="grid pt-3">
|
||||
<a href="/admin/user/{{ user.id }}/delete"
|
||||
class="btn btn-alert"
|
||||
onclick="return confirm('Ist {{ user.name }} wirklich nicht mehr am Schnupperkurs interessiert?');">
|
||||
{% include "includes/delete-icon" %}
|
||||
Daten löschen
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% elif "Schnupperant" in member %}
|
||||
{% if allowed_to_edit %}
|
||||
<div class="grid pt-3">
|
||||
<a href="/admin/user/{{ user.id }}/schnupperant-to-schnupperinterest"
|
||||
class="btn btn-dark"
|
||||
onclick="return confirm('Hat sich \'{{ user.name }}\' wirklich vom Schnupperkurs abgemeldet?');">Vom Kurs abgemeldet</a>
|
||||
</div>
|
||||
<div class="grid pt-3">
|
||||
<a href="/admin/user/{{ user.id }}/schnupperant-to-scheckbuch"
|
||||
class="btn btn-dark"
|
||||
onclick="return confirm('Willst du \'{{ user.name }}\' wirklich auf ein Scheckbuch umwandeln?');">In Scheckbuch umwandeln</a>
|
||||
</div>
|
||||
<div class="grid pt-3">
|
||||
<a href="/admin/user/{{ user.id }}/delete"
|
||||
class="btn btn-alert"
|
||||
onclick="return confirm('Ist {{ user.name }} wirklich nicht mehr am Schnupperkurs interessiert?');">
|
||||
{% include "includes/delete-icon" %}
|
||||
Daten löschen
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if "Scheckbuch" in member or "Schnupperant" in member %}
|
||||
{% if allowed_to_edit %}
|
||||
<div class="grid gap-3 pb-3 mt-3">
|
||||
<button type="button"
|
||||
onclick="document.getElementById('call-for-action').showModal()"
|
||||
class="btn btn-primary">Zu Vereinsmitglied umwandeln</button>
|
||||
</div>
|
||||
<dialog id="call-for-action"
|
||||
class="max-w-screen-sm w-full dark:bg-primary-900 dark:text-white rounded-md"
|
||||
onclick="document.getElementById('call-for-action').close()">
|
||||
<div onclick="event.stopPropagation();" class="p-3">
|
||||
<button type="button"
|
||||
onclick="document.getElementById('call-for-action').close()"
|
||||
title="Schließen"
|
||||
class="sidebar-close border-0 bg-primary-100 focus:bg-primary-50 text-black flex items-center justify-center transform rotate-45 absolute right-0 mr-3">
|
||||
<svg class="inline h-5 w-5"
|
||||
width="16"
|
||||
height="16"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 16 16">
|
||||
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
<div class="mt-8">
|
||||
{% if "Scheckbuch" in member %}
|
||||
{% set action = "scheckbook-to-regular" %}
|
||||
{% elif "Schnupperant" in member %}
|
||||
{% set action = "schnupperant-to-regular" %}
|
||||
{% endif %}
|
||||
<form action="/admin/user/{{ user.id }}/{{ action }}"
|
||||
method="post"
|
||||
enctype="multipart/form-data"
|
||||
class="grid gap-3">
|
||||
<div>
|
||||
<label for="membertype" class="text-sm text-gray-600 dark:text-gray-100">Mitgliedstyp</label>
|
||||
<select name="membertype" id="membertype" class="input rounded-md ">
|
||||
<option selected="" value="regular">Reguläres Vereinsmitglied</option>
|
||||
<option value="unterstuetzend">Unterstützendes Vereinsmitglied</option>
|
||||
<option value="foerdernd">Förderndes Vereinsmitglied</option>
|
||||
</select>
|
||||
</div>
|
||||
{{ macros::input(label='Mitglied seit', name='member_since', type="date", value=now() | date(), required=true) }}
|
||||
{{ macros::input(label='Geburtsdatum', name='birthdate', type="date", value=user.birthdate, required=true) }}
|
||||
{{ macros::input(label='Telefonnummer', name='phone', type="text", value=user.phone, required=true) }}
|
||||
{{ macros::input(label='Adresse', name='address', type="text", value=user.address, required=true) }}
|
||||
{{ macros::input(label='Beitrittserklärung', name='membership_pdf', type="file", accept='application/pdf', required=true) }}
|
||||
<input value="Als neues, reguläres Mitglied anlegen"
|
||||
type="submit"
|
||||
class="btn btn-primary" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% if is_clubmember %}
|
||||
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow">
|
||||
<h2 class="h2">Rollen</h2>
|
||||
<div>
|
||||
<ul class="divide-y divide-gray-200 dark:divide-primary-60 w-full">
|
||||
{% for role in user.proper_roles -%}
|
||||
{% if not role.cluster and not role.hide_in_lists %}
|
||||
<li class="flex w-full justify-between items-center p-3 {% if allowed_to_edit %}hover:bg-gray-100 dark:hover:bg-primary-950{% endif %}">
|
||||
<span>
|
||||
<strong>
|
||||
{% if role.formatted_name %}
|
||||
{{ role.formatted_name }}
|
||||
{% else %}
|
||||
{{ role.name }}
|
||||
{% endif %}
|
||||
</strong>
|
||||
<br />
|
||||
<small>{{ role.desc }}</small>
|
||||
</span>
|
||||
{% if allowed_to_edit %}
|
||||
<a href="/admin/user/{{ user.id }}/remove-role/{{ role.id }}"
|
||||
onclick="return confirm('Willst du die Rolle \'{{ role.name }}\' von {{ user.name }} wirklich entfernen?');">🗑️</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% if allowed_to_edit %}
|
||||
<div class="m-3">
|
||||
<button type="button"
|
||||
onclick="document.getElementById('role-modal').showModal()"
|
||||
class="btn btn-primary w-full">Rolle hinzufügen</button>
|
||||
</div>
|
||||
<dialog id="role-modal"
|
||||
class="max-w-screen-sm w-full dark:bg-primary-900 dark:text-white rounded-md"
|
||||
onclick="document.getElementById('role-modal').close()">
|
||||
<div onclick="event.stopPropagation();" class="p-3">
|
||||
<button type="button"
|
||||
onclick="document.getElementById('role-modal').close()"
|
||||
title="Schließen"
|
||||
class="sidebar-close border-0 bg-primary-100 focus:bg-primary-50 text-black flex items-center justify-center transform rotate-45 absolute right-0 mr-3">
|
||||
<svg class="inline h-5 w-5"
|
||||
width="16"
|
||||
height="16"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 16 16">
|
||||
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
<div class="mt-8">
|
||||
<form action="/admin/user/{{ user.id }}/add-role"
|
||||
method="post"
|
||||
class="grid gap-3">
|
||||
<div>
|
||||
<label for="role_id" class="text-sm text-gray-600 dark:text-gray-100">Rollen</label>
|
||||
<select name="role_id" id="role_id" class="input rounded-md ">
|
||||
{% for role in roles %}
|
||||
{% if not role.cluster and role not in user.proper_roles and not role.hide_in_lists %}
|
||||
<option value="{{ role.id }}">
|
||||
{% if role.formatted_name %}
|
||||
{{ role.formatted_name }}
|
||||
{% else %}
|
||||
{{ role.name }}
|
||||
{% endif %}
|
||||
</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<input value="Rolle hinzufügen" type="submit" class="btn btn-primary" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if supposed_to_pay %}
|
||||
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow">
|
||||
<h2 class="h2">💸-Beitrag</h2>
|
||||
<div class="mx-3 divide-y divide-gray-200 dark:divide-primary-600">
|
||||
<div class="py-3">
|
||||
{% if fee %}
|
||||
<div>
|
||||
<strong>{{ fee.name }}</strong>
|
||||
<span class="block">{{ fee.sum_in_cents / 100 }}€</span>
|
||||
</div>
|
||||
<div>
|
||||
{% for p in fee.parts %}
|
||||
{{ p.0 }} ({{ p.1 / 100 }}€)
|
||||
{% if not loop.last %}+{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if "paid" in user.roles %}
|
||||
✅ bezahlt
|
||||
{% else %}
|
||||
❌ Zahlung ausständig
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if "paid" in user.roles %}
|
||||
✅
|
||||
{% for key, value in member %}
|
||||
{% if loop.first %}{{ key }}{% endif %}
|
||||
{% endfor %}
|
||||
hat schon bezahlt
|
||||
{% else %}
|
||||
❌
|
||||
{% for key, value in member %}
|
||||
{% if loop.first %}{{ key }}{% endif %}
|
||||
{% endfor %}
|
||||
hat noch nicht bezahlt
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% 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 max-h-60 overflow-y-scroll">
|
||||
<div class="py-3">
|
||||
<ul class="list-disc ms-4">
|
||||
{% for activity in activities %}
|
||||
<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 %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow">
|
||||
<h2 class="h2">Ergo-Challenge</h2>
|
||||
<div class="mx-3">
|
||||
<div class="grid gap-3 pb-3 mt-3">
|
||||
{{ macros::inputgroup(label='DOB', name='dob', type="text", value=user.dob, readonly=allowed_to_edit == false) }}
|
||||
{{ macros::inputgroup(label='Weight (kg)', name='weight', type="text", value=user.weight, readonly=allowed_to_edit == false) }}
|
||||
{{ macros::inputgroup(label='Sex', name='sex', type="text", value=user.sex, readonly=allowed_to_edit == false) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
@ -7,7 +7,7 @@
|
||||
<summary>Dirty Thirty</summary>
|
||||
<p>
|
||||
<div class="border-r border-l">
|
||||
<textarea style="width: 100%; height: 300px;">
|
||||
<textarea style="width: 100%; height: 300px;">
|
||||
{%- for stat in thirty %}
|
||||
{%- set names = stat.name | split(pat=" ") %}{% set lastname_index = names | length - 1 %}{% set lastname = names[lastname_index] %}{{ lastname }}	
|
||||
{%- for name in names -%}
|
||||
@ -23,7 +23,7 @@
|
||||
<summary>Dirty Dozen</summary>
|
||||
<p>
|
||||
<div class="border-r border-l">
|
||||
<textarea style="width: 100%; height: 300px;">
|
||||
<textarea style="width: 100%; height: 300px;">
|
||||
{%- for stat in dozen -%}
|
||||
{%- set names = stat.name | split(pat=" ") %}{% set lastname_index = names | length - 1 %}{% set lastname = names[lastname_index] %}{{ lastname }}	
|
||||
{%- for name in names -%}
|
||||
|
@ -21,8 +21,8 @@
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="https://data.ergochallenge.at"
|
||||
target="_blank"
|
||||
style="text-decoration: underline">Offizielle Ergebnisse</a>, bei Fehlern direkt mit <a href="mailto:office@ergochallenge.at"
|
||||
target="_blank"
|
||||
style="text-decoration: underline">Offizielle Ergebnisse</a>, bei Fehlern direkt mit <a href="mailto:office@ergochallenge.at"
|
||||
style="text-decoration: underline">Christian (Ister)</a> Kontakt aufnehmen
|
||||
</li>
|
||||
</ul>
|
||||
@ -75,8 +75,8 @@
|
||||
<div class="pt-3">
|
||||
<p>
|
||||
Folgende Daten hat der Ruderassistent von dir. Wenn diese nicht mehr aktuell sind, bitte gewünschte Änderungen an unseren Schriftführer melden (<a href="mailto:info@rudernlinz.at"
|
||||
class="text-primary-600 dark:text-primary-200 hover:text-primary-950 hover:dark:text-primary-300 underline"
|
||||
target="_blank">it@rudernlinz.at</a>).
|
||||
class="text-primary-600 dark:text-primary-200 hover:text-primary-950 hover:dark:text-primary-300 underline"
|
||||
target="_blank">it@rudernlinz.at</a>).
|
||||
<br />
|
||||
<br />
|
||||
<ul>
|
||||
|
@ -6,11 +6,11 @@
|
||||
{{ macros::input(label='Anzahl Ruderer (ohne Steuerperson)', name='max_people', type='number', required=true, min='0') }}
|
||||
{{ macros::checkbox(label='Scheckbuch-Anmeldungen erlauben', name='allow_guests') }}
|
||||
{{ macros::input(label='Anmerkungen', name='notes', type='input') }}
|
||||
{% if loggedin_user.allowed_to_steer %}
|
||||
{{ macros::select(label='Typ', data=trip_types, name='trip_type', default='Reguläre Ausfahrt') }}
|
||||
{% else %}
|
||||
{{ macros::select(label='Typ', data=trip_types, name='trip_type', only_ergo=true) }}
|
||||
{% endif %}
|
||||
{% if loggedin_user.allowed_to_steer %}
|
||||
{{ macros::select(label='Typ', data=trip_types, name='trip_type', default='Reguläre Ausfahrt') }}
|
||||
{% else %}
|
||||
{{ macros::select(label='Typ', data=trip_types, name='trip_type', only_ergo=true) }}
|
||||
{% endif %}
|
||||
<input value="Erstellen" class="w-full btn btn-primary" type="submit" />
|
||||
</form>
|
||||
</div>
|
||||
|
@ -82,7 +82,13 @@
|
||||
<label for="{{ id }}" class="text-sm text-gray-600 dark:text-gray-100">
|
||||
Ruderer (inkl. Schiffsführer und Steuerperson)
|
||||
</label>
|
||||
<select style="width: 100%;" multiple name="rowers[]" id="{{ id }}" class="w-full" data-seats="{{ amount_seats }}" data-init={{ init }}>
|
||||
<select style="width: 100%"
|
||||
multiple
|
||||
name="rowers[]"
|
||||
id="{{ id }}"
|
||||
class="w-full"
|
||||
data-seats="{{ amount_seats }}"
|
||||
data-init="{{ init }}">
|
||||
{% for user in users %}
|
||||
{% set_global sel = false %}
|
||||
{% for rower in selected %}
|
||||
@ -177,104 +183,131 @@
|
||||
<div class="border-t bg-white dark:bg-primary-900 py-3 px-4 relative"
|
||||
data-filterable="true"
|
||||
data-filter="{{ log.boat.name }} {% for rower in log.rowers %}{{ rower.name }}{% endfor %}">
|
||||
<details>
|
||||
<summary style="list-style: none;">
|
||||
{% if log.logtype and not hide_type %}
|
||||
<div class="absolute top-0 right-0 bg-primary-100 rounded-bl-md text-primary-950 text-xs w-32 px-2 py-1 text-center font-bold">
|
||||
{% if log.logtype == 1 %}
|
||||
Wanderfahrt
|
||||
{% else %}
|
||||
{% if log.logtype == 2 %}
|
||||
Regatta
|
||||
{% else %}
|
||||
{{ log.logtype }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div {% if log.logtype %}class="mt-4 sm:mt-0"{% endif %}>
|
||||
<strong class="text-black dark:text-white">{{ log.boat.name }}</strong>
|
||||
<small class="text-gray-600 dark:text-gray-100">({{ log.shipmaster_user.name -}}
|
||||
{% if log.shipmaster_only_steering %}
|
||||
- handgesteuert
|
||||
{%- endif -%}
|
||||
)</small>
|
||||
<small class="block text-gray-600 dark:text-gray-100">
|
||||
{% if state == "completed" and log.departure | date(format='%d.%m.%Y') == log.arrival | date(format='%d.%m.%Y') %}
|
||||
{{ log.departure | date(format='%d.%m.%Y') }}
|
||||
({{ log.departure | date(format='%H:%M') }}
|
||||
-
|
||||
{{ log.arrival | date(format='%H:%M') }})
|
||||
{% else %}
|
||||
{{ log.departure | date(format='%d.%m.%Y (%H:%M)') }}
|
||||
{% if state == "completed" %}
|
||||
-
|
||||
{{ log.arrival | date(format='%d.%m.%Y (%H:%M)') }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</small>
|
||||
{% set amount_rowers = log.rowers | length %}
|
||||
{% set amount_guests = log.boat.amount_seats - amount_rowers %}
|
||||
{% if allowed_to_close and state == "on_water" %}
|
||||
{{ log::home(log=log) }}
|
||||
{% if log.logtype and not hide_type %}
|
||||
<div class="absolute top-0 right-0 bg-primary-100 rounded-bl-md text-primary-950 text-xs w-32 px-2 py-1 text-center font-bold">
|
||||
{% if log.logtype == 1 %}
|
||||
Wanderfahrt
|
||||
{% else %}
|
||||
{% if log.logtype == 2 %}
|
||||
Regatta
|
||||
{% else %}
|
||||
<div class="text-black dark:text-white">
|
||||
{{ log.destination }}
|
||||
{% if state == "completed" %}
|
||||
<small class="text-gray-600 dark:text-gray-100">({{ log.distance_in_km }}
|
||||
km)</small>
|
||||
{% endif %}
|
||||
{% if log.comments %}<span class="text-sm italic">- "{{ log.comments }}"</span>{% endif %}
|
||||
</div>
|
||||
{% if amount_guests > 0 or log.rowers | length > 0 %}
|
||||
{% if not log.boat.amount_seats == 1 %}
|
||||
<div class="text-sm text-gray-600 dark:text-gray-100">
|
||||
Ruderer:
|
||||
{% for rower in log.rowers -%}
|
||||
{{ rower.name }}
|
||||
{%- if rower.id == log.steering_user.id and rower.id != log.shipmaster_user.id %}
|
||||
(Steuerperson){%- endif -%}
|
||||
{%- if not loop.last or amount_guests > 0 and not log.boat.external %},{% endif %}
|
||||
{% endfor -%}
|
||||
{% if amount_guests > 0 and not log.boat.external %}
|
||||
Gäste
|
||||
<small class="text-gray-600 dark:text-gray-100">(ohne Account)</small>:
|
||||
{{ amount_guests }}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</summary>
|
||||
{% if allowed_to_edit %}
|
||||
<form action="/log/update" method="post">
|
||||
<input type="hidden" name="id" value="{{ log.id }}" />
|
||||
<input type="hidden" name="boat_id" value="{{ log.boat_id }}" />
|
||||
<input type="hidden" name="shipmaster" value="{{ log.shipmaster }}" />
|
||||
<input type="hidden"
|
||||
name="steering_person"
|
||||
value="{{ log.steering_person }}" />
|
||||
Handgesteuert:
|
||||
<input type="checkbox"
|
||||
name="shipmaster_only_steering"
|
||||
{% if log.shipmaster_only_steering %}checked="checked"{% endif %} />
|
||||
<input type="datetime-local" name="departure" value="{{ log.departure }}" />
|
||||
<input type="datetime-local" 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 }}" />
|
||||
<input type="hidden" name="logtype" value="{{ log.logtype }}" />
|
||||
<input type="submit" value="Updaten" />
|
||||
</form>
|
||||
<a href="/log/{{ log.id }}/delete"
|
||||
class="w-28 btn btn-alert"
|
||||
onclick="return confirm('Willst du diesen Logbucheintrag wirklich löschen?');">
|
||||
{% include "includes/delete-icon" %}
|
||||
Löschen
|
||||
</a>
|
||||
{{ log.logtype }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</details>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div {% if log.logtype %}class="mt-4 sm:mt-0"{% endif %}>
|
||||
{% if allowed_to_edit %}
|
||||
<a href="#"
|
||||
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>
|
||||
{% endif %}
|
||||
<small class="text-gray-600 dark:text-gray-100">({{ log.shipmaster_user.name -}}
|
||||
{% if log.shipmaster_only_steering %}
|
||||
- handgesteuert
|
||||
{%- endif -%}
|
||||
)</small>
|
||||
<small class="block text-gray-600 dark:text-gray-100">
|
||||
{% if state == "completed" and log.departure | date(format='%d.%m.%Y') == log.arrival | date(format='%d.%m.%Y') %}
|
||||
{{ log.departure | date(format='%d.%m.%Y') }}
|
||||
({{ log.departure | date(format='%H:%M') }}
|
||||
-
|
||||
{{ log.arrival | date(format='%H:%M') }})
|
||||
{% else %}
|
||||
{{ log.departure | date(format='%d.%m.%Y (%H:%M)') }}
|
||||
{% if state == "completed" %}
|
||||
-
|
||||
{{ log.arrival | date(format='%d.%m.%Y (%H:%M)') }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</small>
|
||||
{% set amount_rowers = log.rowers | length %}
|
||||
{% set amount_guests = log.boat.amount_seats - amount_rowers %}
|
||||
{% if allowed_to_close and state == "on_water" %}
|
||||
{{ log::home(log=log) }}
|
||||
{% else %}
|
||||
<div class="text-black dark:text-white">
|
||||
{{ log.destination }}
|
||||
{% if state == "completed" %}
|
||||
<small class="text-gray-600 dark:text-gray-100">({{ log.distance_in_km }}
|
||||
km)</small>
|
||||
{% endif %}
|
||||
{% if log.comments %}<span class="text-sm italic">- "{{ log.comments }}"</span>{% endif %}
|
||||
</div>
|
||||
{% if amount_guests > 0 or log.rowers | length > 0 %}
|
||||
{% if not log.boat.amount_seats == 1 %}
|
||||
<div class="text-sm text-gray-600 dark:text-gray-100">
|
||||
Ruderer:
|
||||
{% for rower in log.rowers -%}
|
||||
{{ rower.name }}
|
||||
{%- if rower.id == log.steering_user.id and rower.id != log.shipmaster_user.id %}
|
||||
(Steuerperson){%- endif -%}
|
||||
{%- if not loop.last or amount_guests > 0 and not log.boat.external %},{% endif %}
|
||||
{% endfor -%}
|
||||
{% if amount_guests > 0 and not log.boat.external %}
|
||||
Gäste
|
||||
<small class="text-gray-600 dark:text-gray-100">(ohne Account)</small>:
|
||||
{{ amount_guests }}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if allowed_to_edit %}
|
||||
<dialog id="change-{{ log.id }}"
|
||||
class="max-w-screen-sm w-full dark:bg-primary-900 dark:text-white rounded-md"
|
||||
onclick="document.getElementById('change-{{ log.id }}').close()">
|
||||
<div onclick="event.stopPropagation();" class="p-3">
|
||||
<button type="button"
|
||||
onclick="document.getElementById('change-{{ log.id }}').close()"
|
||||
title="Schließen"
|
||||
class="sidebar-close border-0 bg-primary-100 focus:bg-primary-50 text-black flex items-center justify-center transform rotate-45 absolute right-0 mr-3">
|
||||
<svg class="inline h-5 w-5"
|
||||
width="16"
|
||||
height="16"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 16 16">
|
||||
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
<div class="mt-8">
|
||||
<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 }}" />
|
||||
<input type="hidden" name="boat_id" value="{{ log.boat_id }}" />
|
||||
<input type="hidden" name="shipmaster" value="{{ log.shipmaster }}" />
|
||||
<input type="hidden"
|
||||
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="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 }}" />
|
||||
<input type="hidden" name="logtype" value="{{ log.logtype }}" />
|
||||
<input type="submit" class="btn btn-primary" value="Updaten" />
|
||||
</form>
|
||||
<a href="/log/{{ log.id }}/delete"
|
||||
class="w-28 btn btn-alert mt-3"
|
||||
onclick="return confirm('Willst du diesen Logbucheintrag wirklich löschen?');">
|
||||
{% include "includes/delete-icon" %}
|
||||
Löschen
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endmacro show_old %}
|
||||
{% macro home(log) %}
|
||||
|
@ -156,7 +156,7 @@ function setChoiceByLabel(choicesInstance, label) {
|
||||
</header>
|
||||
<div class="h-8"></div>
|
||||
{% endmacro header %}
|
||||
{% macro input(label, name, type, required=false, class='rounded-md', value='', min='', hide_label=false, id='', autofocus=false, wrapper_class='', pattern='', readonly=false, accept='') %}
|
||||
{% macro input(label, name, type, required=false, class='rounded-md', value='', min='', hide_label=false, id='', autofocus=false, wrapper_class='', pattern='', readonly=false, accept='', placeholder='') %}
|
||||
<div class="{{ wrapper_class }}">
|
||||
<label for="{{ name }}"
|
||||
class="{% if hide_label %} sr-only {% else %} text-sm text-gray-600 dark:text-white {% endif %}">
|
||||
@ -169,14 +169,98 @@ function setChoiceByLabel(choicesInstance, label) {
|
||||
{% if required %}required{% endif %}
|
||||
value="{{ value }}"
|
||||
class="input {{ class }}"
|
||||
placeholder="{% if hide_label %}{{ label }}{% endif %}"
|
||||
placeholder="{% if hide_label %}{{ label }}{% endif %}{% if placeholder %}{{ placeholder }}{% endif %}"
|
||||
{% if min is defined %}min="{{ min }}"{% endif %}
|
||||
{% if autofocus %}autofocus{% endif %}
|
||||
{% if accept %}accept="{{ accept }}"{% endif %}
|
||||
{% if pattern %}pattern="{{ pattern }}"{% endif %}
|
||||
{% if readonly %}readonly{% endif %}>
|
||||
{% if readonly %}readonly{% endif %} />
|
||||
</div>
|
||||
{% endmacro input %}
|
||||
{% macro inputgroup(label, name, type, required=false, class='', value='', min='', hide_label=false, id='', autofocus=false, wrapper_class='', pattern='', readonly=false, accept='') %}
|
||||
<div class="{{ wrapper_class }}">
|
||||
<label for="{{ name }}"
|
||||
class="{% if hide_label %} sr-only {% else %} text-sm text-gray-600 dark:text-white {% endif %}">
|
||||
{{ label }}
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<input {% if type=='datetime-local' %}onclick='if (!this.value) setCurrentdate(this)'{% endif %}
|
||||
{% if id %} id="{{ id }}" {% else %} id="{{ name }}" {% endif %}
|
||||
name="{{ name }}"
|
||||
type="{{ type }}"
|
||||
{% if required %}required{% endif %}
|
||||
value="{{ value }}"
|
||||
class="input {% if readonly %}rounded-md{% else %}rounded-l-md{% endif %} {{ class }}"
|
||||
placeholder="{% if hide_label %}{{ label }}{% endif %}"
|
||||
{% if min is defined %}min="{{ min }}"{% endif %}
|
||||
{% if autofocus %}autofocus{% endif %}
|
||||
{% if accept %}accept="{{ accept }}"{% endif %}
|
||||
{% if pattern %}pattern="{{ pattern }}"{% endif %}
|
||||
readonly />
|
||||
{% if allowed_to_edit %}
|
||||
<button type="button" class="btn btn-dark rounded-l-none-important edit-js">
|
||||
{% include "includes/pencil" %}
|
||||
<span class="sr-only">Bearbeiten</span>
|
||||
</button>
|
||||
<input value="x"
|
||||
type="reset"
|
||||
class="edit-js btn btn-alert btn-hidden rounded-none-important" />
|
||||
<input value="💾"
|
||||
type="submit"
|
||||
class="btn btn-primary btn-hidden rounded-l-none-important" />
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro inputgroup %}
|
||||
{% macro selectgroup(label, data, name='trip_type', default='', id='', selected_id='', display='', extras='', class='', wrapper_class='', required=false, show_seats=false, new_last_entry='', nonSelectableDefault=false, only_ergo=false, readonly=false) %}
|
||||
<div class="{{ wrapper_class }}">
|
||||
<label for="{{ name }}" class="text-sm text-gray-600 dark:text-gray-100">{{ label }}</label>
|
||||
{% if display == '' %}
|
||||
{% set display = ["name"] %}
|
||||
{% endif %}
|
||||
<div class="input-group">
|
||||
<select name="{{ name }}"
|
||||
{% if id %} id="{{ id }}" {% else %} id="{{ name }}" {% endif %}
|
||||
class="input {% if readonly %}rounded-md{% else %}rounded-l-md{% endif %} {{ class }}"
|
||||
{% if required %}required="required"{% endif %}
|
||||
disabled>
|
||||
{% if default %}<option selected value>{{ default }}</option>{% endif %}
|
||||
{% if nonSelectableDefault %}<option disabled selected value>{{ nonSelectableDefault }}</option>{% endif %}
|
||||
{% for d in data %}
|
||||
<option value="{{ d.id }}"
|
||||
{% if only_ergo and d.id!=4 %}disabled{% endif %}
|
||||
{% if d.id == selected_id %}selected{% endif %}
|
||||
{% if extras != '' %} {% for extra in extras %} {% if extra != 'on_water' and d[extra] %} data- {{ extra }}={{ d[extra] }} {% else %} {% if d[extra] %}disabled{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if show_seats %} data-custom-properties='{"amount_seats": {{ d["amount_seats"] }}, "owner": "{{ d["owner"] }}", "default_destination": "{{ d["default_destination"] }}", "boat_in_ottensheim": {{ d["location_id"] == 2 }}, "boat_reserved_today": {{ d["reserved_today"] }}, "convert_handoperated_possible": {{ d["convert_handoperated_possible"] }}, "default_handoperated": {{ d["default_shipmaster_only_steering"] }}}' {% endif %}>
|
||||
{% for displa in display -%}
|
||||
{%- if d[displa] -%}
|
||||
{{- d[displa] -}}
|
||||
{%- else -%}
|
||||
{{- displa -}}
|
||||
{%- endif -%}
|
||||
{%- endfor %}
|
||||
</option>
|
||||
{% endfor %}
|
||||
{% if new_last_entry %}<option value="-1">{{ new_last_entry }}</option>{% endif %}
|
||||
</select>
|
||||
{% if allowed_to_edit %}
|
||||
<button type="button" class="btn btn-dark rounded-l-none-important edit-js">
|
||||
{% include "includes/pencil" %}
|
||||
<span class="sr-only">Bearbeiten</span>
|
||||
</button>
|
||||
<input value="x"
|
||||
type="reset"
|
||||
class="edit-js btn btn-alert btn-hidden rounded-none-important" />
|
||||
<input value="💾"
|
||||
type="submit"
|
||||
class="btn btn-primary btn-hidden rounded-l-none-important" />
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro selectgroup %}
|
||||
{% macro checkbox(label, name, id='', checked=false, class='', disabled=false, readonly=false) %}
|
||||
<label for="{{ name }}{{ id }}"
|
||||
class="flex items-center cursor-pointer text-black dark:text-white hover:text-gray-900 dark:hover:text-gray-100 {{ class }}">
|
||||
@ -203,7 +287,14 @@ function setChoiceByLabel(choicesInstance, label) {
|
||||
{% if default %}<option selected value>{{ default }}</option>{% endif %}
|
||||
{% if nonSelectableDefault %}<option disabled selected value>{{ nonSelectableDefault }}</option>{% endif %}
|
||||
{% for d in data %}
|
||||
<option value="{{ d.id }}" {% if only_ergo and d.id!=4 %} disabled {% endif %}{% if d.id == selected_id %}selected{% endif %} {% if extras != '' %} {% for extra in extras %} {% if extra != 'on_water' and d[extra] %} data- {{ extra }}={{ d[extra] }} {% else %} {% if d[extra] %}disabled{% endif %} {% endif %} {% endfor %} {% endif %} {% if show_seats %} data-custom-properties='{"amount_seats": {{ d["amount_seats"] }}, "owner": "{{ d["owner"] }}", "default_destination": "{{ d["default_destination"] }}", "boat_in_ottensheim": {{ d["location_id"] == 2 }}, "boat_reserved_today": {{ d["reserved_today"] }}, "convert_handoperated_possible": {{ d["convert_handoperated_possible"] }}, "default_handoperated": {{ d["default_shipmaster_only_steering"] }}}' {% endif %}>
|
||||
<option value="{{ d.id }}"
|
||||
{% if only_ergo and d.id!=4 %}disabled{% endif %}
|
||||
{% if d.id == selected_id %}selected{% endif %}
|
||||
{% if extras != '' %} {% for extra in extras %} {% if extra != 'on_water' and d[extra] %} data- {{ extra }}={{ d[extra] }} {% else %} {% if d[extra] %}disabled{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if show_seats %} data-custom-properties='{"amount_seats": {{ d["amount_seats"] }}, "owner": "{{ d["owner"] }}", "default_destination": "{{ d["default_destination"] }}", "boat_in_ottensheim": {{ d["location_id"] == 2 }}, "boat_reserved_today": {{ d["reserved_today"] }}, "convert_handoperated_possible": {{ d["convert_handoperated_possible"] }}, "default_handoperated": {{ d["default_shipmaster_only_steering"] }}}' {% endif %}>
|
||||
{% for displa in display -%}
|
||||
{%- if d[displa] -%}
|
||||
{{- d[displa] -}}
|
||||
|
@ -32,7 +32,9 @@
|
||||
<h2 class="h2">Nachrichten</h2>
|
||||
{% if loggedin_user.amount_unread_notifications > 10 %}
|
||||
<div class="text-primary-950 dark:text-white bg-gray-200 dark:bg-primary-950 bg-opacity-80 text-center pb-3 px-3">
|
||||
Du hast viele ungelesene Benachrichtigungen. Um deine Oberfläche übersichtlich zu halten und wichtige Updates nicht zu verpassen, nimm dir bitte in Zukunft einen kurzen Moment Zeit sie zu überprüfen und als gelesen zu markieren (✓).<br /><a href="/notification/read/all" class="underline">Du kannst hier ausnahmsweise alle als gelesen markieren.</a>
|
||||
Du hast viele ungelesene Benachrichtigungen. Um deine Oberfläche übersichtlich zu halten und wichtige Updates nicht zu verpassen, nimm dir bitte in Zukunft einen kurzen Moment Zeit sie zu überprüfen und als gelesen zu markieren (✓).
|
||||
<br />
|
||||
<a href="/notification/read/all" class="underline">Du kannst hier ausnahmsweise alle als gelesen markieren.</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="divide-y">
|
||||
@ -210,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"
|
||||
@ -234,93 +237,88 @@
|
||||
role="alert">
|
||||
<h2 class="h2">Vereinsmitglied</h2>
|
||||
<ul class="list-none ms-2 divide-y divide-gray-200 dark:divide-primary-600">
|
||||
{% if "Unterstützend" not in loggedin_user.roles and "Förderndes Mitglied" not in loggedin_user.roles %}
|
||||
<li class="py-1">
|
||||
<a href="/planned" class="block w-100 py-2 hover:text-primary-600">Geplante Ausfahrten</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/log" class="block w-100 py-2 hover:text-primary-600">Ausfahrt eintragen</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/log/show" class="block w-100 py-2 hover:text-primary-600">Logbuch</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/stat" class="block w-100 py-2 hover:text-primary-600">Statistik</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/stat/boats" class="block w-100 py-2 hover:text-primary-600">Bootsauswertung</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/boatdamage" class="block w-100 py-2 hover:text-primary-600">Bootsschaden</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/boatreservation"
|
||||
class="block w-100 py-2 hover:text-primary-600">Bootsreservierung</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/trailerreservation"
|
||||
class="block w-100 py-2 hover:text-primary-600">Hängerreservierung</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/steering" class="block w-100 py-2 hover:text-primary-600">Steuerleute & Co</a>
|
||||
</li>
|
||||
<div class="py-3">
|
||||
<p>
|
||||
<details>
|
||||
<summary>
|
||||
Kalender
|
||||
</summary>
|
||||
<p class="mt-3">
|
||||
Du möchtest immer up-to-date mit den Events und Ausfahrten bleiben? Wir bieten 3 verschiedene Arten von Kalender an:
|
||||
</p>
|
||||
<ol class="list-decimal ml-5 my-3">
|
||||
<li>
|
||||
<strong>Alle Events und Ausfahrten</strong>, zu denen du dich angemeldet hast: <a class="underline break-all"
|
||||
{% if "Unterstützend" not in loggedin_user.roles and "Förderndes Mitglied" not in loggedin_user.roles %}
|
||||
<li class="py-1">
|
||||
<a href="/planned" class="block w-100 py-2 hover:text-primary-600">Geplante Ausfahrten</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/log" class="block w-100 py-2 hover:text-primary-600">Ausfahrt eintragen</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/log/show" class="block w-100 py-2 hover:text-primary-600">Logbuch</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/stat" class="block w-100 py-2 hover:text-primary-600">Statistik</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/stat/boats" class="block w-100 py-2 hover:text-primary-600">Bootsauswertung</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/boatdamage" class="block w-100 py-2 hover:text-primary-600">Bootsschaden</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/boatreservation"
|
||||
class="block w-100 py-2 hover:text-primary-600">Bootsreservierung</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/trailerreservation"
|
||||
class="block w-100 py-2 hover:text-primary-600">Hängerreservierung</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/steering" class="block w-100 py-2 hover:text-primary-600">Steuerleute & Co</a>
|
||||
</li>
|
||||
<div class="py-3">
|
||||
<p>
|
||||
<details>
|
||||
<summary>Kalender</summary>
|
||||
<p class="mt-3">
|
||||
Du möchtest immer up-to-date mit den Events und Ausfahrten bleiben? Wir bieten 3 verschiedene Arten von Kalender an:
|
||||
</p>
|
||||
<ol class="list-decimal ml-5 my-3">
|
||||
<li>
|
||||
<strong>Alle Events und Ausfahrten</strong>, zu denen du dich angemeldet hast: <a class="underline break-all"
|
||||
href="https://app.rudernlinz.at/cal/personal/{{ loggedin_user.id }}/{{ loggedin_user.user_token }}">https://app.rudernlinz.at/cal/personal/{{ loggedin_user.id }}/{{ loggedin_user.user_token }}</a>
|
||||
<br />
|
||||
<small>Dieser Link enthält einen zufällig generierten Teil, damit nur du (und jene, denen du diesen Link weitergibst) Zugang zu diesen Daten hast.</small>
|
||||
</li>
|
||||
<li>
|
||||
<strong>Allgemeiner Kalender</strong>, zB save-the-dates (Wanderfahrten, ...): <a href="https://rudernlinz.at/cal" class="break-all underline">https://rudernlinz.at/cal</a>
|
||||
</li>
|
||||
<li>
|
||||
<strong>Alle Events</strong>: <a class="break-all underline" href="https://app.rudernlinz.at/cal">https://app.rudernlinz.at/cal</a>
|
||||
<br />
|
||||
<small>Beachte, dass dieser Kalender keine Ausfahrten enthält, die von einzelnen Steuerpersonen augeschrieben werden. Dieser Kalender wird zB auf <a href="https://rudernlinz.at/termine" class="underline">https://rudernlinz.at/termine</a> verwendet und wir möchten keine persönlichen Daten (Namen etc.) leaken.</small>
|
||||
</li>
|
||||
</ol>
|
||||
Du kannst die Kalender einfach in deinen Kalender als "externen Kalender" synchronisieren. Die genauen Schritte hängen von deiner verwendeten Software ab.
|
||||
</details>
|
||||
</p>
|
||||
</div>
|
||||
<br />
|
||||
<small>Dieser Link enthält einen zufällig generierten Teil, damit nur du (und jene, denen du diesen Link weitergibst) Zugang zu diesen Daten hast.</small>
|
||||
</li>
|
||||
<li>
|
||||
<strong>Allgemeiner Kalender</strong>, zB save-the-dates (Wanderfahrten, ...): <a href="https://rudernlinz.at/cal" class="break-all underline">https://rudernlinz.at/cal</a>
|
||||
</li>
|
||||
<li>
|
||||
<strong>Alle Events</strong>: <a class="break-all underline" href="https://app.rudernlinz.at/cal">https://app.rudernlinz.at/cal</a>
|
||||
<br />
|
||||
<small>Beachte, dass dieser Kalender keine Ausfahrten enthält, die von einzelnen Steuerpersonen augeschrieben werden. Dieser Kalender wird zB auf <a href="https://rudernlinz.at/termine" class="underline">https://rudernlinz.at/termine</a> verwendet und wir möchten keine persönlichen Daten (Namen etc.) leaken.</small>
|
||||
</li>
|
||||
</ol>
|
||||
Du kannst die Kalender einfach in deinen Kalender als "externen Kalender" synchronisieren. Die genauen Schritte hängen von deiner verwendeten Software ab.
|
||||
</details>
|
||||
</p>
|
||||
</div>
|
||||
<div class="py-3">
|
||||
<p>
|
||||
<details>
|
||||
<summary>Signal-Gruppenchat Donau Linz</summary>
|
||||
<p class="mt-3">
|
||||
Mit diesem Link kannst du unserer Signal Gruppe beitreten: <a class="break-all underline"
|
||||
href="https://signal.group/#CjQKICFrq6zSsRHxrucS3jEcQn6lknEXacAykwwLV3vNLKxPEhA17jxz7cpjfu3JZokLq1TH">https://signal.group/#CjQKICFrq6zSsRHxrucS3jEcQn6lknEXacAykwwLV3vNLKxPEhA17jxz7cpjfu3JZokLq1TH</a>
|
||||
</p>
|
||||
</details>
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="py-3">
|
||||
<p>
|
||||
<details>
|
||||
<summary>
|
||||
Signal-Gruppenchat Donau Linz
|
||||
</summary>
|
||||
<summary>WLAN-Passwort</summary>
|
||||
<p class="mt-3">
|
||||
Mit diesem Link kannst du unserer Signal Gruppe beitreten: <a class="break-all underline" href="https://signal.group/#CjQKICFrq6zSsRHxrucS3jEcQn6lknEXacAykwwLV3vNLKxPEhA17jxz7cpjfu3JZokLq1TH">https://signal.group/#CjQKICFrq6zSsRHxrucS3jEcQn6lknEXacAykwwLV3vNLKxPEhA17jxz7cpjfu3JZokLq1TH</a>
|
||||
</p>
|
||||
</details>
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="py-3">
|
||||
<p>
|
||||
<details>
|
||||
<summary>
|
||||
WLAN-Passwort
|
||||
</summary>
|
||||
<p class="mt-3">
|
||||
Das Passwort für unser "ASKÖ Ruderverein Donau Linz" WLAN ist <q>donau1921</q> (ohne Anführungszeichen). Bitte an keine vereinsfremden Personen weitergeben.
|
||||
Das Passwort für unser "ASKÖ Ruderverein Donau Linz" WLAN ist <q>donau1921</q> (ohne Anführungszeichen). Bitte an keine vereinsfremden Personen weitergeben.
|
||||
</p>
|
||||
</details>
|
||||
</p>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if "cox" in loggedin_user.roles or "Bootsführer" in loggedin_user.roles %}
|
||||
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"
|
||||
role="alert">
|
||||
@ -329,11 +327,10 @@
|
||||
<div class="py-3">
|
||||
<p>
|
||||
<details>
|
||||
<summary>
|
||||
Signal-Gruppenchat Steuerpersonen Donau Linz
|
||||
</summary>
|
||||
<summary>Signal-Gruppenchat Steuerpersonen Donau Linz</summary>
|
||||
<p class="mt-3">
|
||||
Mit diesem Link kannst du unserer Signal Gruppe beitreten: <a class="break-all underline" href="https://signal.group/#CjQKIHJInNb3zSVW7ipLo7_ygIqVxhxUaaNYx4sy2jdklLsIEhBHJNM2KZM1UnBdQxWy_Gdp">https://signal.group/#CjQKIHJInNb3zSVW7ipLo7_ygIqVxhxUaaNYx4sy2jdklLsIEhBHJNM2KZM1UnBdQxWy_Gdp</a>
|
||||
Mit diesem Link kannst du unserer Signal Gruppe beitreten: <a class="break-all underline"
|
||||
href="https://signal.group/#CjQKIHJInNb3zSVW7ipLo7_ygIqVxhxUaaNYx4sy2jdklLsIEhBHJNM2KZM1UnBdQxWy_Gdp">https://signal.group/#CjQKIHJInNb3zSVW7ipLo7_ygIqVxhxUaaNYx4sy2jdklLsIEhBHJNM2KZM1UnBdQxWy_Gdp</a>
|
||||
</p>
|
||||
</details>
|
||||
</p>
|
||||
@ -421,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 %}
|
||||
@ -435,6 +435,9 @@
|
||||
<li class="py-1">
|
||||
<a href="/admin/rss" class="block w-100 py-2 hover:text-primary-600">Logs</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/admin/role" class="block w-100 py-2 hover:text-primary-600">Rollen</a>
|
||||
</li>
|
||||
<li class="py-1">
|
||||
<a href="/admin/list" class="block w-100 py-2 hover:text-primary-600">Fingerabdruck-Liste überprüfen</a>
|
||||
</li>
|
||||
|
@ -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 %}
|
||||
|
@ -67,7 +67,7 @@
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<div id="{{ day.day| date(format="%Y-%m-%d") }}"
|
||||
<div id="{{ day.day| date(format='%Y-%m-%d') }}"
|
||||
class="bg-white dark:bg-primary-900 rounded-md flex justify-between flex-col shadow reset-js"
|
||||
style="min-height: 10rem"
|
||||
data-trips="{{ amount_trips }}"
|
||||
@ -93,20 +93,22 @@
|
||||
<div class="grid grid-cols-1 gap-3 mb-3">
|
||||
{# --- 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">
|
||||
{% set reservation = reservations_for_event[0] %}
|
||||
<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">
|
||||
⏳ {{ reservation.time_desc }} <small class="text-gray-600 dark:text-gray-100">({{ reservation.user_applicant.name }})</small><br/>
|
||||
⏳ {{ reservation.time_desc }} <small class="text-gray-600 dark:text-gray-100">({{ reservation.user_applicant.name }})</small>
|
||||
<br />
|
||||
<strong>
|
||||
{% for reservation in reservations_for_event -%}
|
||||
{{ reservation.boat.name }}
|
||||
{%- if not loop.last %} + {% endif -%}
|
||||
{% endfor -%}
|
||||
{% for reservation in reservations_for_event -%}
|
||||
{{ reservation.boat.name }}
|
||||
{%- if not loop.last %} +
|
||||
{% endif -%}
|
||||
{% endfor -%}
|
||||
</strong>
|
||||
</span>
|
||||
<small class="text-gray-600 dark:text-gray-100">(Reservierung - {{ reservation.usage}})</small>
|
||||
<small class="text-gray-600 dark:text-gray-100">(Reservierung - {{ reservation.usage }})</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -241,9 +243,9 @@
|
||||
<input type="hidden" name="id" value="{{ event.id }}" />
|
||||
{{ macros::input(label='Titel', name='name', type='input', value=event.name) }}
|
||||
{% if event.cancelled %}
|
||||
<input type="hidden" name="max_people" value="-1" />
|
||||
<input type="hidden" name="max_people" value="-1" />
|
||||
{% else %}
|
||||
{{ macros::input(label='Anzahl Ruderer', name='max_people', type='number', required=true, value=event.max_people, min='0') }}
|
||||
{{ macros::input(label='Anzahl Ruderer', name='max_people', type='number', required=true, value=event.max_people, min='0') }}
|
||||
{% endif %}
|
||||
{{ macros::input(label='Anzahl Steuerleute', name='planned_amount_cox', type='number', value=event.planned_amount_cox, required=true, min='0') }}
|
||||
{{ macros::checkbox(label='Immer anzeigen', name='always_show', id=event.id,checked=event.always_show) }}
|
||||
@ -378,11 +380,11 @@
|
||||
{{ macros::input(label='Anzahl Ruderer', name='max_people', type='number', required=true, value=trip.max_people, min=trip.rower | length) }}
|
||||
{{ macros::input(label='Anmerkungen', name='notes', type='input', value=trip.notes) }}
|
||||
{{ macros::checkbox(label='Gesperrt', name='is_locked', id=trip.id,checked=trip.is_locked) }}
|
||||
{% if loggedin_user.allowed_to_steer %}
|
||||
{{ macros::select(label='Typ', name='trip_type', data=trip_types, default='Reguläre Ausfahrt', selected_id=trip.trip_type_id, only_ergo=not loggedin_user.allowed_to_steer) }}
|
||||
{% else %}
|
||||
{{ macros::select(label='Typ', name='trip_type', data=trip_types, selected_id=trip.trip_type_id, only_ergo=not loggedin_user.allowed_to_steer, only_ergos=true) }}
|
||||
{% endif %}
|
||||
{% if loggedin_user.allowed_to_steer %}
|
||||
{{ macros::select(label='Typ', name='trip_type', data=trip_types, default='Reguläre Ausfahrt', selected_id=trip.trip_type_id, only_ergo=not loggedin_user.allowed_to_steer) }}
|
||||
{% else %}
|
||||
{{ macros::select(label='Typ', name='trip_type', data=trip_types, selected_id=trip.trip_type_id, only_ergo=not loggedin_user.allowed_to_steer, only_ergos=true) }}
|
||||
{% endif %}
|
||||
<input value="Speichern" class="btn btn-primary" type="submit" />
|
||||
</form>
|
||||
</div>
|
||||
@ -472,9 +474,11 @@
|
||||
{% endif %}
|
||||
">
|
||||
<span class="absolute inset-y-0 left-0 flex items-center pl-3">{% include "includes/plus-icon" %}</span>
|
||||
{% if not loggedin_user.allowed_to_steer %}Ergo-Session
|
||||
{%- else -%}
|
||||
Ausfahrt{%endif%}
|
||||
{% if not loggedin_user.allowed_to_steer %}
|
||||
Ergo-Session
|
||||
{%- else -%}
|
||||
Ausfahrt
|
||||
{% endif %}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
@ -484,7 +488,7 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% if loggedin_user.allowed_to_steer or "ergo" in loggedin_user.roles %}
|
||||
{% if loggedin_user.allowed_to_steer or "ergo" in loggedin_user.roles %}
|
||||
{% include "forms/trip" %}
|
||||
{% endif %}
|
||||
{% if "manage_events" in loggedin_user.roles %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user