Skip to content

Commit 7d8fc00

Browse files
committed
slugify organization names
1 parent 2ba33d3 commit 7d8fc00

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

Cargo.lock

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

entity_api/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ log = "0.4.22"
1414
axum-login = "0.16.0"
1515
async-trait = "0.1.83"
1616
password-auth = "1.0.0"
17+
slugify = "0.1.0"
1718
sqlx = { version = "0.8.2", features = ["time", "runtime-tokio"] }
1819
sqlx-sqlite = { version = "0.8.2" }
1920
utoipa = { version = "4.2.0", features = ["axum_extras", "uuid"] }

entity_api/src/organization.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use sea_orm::{
66
entity::prelude::*, sea_query, ActiveValue::Set, ActiveValue::Unchanged, DatabaseConnection,
77
JoinType, QuerySelect, TryIntoModel,
88
};
9+
use slugify::slugify;
910
use std::collections::HashMap;
1011

1112
use log::*;
@@ -17,10 +18,12 @@ pub async fn create(db: &DatabaseConnection, organization_model: Model) -> Resul
1718
);
1819

1920
let now = Utc::now();
21+
let name = organization_model.name;
2022

2123
let organization_active_model: ActiveModel = ActiveModel {
2224
logo: Set(organization_model.logo),
23-
name: Set(organization_model.name),
25+
name: Set(name.clone()),
26+
slug: Set(slugify!(name.as_str())),
2427
created_at: Set(now.into()),
2528
updated_at: Set(now.into()),
2629
..Default::default()

0 commit comments

Comments
 (0)