make everything work again
This commit is contained in:
parent
82606e720e
commit
0d2c1bacf9
10 changed files with 11 additions and 42 deletions
|
@ -3,7 +3,5 @@ CREATE TABLE IF NOT EXISTS users (
|
|||
username TEXT NOT NULL UNIQUE CHECK (LENGTH(username) <= 32),
|
||||
password_hash TEXT NOT NULL,
|
||||
email TEXT NOT NULL UNIQUE CHECK (LENGTH(email) <= 100),
|
||||
name TEXT NOT NULL CHECK (LENGTH(name) <= 100),
|
||||
created TIMESTAMP NOT NULL,
|
||||
updated TIMESTAMP NOT NULL
|
||||
name TEXT NOT NULL CHECK (LENGTH(name) <= 100)
|
||||
);
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
|
||||
DROP TABLE IF EXISTS projects;
|
||||
DROP TABLE IF EXISTS documents;
|
||||
|
|
|
@ -5,10 +5,7 @@ CREATE TABLE IF NOT EXISTS projects (
|
|||
name TEXT NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
|
||||
key TEXT NOT NULL,
|
||||
|
||||
created TIMESTAMP NOT NULL,
|
||||
updated TIMESTAMP NOT NULL
|
||||
key TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS documents (
|
||||
|
@ -17,8 +14,5 @@ CREATE TABLE IF NOT EXISTS documents (
|
|||
project_id UUID_TEXT NOT NULL,
|
||||
|
||||
title TEXT NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
|
||||
created TIMESTAMP NOT NULL,
|
||||
updated TIMESTAMP NOT NULL
|
||||
content TEXT NOT NULL
|
||||
);
|
||||
|
|
|
@ -4,8 +4,5 @@ CREATE TABLE IF NOT EXISTS project_memberships(
|
|||
|
||||
user_id UUID_TEXT NOT NULL,
|
||||
project_id UUID_TEXT NOT NULL,
|
||||
role TEXT NOT NULL,
|
||||
|
||||
created TIMESTAMP NOT NULL,
|
||||
updated TIMESTAMP NOT NULL
|
||||
role TEXT NOT NULL
|
||||
);
|
||||
|
|
|
@ -26,10 +26,12 @@ async fn render_documents_page(ctx: Context, user: User) -> Result<Response, (St
|
|||
let mut db = ctx.db_pool.get().map_err(internal_error)?;
|
||||
let documents =
|
||||
permissions::query::accessible_documents(&mut db, &user.id).map_err(internal_error)?;
|
||||
let projects = permissions::query::accessible_projects(&mut db, &user.id).map_err(internal_error)?;
|
||||
|
||||
let values = context! {
|
||||
user => user,
|
||||
documents => documents,
|
||||
projects => projects,
|
||||
};
|
||||
|
||||
Ok(ctx.render_resp("documents/list_documents.html", values))
|
||||
|
@ -122,10 +124,12 @@ pub async fn edit_document_page(
|
|||
}
|
||||
|
||||
let document = documents::query::by_id(&mut db, &id.to_string()).map_err(internal_error)?;
|
||||
let projects = permissions::query::accessible_projects(&mut db, &user.id).map_err(internal_error)?;
|
||||
|
||||
let values = context! {
|
||||
user => user,
|
||||
document => document,
|
||||
projects => projects,
|
||||
};
|
||||
|
||||
Ok(ctx.render_resp("documents/edit_document.html", values))
|
||||
|
|
|
@ -15,10 +15,6 @@ pub struct Document {
|
|||
pub project_id: String,
|
||||
pub title: String,
|
||||
pub content: String,
|
||||
#[serde(skip)]
|
||||
pub created: chrono::NaiveDateTime,
|
||||
#[serde(skip)]
|
||||
pub updated: chrono::NaiveDateTime,
|
||||
}
|
||||
|
||||
#[derive(Insertable)]
|
||||
|
@ -34,7 +30,7 @@ pub struct NewDocument {
|
|||
impl NewDocument {
|
||||
pub fn new(creator_id: &str, project_id: &str, title: String, content: String) -> Self {
|
||||
Self {
|
||||
id: Uuid::new_v4().to_string(),
|
||||
id: Uuid::now_v7().to_string(),
|
||||
creator_id: creator_id.to_string(),
|
||||
project_id: project_id.to_string(),
|
||||
title,
|
||||
|
|
|
@ -50,9 +50,6 @@ pub struct ProjectMembership {
|
|||
|
||||
#[diesel(serialize_as = String, deserialize_as = String)]
|
||||
pub role: ProjectRole,
|
||||
|
||||
pub created: chrono::NaiveDateTime,
|
||||
pub updated: chrono::NaiveDateTime,
|
||||
}
|
||||
|
||||
#[derive(Insertable)]
|
||||
|
|
|
@ -15,10 +15,6 @@ pub struct Project {
|
|||
pub name: String,
|
||||
pub description: String,
|
||||
pub key: String,
|
||||
#[serde(skip)]
|
||||
pub created: chrono::NaiveDateTime,
|
||||
#[serde(skip)]
|
||||
pub updated: chrono::NaiveDateTime,
|
||||
}
|
||||
|
||||
#[derive(Insertable)]
|
||||
|
@ -34,7 +30,7 @@ pub struct NewProject {
|
|||
impl NewProject {
|
||||
pub fn new(creator_id: String, name: String, description: String, key: String) -> Self {
|
||||
Self {
|
||||
id: Uuid::new_v4().to_string(),
|
||||
id: Uuid::now_v7().to_string(),
|
||||
creator_id,
|
||||
name,
|
||||
description,
|
||||
|
|
|
@ -17,10 +17,6 @@ pub struct User {
|
|||
pub password_hash: String,
|
||||
pub email: String,
|
||||
pub name: String,
|
||||
#[serde(skip)]
|
||||
pub created: chrono::NaiveDateTime,
|
||||
#[serde(skip)]
|
||||
pub updated: chrono::NaiveDateTime,
|
||||
}
|
||||
|
||||
#[derive(Insertable)]
|
||||
|
@ -37,7 +33,7 @@ impl NewUser {
|
|||
pub fn new(name: String, username: String, email: String, password: String) -> Self {
|
||||
let password_hash = password::hash(&password);
|
||||
Self {
|
||||
id: Uuid::new_v4().to_string(),
|
||||
id: Uuid::now_v7().to_string(),
|
||||
name,
|
||||
username,
|
||||
email,
|
||||
|
|
|
@ -7,8 +7,6 @@ diesel::table! {
|
|||
project_id -> Text,
|
||||
title -> Text,
|
||||
content -> Text,
|
||||
created -> Timestamp,
|
||||
updated -> Timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,8 +16,6 @@ diesel::table! {
|
|||
user_id -> Text,
|
||||
project_id -> Text,
|
||||
role -> Text,
|
||||
created -> Timestamp,
|
||||
updated -> Timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,8 +26,6 @@ diesel::table! {
|
|||
name -> Text,
|
||||
description -> Text,
|
||||
key -> Text,
|
||||
created -> Timestamp,
|
||||
updated -> Timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,8 +36,6 @@ diesel::table! {
|
|||
password_hash -> Text,
|
||||
email -> Text,
|
||||
name -> Text,
|
||||
created -> Timestamp,
|
||||
updated -> Timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue