|  | @ -192,6 +192,38 @@ fn post_organization_collection_update(org_id: String, col_id: String, headers: | 
			
		
	
		
		
			
				
					|  |  |     Ok(Json(collection.to_json())) |  |  |     Ok(Json(collection.to_json())) | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | #[post("/organizations/<org_id>/collections/<col_id>/delete-user/<org_user_id>")] | 
			
		
	
		
		
			
				
					|  |  |  |  |  | fn post_organization_collection_delete_user(org_id: String, col_id: String, org_user_id: String, headers: Headers, conn: DbConn) -> EmptyResult { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     match UserOrganization::find_by_user_and_org(&headers.user.uuid, &org_id, &conn) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         None => err!("Not a member of Organization"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         Some(user_org) => if user_org.has_full_access() { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             match Collection::find_by_uuid(&col_id, &conn) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 None => err!("Collection not found"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 Some(collection) => if collection.org_uuid == org_id { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     match UserOrganization::find_by_uuid(&org_user_id, &conn) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         None => err!("User not found in organization"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         Some(user_org) => { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             match CollectionUser::find_by_collection_and_user(&collection.uuid, &user_org.user_uuid, &conn) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 None => err!("User not assigned to collection"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 Some(col_user) => { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                     match col_user.delete(&conn) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                         Ok(()) => Ok(()), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                         Err(_) => err!("Failed removing user from collection") | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                 } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } else { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     err!("Collection and Organization id do not match") | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } else { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             err!("Not enough rights to delete Collection") | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | #[derive(Deserialize, Debug)] |  |  | #[derive(Deserialize, Debug)] | 
			
		
	
		
		
			
				
					|  |  | #[allow(non_snake_case)] |  |  | #[allow(non_snake_case)] | 
			
		
	
		
		
			
				
					|  |  | struct DeleteCollectionData { |  |  | struct DeleteCollectionData { | 
			
		
	
	
		
		
			
				
					|  | @ -232,26 +264,21 @@ fn get_org_collection_detail(org_id: String, coll_id: String, headers: AdminHead | 
			
		
	
		
		
			
				
					|  |  | #[get("/organizations/<org_id>/collections/<coll_id>/users")] |  |  | #[get("/organizations/<org_id>/collections/<coll_id>/users")] | 
			
		
	
		
		
			
				
					|  |  | fn get_collection_users(org_id: String, coll_id: String, headers: AdminHeaders, conn: DbConn) -> JsonResult { |  |  | fn get_collection_users(org_id: String, coll_id: String, headers: AdminHeaders, conn: DbConn) -> JsonResult { | 
			
		
	
		
		
			
				
					|  |  |     // Get org and collection, check that collection is from org
 |  |  |     // Get org and collection, check that collection is from org
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     let collection = match Collection::find_by_uuid_and_org(&coll_id, &org_id, &conn) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         None => err!("Collection not found in Organization"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         Some(collection) => collection | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     }; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     // Get the users from collection
 |  |  |     // Get the users from collection
 | 
			
		
	
		
		
			
				
					
					|  |  | 
 |  |  |     let user_list: Vec<Value> = CollectionUser::find_by_collection(&collection.uuid, &conn) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |     /* |  |  |     .iter().map(|col_user|  { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |     The elements from the data array to return have the following structure |  |  |         UserOrganization::find_by_user_and_org(&col_user.user_uuid, &org_id, &conn) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 
 |  |  |         .unwrap() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |     { |  |  |         .to_json_collection_user_details(&col_user.read_only, &conn) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         OrganizationUserId:	<id> |  |  |     }).collect(); | 
			
				
				
			
		
	
		
		
			
				
					|  |  |         AccessAll:	true |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         Name:	    <user_name> |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         Email:	    <user_email> |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         Type:	    0 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         Status:	    2 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         ReadOnly:	false |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         Object:	    collectionUser |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     */ |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     Ok(Json(json!({ |  |  |     Ok(Json(json!({ | 
			
		
	
		
		
			
				
					
					|  |  |         "Data": [], |  |  |         "Data": user_list, | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |         "Object": "list" |  |  |         "Object": "list" | 
			
		
	
		
		
			
				
					|  |  |     }))) |  |  |     }))) | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
	
		
		
			
				
					|  | @ -473,8 +500,11 @@ fn edit_user(org_id: String, user_id: String, data: Json<EditUserData>, headers: | 
			
		
	
		
		
			
				
					|  |  |     user_to_edit.type_ = new_type; |  |  |     user_to_edit.type_ = new_type; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     // Delete all the odd collections
 |  |  |     // Delete all the odd collections
 | 
			
		
	
		
		
			
				
					
					|  |  |     for c in Collection::find_by_organization_and_user_uuid(&org_id, &user_to_edit.user_uuid, &conn) { |  |  |     for c in CollectionUser::find_by_organization_and_user_uuid(&org_id, &user_to_edit.user_uuid, &conn) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         CollectionUser::delete(&user_to_edit.user_uuid, &c.uuid, &conn); |  |  |         match c.delete(&conn) { | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |             Ok(()) => (), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             Err(_) => err!("Failed deleting old collection assignment") | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     // If no accessAll, add the collections received
 |  |  |     // If no accessAll, add the collections received
 | 
			
		
	
	
		
		
			
				
					|  | 
 |