Can create couple
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use crate::connections::db_connection;
|
||||
use crate::models::{FamilyID, Member, MemberID, NewMember};
|
||||
use crate::schema::members;
|
||||
use crate::services::photos_service;
|
||||
use crate::services::{couples_service, photos_service};
|
||||
use crate::utils::time_utils::time;
|
||||
use diesel::prelude::*;
|
||||
use diesel::RunQueryDsl;
|
||||
@@ -102,7 +102,16 @@ pub async fn remove_photo(member: &mut Member) -> anyhow::Result<()> {
|
||||
|
||||
/// Delete a member
|
||||
pub async fn delete(member: &mut Member) -> anyhow::Result<()> {
|
||||
// TODO : remove associated couple
|
||||
// Remove associated couple
|
||||
for mut c in couples_service::get_all_of_member(member.id()).await? {
|
||||
// Check if only one person is attached to the couple
|
||||
// i.e. if the current member is the last person attached to the couple
|
||||
if c.wife().is_some() && c.husband().is_some() {
|
||||
continue;
|
||||
}
|
||||
|
||||
couples_service::delete(&mut c).await?;
|
||||
}
|
||||
|
||||
remove_photo(member).await?;
|
||||
|
||||
|
Reference in New Issue
Block a user