Compare commits

...

53 Commits

Author SHA1 Message Date
63af74662f Merge branch 'main' into notification
Some checks are pending
CI/CD Pipeline / test (push) Waiting to run
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
2024-03-20 22:21:12 +01:00
e3afe8c2ae Merge pull request 'push' (#290) from only-show-input-when-possible into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m6s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 5m7s
Reviewed-on: #290
2024-03-20 22:14:10 +01:00
ac90dbedea push
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
2024-03-20 22:13:18 +01:00
0dcf941cd1 Merge pull request 'only accept pdf' (#288) from fix-ci into main
Some checks are pending
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Successful in 9m12s
Reviewed-on: #288
2024-03-20 21:40:54 +01:00
868847f778 only accept pdf
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m7s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
2024-03-20 21:40:08 +01:00
ffce336199 Merge pull request 'fix ci' (#285) from fix-ci into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m18s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m57s
Reviewed-on: #285
2024-03-20 21:17:54 +01:00
35900f3059 fix ci
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2024-03-20 21:16:55 +01:00
e48bc468cd Merge pull request 'add membership pdf' (#283) from membership-pdf-new into main
Some checks failed
CI/CD Pipeline / test (push) Failing after 7m23s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #283
2024-03-20 21:04:42 +01:00
9fdc1f82bd add membership pdf
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2024-03-20 21:02:41 +01:00
fda2673f5a Merge pull request 'improve boathouse functionality, fixes #261' (#281) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 8m12s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 3m57s
Reviewed-on: #281
2024-03-20 13:59:30 +01:00
7614cc8fae Merge pull request 're-wording' (#280) from staging into main
Some checks failed
CI/CD Pipeline / test (push) Successful in 8m5s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been cancelled
Reviewed-on: #280
2024-03-20 13:41:28 +01:00
6ad07f35f7 Merge pull request 'show total club km' (#279) from staging into main
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #279
2024-03-20 13:34:54 +01:00
f61ffb60d8 Merge pull request 'don't count 'externe steuerkilometer' as guest kms' (#278) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 7m57s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 3m56s
Reviewed-on: #278
2024-03-20 09:16:21 +01:00
d6b4f76fb5 Merge pull request 'fix ci' (#277) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 8m20s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m16s
Reviewed-on: #277
2024-03-20 00:48:47 +01:00
a649912e78 Merge pull request 'push' (#276) from staging into main
Some checks failed
CI/CD Pipeline / deploy-staging (push) Waiting to run
CI/CD Pipeline / deploy-main (push) Waiting to run
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #276
2024-03-20 00:11:39 +01:00
a1126e0509 Merge pull request 'bit nicer logs' (#275) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 7m55s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m0s
Reviewed-on: #275
2024-03-19 10:00:12 +01:00
b075b8803b Merge pull request 'spacing' (#273) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 10m21s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 6m36s
Reviewed-on: #273
2024-03-17 21:09:19 +01:00
54058b0917 Merge pull request 'add more logs' (#270) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m49s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m59s
Reviewed-on: #270
2024-03-16 20:43:30 +01:00
e228deb6cd Merge pull request 'spacing again' (#269) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 10m15s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m47s
Reviewed-on: #269
2024-03-16 19:47:39 +01:00
1a2f4c9920 Merge pull request 'fix whitespace' (#268) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 10m16s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m42s
Reviewed-on: #268
2024-03-16 09:56:28 +01:00
2ab164d5b9 Merge pull request 'a bit nicer mail sending layout' (#267) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 10m27s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m29s
Reviewed-on: #267
2024-03-15 15:30:28 +01:00
ec9657c6e9 Merge pull request 'fix typo' (#266) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m41s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m49s
Reviewed-on: #266
2024-03-15 11:49:53 +01:00
a0183c1359 Merge pull request 'add mail for requesting fee' (#265) from staging into main
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #265
2024-03-15 11:42:35 +01:00
3b72bf279f Merge pull request 'show which schnupperant already paid' (#264) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m59s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m55s
Reviewed-on: #264
2024-03-15 10:52:58 +01:00
11a96f4091 Merge pull request 'update docs' (#263) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m43s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m35s
Reviewed-on: #263
2024-03-15 10:06:06 +01:00
7958a9311d Merge pull request 'move to hetzner server' (#262) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 10m26s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m33s
Reviewed-on: #262
2024-03-15 09:35:36 +01:00
da525d98cb Merge pull request 'staging' (#260) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m45s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m12s
Reviewed-on: #260
2024-03-09 18:17:15 +01:00
ee73509fc7 Merge pull request 'boatshouse' (#258) from boatshouse into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m53s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m17s
Reviewed-on: #258
2024-03-09 17:00:11 +01:00
5da1900ae8 Merge pull request 'no fee for 'ehrenmitglieder' (#256) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m42s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m5s
Reviewed-on: #256
2024-03-08 13:58:42 +01:00
92a1a8278d Merge pull request 'update filter' (#255) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m33s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 3m58s
Reviewed-on: #255
2024-03-08 10:17:13 +01:00
754f746094 Merge pull request 'add schnupper management' (#254) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m32s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m4s
Reviewed-on: #254
2024-03-06 15:55:49 +01:00
ef6fc3a349 Merge pull request 'clippy' (#253) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m39s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 3m59s
Reviewed-on: #253
2024-03-06 13:28:53 +01:00
25667af9c5 Merge pull request 'sort boats by name' (#252) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m28s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m3s
Reviewed-on: #252
2024-03-06 08:16:11 +01:00
9f6d7bf5d7 Merge pull request 'fix ci' (#251) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m17s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 3m59s
Reviewed-on: #251
2024-03-05 15:02:12 +01:00
3b9d743603 Merge pull request 'fix ci' (#250) from staging into main
Some checks failed
CI/CD Pipeline / test (push) Failing after 3m44s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #250
2024-03-05 14:29:58 +01:00
292e944783 Merge pull request 'fix ci' (#249) from staging into main
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #249
2024-03-05 14:13:18 +01:00
8c8b9b7aca Merge pull request 'staging' (#248) from staging into main
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #248
2024-03-05 13:45:55 +01:00
aadc1b315e staging (#246)
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m21s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m1s
Reviewed-on: #246
2024-03-05 09:46:53 +01:00
7a6bea3c46 fix ci (#245)
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #245
2024-03-05 09:35:08 +01:00
6c2ff716e1 Merge pull request 'staging' (#244) from staging into main
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #244
2024-03-05 09:19:50 +01:00
814e80864d Merge pull request 'fix wording' (#243) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m26s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m5s
Reviewed-on: #243
2024-03-05 08:31:41 +01:00
f3b97e0e49 Merge pull request 'fix ci?' (#242) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m34s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m6s
Reviewed-on: #242
2024-03-05 07:51:12 +01:00
bb6ba7730e Merge pull request 'remove timeout again' (#241) from staging into main
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #241
2024-03-05 00:58:20 +01:00
359e20e948 Merge pull request 'wait for webserver to respond with 2xx, fix failing first (flaky) test' (#239) from staging into main
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #239
2024-03-05 00:53:35 +01:00
b3779bfefd Merge pull request 'faster tests' (#238) from staging into main
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #238
2024-03-05 00:46:42 +01:00
5cbdb2ae63 Merge pull request 'remove 1 minute timeout + use local timezone where appropriate and fix tests between 0 and 1 o'clock' (#237) from staging into main
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #237
2024-03-05 00:17:56 +01:00
38d4899bf4 Merge pull request 'staging' (#236) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 16m24s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m10s
Reviewed-on: #236
2024-03-04 23:12:05 +01:00
eed7718a3f Merge pull request 'alphabetically order stat if same ranking' (#233) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 15m25s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 3m58s
Reviewed-on: #233
2024-03-04 17:12:40 +01:00
2bff90b025 Merge pull request 'staging' (#232) from staging into main
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #232
2024-03-04 17:01:53 +01:00
2490428781 Merge pull request 'Create admin function to use copy-pasted users from ekey, return the ones which don't match to "Donau Linz" rowt user, Fixes #204 (#230)' (#231) from staging into main
Some checks are pending
CI/CD Pipeline / test (push) Waiting to run
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
Reviewed-on: #231
2024-03-04 17:00:06 +01:00
a269efedca Merge pull request 'show user icon in all vorstand users' (#229) from staging into main
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #229
2024-03-04 16:38:50 +01:00
e7168d308f Merge pull request 'fix link' (#228) from staging into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 15m46s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 4m2s
Reviewed-on: #228
2024-03-04 15:57:34 +01:00
11188bacbe Merge pull request 'reformat files' (#227) from staging into main
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #227
2024-03-04 15:51:50 +01:00
7 changed files with 71 additions and 21 deletions

View File

@ -16,7 +16,8 @@ CREATE TABLE IF NOT EXISTS "user" (
"notes" text, "notes" text,
"phone" text, "phone" text,
"address" text, "address" text,
"family_id" INTEGER REFERENCES family(id) "family_id" INTEGER REFERENCES family(id),
"membership_pdf" BLOB
); );
CREATE TABLE IF NOT EXISTS "family" ( CREATE TABLE IF NOT EXISTS "family" (

View File

@ -75,7 +75,7 @@ GROUP BY family.id;"
} }
pub async fn members(&self, db: &SqlitePool) -> Vec<User> { 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 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, notes, phone, address, family_id, membership_pdf FROM user WHERE family_id = ?", self.id)
.fetch_all(db) .fetch_all(db)
.await .await
.unwrap() .unwrap()

View File

@ -16,7 +16,7 @@ impl Rower {
sqlx::query_as!( sqlx::query_as!(
User, User,
" "
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, membership_pdf
FROM user FROM user
WHERE id in (SELECT rower_id FROM rower WHERE logbook_id=?) WHERE id in (SELECT rower_id FROM rower WHERE logbook_id=?)
", ",

View File

@ -8,6 +8,7 @@ use rocket::{
http::{Cookie, Status}, http::{Cookie, Status},
request::{self, FromRequest, Outcome}, request::{self, FromRequest, Outcome},
time::{Duration, OffsetDateTime}, time::{Duration, OffsetDateTime},
tokio::io::AsyncReadExt,
Request, Request,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -43,6 +44,7 @@ pub struct User {
pub phone: Option<String>, pub phone: Option<String>,
pub address: Option<String>, pub address: Option<String>,
pub family_id: Option<i64>, pub family_id: Option<i64>,
pub membership_pdf: Option<Vec<u8>>,
} }
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
@ -285,7 +287,7 @@ impl User {
sqlx::query_as!( sqlx::query_as!(
Self, Self,
" "
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, membership_pdf
FROM user FROM user
WHERE id like ? WHERE id like ?
", ",
@ -300,7 +302,7 @@ WHERE id like ?
sqlx::query_as!( sqlx::query_as!(
Self, Self,
" "
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, membership_pdf
FROM user FROM user
WHERE id like ? WHERE id like ?
", ",
@ -315,7 +317,7 @@ WHERE id like ?
sqlx::query_as!( sqlx::query_as!(
Self, Self,
" "
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, membership_pdf
FROM user FROM user
WHERE name like ? WHERE name like ?
", ",
@ -357,7 +359,7 @@ WHERE name like ?
sqlx::query_as!( sqlx::query_as!(
Self, Self,
" "
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, membership_pdf
FROM user FROM user
WHERE deleted = 0 WHERE deleted = 0
ORDER BY last_access DESC ORDER BY last_access DESC
@ -372,7 +374,7 @@ ORDER BY last_access DESC
sqlx::query_as!( sqlx::query_as!(
Self, Self,
" "
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, membership_pdf
FROM user u FROM user u
JOIN user_role ur ON u.id = ur.user_id JOIN user_role ur ON u.id = ur.user_id
WHERE ur.role_id = ? AND deleted = 0 WHERE ur.role_id = ? AND deleted = 0
@ -388,14 +390,14 @@ ORDER BY name;
sqlx::query_as!( sqlx::query_as!(
Self, Self,
" "
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id FROM user SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, membership_pdf FROM user
WHERE family_id IS NOT NULL WHERE family_id IS NOT NULL
GROUP BY family_id GROUP BY family_id
UNION UNION
-- Select users with a null family_id, without grouping -- Select users with a null family_id, without grouping
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id FROM user SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, membership_pdf FROM user
WHERE family_id IS NULL; WHERE family_id IS NULL;
" "
) )
@ -408,7 +410,7 @@ WHERE family_id IS NULL;
sqlx::query_as!( sqlx::query_as!(
Self, Self,
" "
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, membership_pdf
FROM user FROM user
WHERE deleted = 0 AND dob != '' and weight != '' and sex != '' WHERE deleted = 0 AND dob != '' and weight != '' and sex != ''
ORDER BY name ORDER BY name
@ -423,7 +425,7 @@ ORDER BY name
sqlx::query_as!( sqlx::query_as!(
Self, Self,
" "
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id, membership_pdf
FROM user FROM user
WHERE deleted = 0 AND (SELECT COUNT(*) FROM user_role WHERE user_id=user.id AND role_id = (SELECT id FROM role WHERE name = 'cox')) > 0 WHERE deleted = 0 AND (SELECT COUNT(*) FROM user_role WHERE user_id=user.id AND role_id = (SELECT id FROM role WHERE name = 'cox')) > 0
ORDER BY last_access DESC ORDER BY last_access DESC
@ -441,13 +443,29 @@ ORDER BY last_access DESC
.is_ok() .is_ok()
} }
pub async fn update(&self, db: &SqlitePool, data: UserEditForm) { pub async fn update(&self, db: &SqlitePool, data: UserEditForm<'_>) {
let mut family_id = data.family_id; let mut family_id = data.family_id;
if family_id.is_some_and(|x| x == -1) { if family_id.is_some_and(|x| x == -1) {
family_id = Some(Family::insert(db).await) family_id = Some(Family::insert(db).await)
} }
if self.membership_pdf.is_none() {
if let Some(membership_pdf) = data.membership_pdf {
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
}
}
sqlx::query!( sqlx::query!(
"UPDATE user SET dob = ?, weight = ?, sex = ?, member_since_date=?, birthdate=?, mail=?, nickname=?, notes=?, phone=?, address=?, family_id = ? where id = ?", "UPDATE user SET dob = ?, weight = ?, sex = ?, member_since_date=?, birthdate=?, mail=?, nickname=?, notes=?, phone=?, address=?, family_id = ? where id = ?",
data.dob, data.dob,
@ -1046,6 +1064,7 @@ mod test {
phone: None, phone: None,
address: None, address: None,
family_id: None, family_id: None,
membership_pdf: None,
}, },
) )
.await; .await;

View File

@ -10,8 +10,9 @@ use crate::model::{
use futures::future::join_all; use futures::future::join_all;
use rocket::{ use rocket::{
form::Form, form::Form,
fs::TempFile,
get, get,
http::Status, http::{ContentType, Status},
post, post,
request::{FlashMessage, FromRequest, Outcome}, request::{FlashMessage, FromRequest, Outcome},
response::{Flash, Redirect}, response::{Flash, Redirect},
@ -231,7 +232,7 @@ async fn delete(db: &State<SqlitePool>, admin: AdminUser, user: i32) -> Flash<Re
} }
#[derive(FromForm, Debug)] #[derive(FromForm, Debug)]
pub struct UserEditForm { pub struct UserEditForm<'a> {
pub(crate) id: i32, pub(crate) id: i32,
pub(crate) dob: Option<String>, pub(crate) dob: Option<String>,
pub(crate) weight: Option<String>, pub(crate) weight: Option<String>,
@ -245,12 +246,13 @@ pub struct UserEditForm {
pub(crate) phone: Option<String>, pub(crate) phone: Option<String>,
pub(crate) address: Option<String>, pub(crate) address: Option<String>,
pub(crate) family_id: Option<i64>, pub(crate) family_id: Option<i64>,
pub(crate) membership_pdf: Option<TempFile<'a>>,
} }
#[post("/user", data = "<data>")] #[post("/user", data = "<data>", format = "multipart/form-data")]
async fn update( async fn update(
db: &State<SqlitePool>, db: &State<SqlitePool>,
data: Form<UserEditForm>, data: Form<UserEditForm<'_>>,
admin: AdminUser, admin: AdminUser,
) -> Flash<Redirect> { ) -> Flash<Redirect> {
let user = User::find_by_id(db, data.id).await; let user = User::find_by_id(db, data.id).await;
@ -271,6 +273,25 @@ async fn update(
Flash::success(Redirect::to("/admin/user"), "Successfully updated user") Flash::success(Redirect::to("/admin/user"), "Successfully updated user")
} }
#[get("/user/<user>/membership")]
async fn download_membership_pdf(
db: &State<SqlitePool>,
admin: AdminUser,
user: i32,
) -> (ContentType, Vec<u8>) {
let user = User::find_by_id(db, user).await.unwrap();
Log::create(
db,
format!(
"{} downloaded membership application for user: {user:?}",
admin.user.name
),
)
.await;
(ContentType::PDF, user.membership_pdf.unwrap())
}
#[derive(FromForm, Debug)] #[derive(FromForm, Debug)]
struct UserAddForm<'r> { struct UserAddForm<'r> {
name: &'r str, name: &'r str,
@ -307,6 +328,7 @@ pub fn routes() -> Vec<Route> {
delete, delete,
fees, fees,
fees_paid, fees_paid,
scheckbuch scheckbuch,
download_membership_pdf
] ]
} }

View File

@ -33,7 +33,7 @@
name="name" name="name"
id="filter-js" id="filter-js"
class="search-bar" class="search-bar"
placeholder="Suchen nach (Name, [yes|no]-role:<name>)" /> placeholder="Suchen nach (Name, [yes|no]-role:<name>, has-[no-]membership-pdf)" />
</div> </div>
<!-- END filterBar --> <!-- END filterBar -->
<div class="bg-primary-100 dark:bg-primary-950 p-3 rounded-b-md grid gap-4"> <div class="bg-primary-100 dark:bg-primary-950 p-3 rounded-b-md grid gap-4">
@ -41,9 +41,10 @@
class="text-primary-950 dark:text-white text-right"></div> class="text-primary-950 dark:text-white text-right"></div>
{% for user in users %} {% for user in users %}
<div data-filterable="true" <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 %} "> 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 %} ">
<form action="/admin/user" <form action="/admin/user"
method="post" method="post"
enctype="multipart/form-data"
class="bg-white dark:bg-primary-900 p-3 rounded-md w-full"> class="bg-white dark:bg-primary-900 p-3 rounded-md w-full">
<div class="w-full grid gap-3"> <div class="w-full grid gap-3">
<input type="hidden" name="id" value="{{ user.id }}" /> <input type="hidden" name="id" value="{{ user.id }}" />
@ -62,6 +63,12 @@
{% for role in roles %} {% for role in roles %}
{{ macros::checkbox(label=role.name, name="roles[" ~ role.id ~ "]", id=loop.index , checked=role.name in user.roles, disabled=allowed_to_edit == false) }} {{ macros::checkbox(label=role.name, name="roles[" ~ role.id ~ "]", id=loop.index , checked=role.name in user.roles, disabled=allowed_to_edit == false) }}
{% endfor %} {% endfor %}
{% 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='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='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='Sex', name='sex', id=loop.index, type="text", value=user.sex, readonly=allowed_to_edit == false) }}

View File

@ -115,7 +115,7 @@
</header> </header>
<div class="h-8"></div> <div class="h-8"></div>
{% endmacro header %} {% 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) %} {% macro input(label, name, type, required=false, class='rounded-md', value='', min='', hide_label=false, id='', autofocus=false, wrapper_class='', pattern='', readonly=false, accept='') %}
<div class="{{ wrapper_class }}"> <div class="{{ wrapper_class }}">
<label for="{{ name }}" <label for="{{ name }}"
class="{% if hide_label %} sr-only {% else %} text-sm text-gray-600 dark:text-white {% endif %}"> class="{% if hide_label %} sr-only {% else %} text-sm text-gray-600 dark:text-white {% endif %}">
@ -131,6 +131,7 @@
placeholder="{% if hide_label %}{{ label }}{% endif %}" placeholder="{% if hide_label %}{{ label }}{% endif %}"
{% if min is defined %}min="{{ min }}"{% endif %} {% if min is defined %}min="{{ min }}"{% endif %}
{% if autofocus %}autofocus{% endif %} {% if autofocus %}autofocus{% endif %}
{% if accept %}accept="{{ accept }}"{% endif %}
{% if pattern %}pattern="{{ pattern }}"{% endif %} {% if pattern %}pattern="{{ pattern }}"{% endif %}
{% if readonly %}readonly{% endif %}> {% if readonly %}readonly{% endif %}>
</div> </div>