From b369917fae3a7ff257749a5322096516c2a76fca Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Sat, 25 Sep 2021 02:19:09 +0100 Subject: [PATCH] Organisation descriptions --- chartered-db/src/organisations.rs | 6 ++++++ chartered-db/src/schema.rs | 1 + migrations/2021-08-31-214501_create_crates_table/up.sql | 5 +++-- chartered-frontend/src/pages/crate/OrganisationView.tsx | 5 ++--- chartered-web/src/endpoints/web_api/organisations/info.rs | 2 ++ 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/chartered-db/src/organisations.rs b/chartered-db/src/organisations.rs index 3ffad25..b8b774c 100644 --- a/chartered-db/src/organisations.rs +++ a/chartered-db/src/organisations.rs @@ -15,6 +15,7 @@ pub id: i32, pub uuid: SqlUuid, pub name: String, + pub description: String, } impl Organisation { @@ -68,6 +69,11 @@ #[must_use] pub fn permissions(&self) -> UserPermission { self.permissions + } + + #[must_use] + pub fn organisation(&self) -> &Organisation { + &self.organisation } pub async fn crates(self: Arc, conn: ConnectionPool) -> Result> { diff --git a/chartered-db/src/schema.rs b/chartered-db/src/schema.rs index 35ae527..3d9160d 100644 --- a/chartered-db/src/schema.rs +++ a/chartered-db/src/schema.rs @@ -33,6 +33,7 @@ id -> Integer, uuid -> Binary, name -> Text, + description -> Text, } } diff --git a/migrations/2021-08-31-214501_create_crates_table/up.sql b/migrations/2021-08-31-214501_create_crates_table/up.sql index 12b2538..fd57f0a 100644 --- a/migrations/2021-08-31-214501_create_crates_table/up.sql +++ a/migrations/2021-08-31-214501_create_crates_table/up.sql @@ -9,10 +9,11 @@ CREATE TABLE organisations ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, uuid BINARY(128) NOT NULL UNIQUE, - name VARCHAR(255) NOT NULL UNIQUE + name VARCHAR(255) NOT NULL UNIQUE, + description TEXT NOT NULL DEFAULT "" ); -INSERT INTO organisations (id, uuid, name) VALUES (1, X'936DA01F9ABD4D9D80C702AF85C822A8', "core"); +INSERT INTO organisations (id, uuid, name, description) VALUES (1, X'936DA01F9ABD4D9D80C702AF85C822A8', "core", "My first organisation"); CREATE TABLE crates ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, diff --git a/chartered-frontend/src/pages/crate/OrganisationView.tsx b/chartered-frontend/src/pages/crate/OrganisationView.tsx index d514142..935c1e6 100644 --- a/chartered-frontend/src/pages/crate/OrganisationView.tsx +++ a/chartered-frontend/src/pages/crate/OrganisationView.tsx @@ -24,6 +24,7 @@ possible_permissions?: string[]; crates: Crate[]; members: Member[]; + description: string; } interface Crate { @@ -63,8 +64,6 @@ return ; } - const description = "a collection of things and stuff."; - return (
diff --git a/chartered-web/src/endpoints/web_api/organisations/info.rs b/chartered-web/src/endpoints/web_api/organisations/info.rs index 26527a3..7d9a877 100644 --- a/chartered-web/src/endpoints/web_api/organisations/info.rs +++ a/chartered-web/src/endpoints/web_api/organisations/info.rs @@ -40,6 +40,7 @@ )?; Ok(Json(Response { + description: organisation.organisation().description.to_string(), possible_permissions: can_manage_users.then(UserPermission::all), crates: crates .into_iter() @@ -61,6 +62,7 @@ #[derive(Serialize)] pub struct Response { + description: String, possible_permissions: Option, crates: Vec, members: Vec, -- rgit 0.1.3