Can toggle accommodations module
This commit is contained in:
		@@ -1,2 +1,5 @@
 | 
			
		||||
ALTER TABLE public.families
 | 
			
		||||
    DROP COLUMN enable_accommodations;
 | 
			
		||||
 | 
			
		||||
DROP TABLE IF EXISTS accomodations_reservations;
 | 
			
		||||
DROP TABLE IF EXISTS accomodations_list;
 | 
			
		||||
@@ -1,3 +1,10 @@
 | 
			
		||||
-- Add column to toggle accommodations module
 | 
			
		||||
ALTER TABLE public.families
 | 
			
		||||
    ADD enable_accommodations boolean NOT NULL DEFAULT false;
 | 
			
		||||
COMMENT
 | 
			
		||||
    ON COLUMN public.families.enable_accommodations IS 'Specify whether accommodations feature is enabled for the family';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- Create tables
 | 
			
		||||
CREATE TABLE IF NOT EXISTS accommodations_list
 | 
			
		||||
(
 | 
			
		||||
 
 | 
			
		||||
@@ -80,6 +80,7 @@ struct RichFamilyInfo {
 | 
			
		||||
    #[serde(flatten)]
 | 
			
		||||
    membership: FamilyMembership,
 | 
			
		||||
    enable_genealogy: bool,
 | 
			
		||||
    enable_accommodations: bool,
 | 
			
		||||
    disable_couple_photos: bool,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -90,6 +91,7 @@ pub async fn single_info(f: FamilyInPath) -> HttpResult {
 | 
			
		||||
    Ok(HttpResponse::Ok().json(RichFamilyInfo {
 | 
			
		||||
        membership,
 | 
			
		||||
        enable_genealogy: family.enable_genealogy,
 | 
			
		||||
        enable_accommodations: family.enable_accommodations,
 | 
			
		||||
        disable_couple_photos: family.disable_couple_photos,
 | 
			
		||||
    }))
 | 
			
		||||
}
 | 
			
		||||
@@ -105,6 +107,7 @@ pub async fn leave(f: FamilyInPath) -> HttpResult {
 | 
			
		||||
pub struct UpdateFamilyBody {
 | 
			
		||||
    name: Option<String>,
 | 
			
		||||
    enable_genealogy: Option<bool>,
 | 
			
		||||
    enable_accommodations: Option<bool>,
 | 
			
		||||
    disable_couple_photos: Option<bool>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -127,6 +130,10 @@ pub async fn update(
 | 
			
		||||
        family.enable_genealogy = enable_genealogy;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if let Some(enable_accommodations) = req.enable_accommodations {
 | 
			
		||||
        family.enable_accommodations = enable_accommodations;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if let Some(disable_couple_photos) = req.disable_couple_photos {
 | 
			
		||||
        family.disable_couple_photos = disable_couple_photos;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -204,6 +204,17 @@ async fn main() -> std::io::Result<()> {
 | 
			
		||||
                "/family/{id}/genealogy/data/import",
 | 
			
		||||
                web::put().to(data_controller::import_family),
 | 
			
		||||
            )
 | 
			
		||||
            // [ACCOMODATIONS] List controller
 | 
			
		||||
            // TODO : create
 | 
			
		||||
            // TODO : update
 | 
			
		||||
            // TODO : delete
 | 
			
		||||
            // TODO : list
 | 
			
		||||
            // [ACCOMODATIONS] Reservations controller
 | 
			
		||||
            // TODO : create
 | 
			
		||||
            // TODO : update
 | 
			
		||||
            // TODO : delete
 | 
			
		||||
            // TODO : list
 | 
			
		||||
            // TODO : validate or reject
 | 
			
		||||
            // Photos controller
 | 
			
		||||
            .route(
 | 
			
		||||
                "/photo/{id}",
 | 
			
		||||
 
 | 
			
		||||
@@ -66,6 +66,7 @@ pub struct Family {
 | 
			
		||||
    pub invitation_code: String,
 | 
			
		||||
    pub disable_couple_photos: bool,
 | 
			
		||||
    pub enable_genealogy: bool,
 | 
			
		||||
    pub enable_accommodations: bool,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Family {
 | 
			
		||||
 
 | 
			
		||||
@@ -56,6 +56,7 @@ diesel::table! {
 | 
			
		||||
        invitation_code -> Varchar,
 | 
			
		||||
        disable_couple_photos -> Bool,
 | 
			
		||||
        enable_genealogy -> Bool,
 | 
			
		||||
        enable_accommodations -> Bool,
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -175,6 +175,7 @@ pub async fn update_family(family: &Family) -> anyhow::Result<()> {
 | 
			
		||||
                families::dsl::name.eq(family.name.clone()),
 | 
			
		||||
                families::dsl::invitation_code.eq(family.invitation_code.clone()),
 | 
			
		||||
                families::dsl::enable_genealogy.eq(family.enable_genealogy),
 | 
			
		||||
                families::dsl::enable_accommodations.eq(family.enable_accommodations),
 | 
			
		||||
                families::dsl::disable_couple_photos.eq(family.disable_couple_photos),
 | 
			
		||||
            ))
 | 
			
		||||
            .execute(conn)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user