merging chances
This commit is contained in:
		| @@ -5,7 +5,6 @@ | |||||||
| - [] delete flag user administration | - [] delete flag user administration | ||||||
| - [] max_people = 0 -> Rot hervorheben, dass Ausfahrt abgesagt wurde? | - [] max_people = 0 -> Rot hervorheben, dass Ausfahrt abgesagt wurde? | ||||||
| - [] my trips for cox | - [] my trips for cox | ||||||
| - [] remove key from src/rest/admin/rss.rs (line 8); at least before putting code somewhere public |  | ||||||
| - [] add `trip_type` (id, name, desc, question, icon) with a FK to `trip_details` | - [] add `trip_type` (id, name, desc, question, icon) with a FK to `trip_details` | ||||||
| - [] add `always_show` to `planned_trips` (e.g. for wanderfahrten) | - [] add `always_show` to `planned_trips` (e.g. for wanderfahrten) | ||||||
| - [] exactly same time -> deny registration | - [] exactly same time -> deny registration | ||||||
| @@ -14,6 +13,7 @@ | |||||||
| # Nice to have | # Nice to have | ||||||
| - [] automatically add regular planned trip | - [] automatically add regular planned trip | ||||||
| - [] User sync w/ nextcloud | - [] User sync w/ nextcloud | ||||||
|  | - [] remove key from src/rest/admin/rss.rs (line 8); at least before putting code somewhere public | ||||||
|  |  | ||||||
| # Frontend Process  | # Frontend Process  | ||||||
| ´cd frontend´ | ´cd frontend´ | ||||||
| @@ -25,6 +25,6 @@ | |||||||
| - [x] model/user.rs | - [x] model/user.rs | ||||||
| - [x] model/tripdetails.rs | - [x] model/tripdetails.rs | ||||||
| - [x] model/planned_event.rs | - [x] model/planned_event.rs | ||||||
| - [.] model/trip.rs | - [x] model/trip.rs | ||||||
| - [ ] model/usertrip.rs | - [ ] model/usertrip.rs | ||||||
| - [ ] Rest? | - [ ] Rest? | ||||||
|   | |||||||
| @@ -221,7 +221,7 @@ pub enum CoxHelpError { | |||||||
|     AlreadyRegisteredAsCox, |     AlreadyRegisteredAsCox, | ||||||
| } | } | ||||||
|  |  | ||||||
| #[derive(Debug)] | #[derive(Debug, PartialEq)] | ||||||
| pub enum TripDeleteError { | pub enum TripDeleteError { | ||||||
|     SomebodyAlreadyRegistered, |     SomebodyAlreadyRegistered, | ||||||
|     NotYourTrip, |     NotYourTrip, | ||||||
| @@ -238,8 +238,10 @@ mod test { | |||||||
|     use crate::{ |     use crate::{ | ||||||
|         model::{ |         model::{ | ||||||
|             planned_event::PlannedEvent, |             planned_event::PlannedEvent, | ||||||
|  |             trip::TripDeleteError, | ||||||
|             tripdetails::TripDetails, |             tripdetails::TripDetails, | ||||||
|             user::{CoxUser, User}, |             user::{CoxUser, User}, | ||||||
|  |             usertrip::UserTrip, | ||||||
|         }, |         }, | ||||||
|         testdb, |         testdb, | ||||||
|     }; |     }; | ||||||
| @@ -377,4 +379,48 @@ mod test { | |||||||
|  |  | ||||||
|         assert!(Trip::find_by_id(&pool, 1).await.is_none()); |         assert!(Trip::find_by_id(&pool, 1).await.is_none()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     #[sqlx::test] | ||||||
|  |     fn test_fail_delete_diff_cox() { | ||||||
|  |         let pool = testdb!(); | ||||||
|  |  | ||||||
|  |         let cox: CoxUser = User::find_by_name(&pool, "cox2".into()) | ||||||
|  |             .await | ||||||
|  |             .unwrap() | ||||||
|  |             .try_into() | ||||||
|  |             .unwrap(); | ||||||
|  |  | ||||||
|  |         let trip = Trip::find_by_id(&pool, 1).await.unwrap(); | ||||||
|  |  | ||||||
|  |         let result = trip | ||||||
|  |             .delete(&pool, &cox) | ||||||
|  |             .await | ||||||
|  |             .expect_err("It should not be possible to delete trips from others"); | ||||||
|  |         let expected = TripDeleteError::NotYourTrip; | ||||||
|  |  | ||||||
|  |         assert_eq!(result, expected); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     #[sqlx::test] | ||||||
|  |     fn test_fail_delete_someone_registered() { | ||||||
|  |         let pool = testdb!(); | ||||||
|  |  | ||||||
|  |         let cox: CoxUser = User::find_by_name(&pool, "cox2".into()) | ||||||
|  |             .await | ||||||
|  |             .unwrap() | ||||||
|  |             .try_into() | ||||||
|  |             .unwrap(); | ||||||
|  |  | ||||||
|  |         let trip = Trip::find_by_id(&pool, 1).await.unwrap(); | ||||||
|  |  | ||||||
|  |         UserTrip::create(&pool, 2, 2).await.unwrap(); | ||||||
|  |  | ||||||
|  |         let result = trip | ||||||
|  |             .delete(&pool, &cox) | ||||||
|  |             .await | ||||||
|  |             .expect_err("It should not be possible to delete trips if somebody already registered"); | ||||||
|  |         let expected = TripDeleteError::SomebodyAlreadyRegistered; | ||||||
|  |  | ||||||
|  |         assert_eq!(result, expected); | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -78,6 +78,7 @@ impl UserTrip { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #[derive(Debug)] | ||||||
| pub enum UserTripError { | pub enum UserTripError { | ||||||
|     AlreadyRegistered, |     AlreadyRegistered, | ||||||
|     AlreadyRegisteredAsCox, |     AlreadyRegisteredAsCox, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Philipp
					Philipp