🏡 index : ~doyle/chartered.git

author Jordan Doyle <jordan@doyle.la> 2021-09-25 2:19:09.0 +01:00:00
committer Jordan Doyle <jordan@doyle.la> 2021-09-25 2:19:09.0 +01:00:00
commit
b369917fae3a7ff257749a5322096516c2a76fca [patch]
tree
9560390da9f551be0129ee52c02eb4c0b9da7217
parent
a7544b43b22dbd2baff1c1a736b766acac5519aa
download
b369917fae3a7ff257749a5322096516c2a76fca.tar.gz

Organisation descriptions



Diff

 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<Self>, conn: ConnectionPool) -> Result<Vec<Crate>> {
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 <Loading />;
  }

  const description = "a collection of things and stuff.";

  return (
    <div className="text-white">
      <Nav />
@@ -82,7 +81,7 @@

                  <div className="px-2">
                    <h1 className="text-primary my-0">{organisation}</h1>
                    <p className="m-0">{description}</p>
                    <p className="m-0">{organisationDetails.description}</p>
                  </div>
                </div>
              </div>
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<UserPermission>,
    crates: Vec<ResponseCrate>,
    members: Vec<ResponseUser>,