chore: finish renaming pages to communities
This commit is contained in:
parent
d6fbfc3cd6
commit
00abbc8fa2
8 changed files with 31 additions and 30 deletions
|
@ -15,6 +15,7 @@
|
|||
<span class="desktop">{{ text "general:link.home" }}</span>
|
||||
</a>
|
||||
|
||||
{% if user %}
|
||||
<a
|
||||
href="/communities"
|
||||
class="button {% if selected == 'communities' %}active{% endif %}"
|
||||
|
@ -24,7 +25,7 @@
|
|||
>{{ text "general:link.communities" }}</span
|
||||
>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %} {% endif %}
|
||||
</div>
|
||||
|
||||
<div class="flex nav_side">
|
||||
|
|
|
@ -14,7 +14,7 @@ impl DataManager {
|
|||
};
|
||||
|
||||
execute!(&conn, common::CREATE_TABLE_USERS).unwrap();
|
||||
execute!(&conn, common::CREATE_TABLE_JOURNALS).unwrap();
|
||||
execute!(&conn, common::CREATE_TABLE_COMMUNITIES).unwrap();
|
||||
execute!(&conn, common::CREATE_TABLE_POSTS).unwrap();
|
||||
execute!(&conn, common::CREATE_TABLE_MEMBERSHIPS).unwrap();
|
||||
execute!(&conn, common::CREATE_TABLE_REACTIONS).unwrap();
|
||||
|
|
|
@ -37,12 +37,12 @@ impl DataManager {
|
|||
}
|
||||
}
|
||||
|
||||
auto_method!(get_page_by_id()@get_community_from_row -> "SELECT * FROM journals WHERE id = $1" --name="journal" --returns=Community --cache-key-tmpl="atto.journal:{}");
|
||||
auto_method!(get_community_by_id()@get_community_from_row -> "SELECT * FROM communities WHERE id = $1" --name="community" --returns=Community --cache-key-tmpl="atto.community:{}");
|
||||
|
||||
/// Create a new journal page in the database.
|
||||
/// Create a new community in the database.
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `data` - a mock [`Journal`] object to insert
|
||||
/// * `data` - a mock [`Community`] to insert
|
||||
pub async fn create_community(&self, data: Community) -> Result<()> {
|
||||
// check values
|
||||
if data.title.len() < 2 {
|
||||
|
@ -59,7 +59,7 @@ impl DataManager {
|
|||
|
||||
let res = execute!(
|
||||
&conn,
|
||||
"INSERT INTO journals VALUES ($1, $2, $3, $4, $5, $6, $7)",
|
||||
"INSERT INTO communities VALUES ($1, $2, $3, $4, $5, $6, $7)",
|
||||
&[
|
||||
&data.id.to_string().as_str(),
|
||||
&data.created.to_string().as_str(),
|
||||
|
@ -88,14 +88,14 @@ impl DataManager {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
auto_method!(delete_community()@get_page_by_id:MANAGE_JOURNAL_PAGES -> "DELETE journals pages WHERE id = $1" --cache-key-tmpl="atto.journal:{}");
|
||||
auto_method!(update_community_title(String)@get_page_by_id:MANAGE_JOURNAL_PAGES -> "UPDATE journals SET title = $1 WHERE id = $2" --cache-key-tmpl="atto.journal:{}");
|
||||
auto_method!(update_community_context(CommunityContext)@get_page_by_id:MANAGE_JOURNAL_PAGES -> "UPDATE journals SET prompt = $1 WHERE id = $2" --serde --cache-key-tmpl="atto.journal:{}");
|
||||
auto_method!(update_community_read_access(CommunityReadAccess)@get_page_by_id:MANAGE_JOURNAL_PAGES -> "UPDATE journals SET read_access = $1 WHERE id = $2" --serde --cache-key-tmpl="atto.journal:{}");
|
||||
auto_method!(update_community_write_access(CommunityWriteAccess)@get_page_by_id:MANAGE_JOURNAL_PAGES -> "UPDATE journals SET write_access = $1 WHERE id = $2" --serde --cache-key-tmpl="atto.journal:{}");
|
||||
auto_method!(delete_community()@get_community_by_id:MANAGE_COMMUNITY_PAGES -> "DELETE communities pages WHERE id = $1" --cache-key-tmpl="atto.community:{}");
|
||||
auto_method!(update_community_title(String)@get_community_by_id:MANAGE_COMMUNITY_PAGES -> "UPDATE communities SET title = $1 WHERE id = $2" --cache-key-tmpl="atto.community:{}");
|
||||
auto_method!(update_community_context(CommunityContext)@get_community_by_id:MANAGE_COMMUNITY_PAGES -> "UPDATE communities SET prompt = $1 WHERE id = $2" --serde --cache-key-tmpl="atto.community:{}");
|
||||
auto_method!(update_community_read_access(CommunityReadAccess)@get_community_by_id:MANAGE_COMMUNITY_PAGES -> "UPDATE communities SET read_access = $1 WHERE id = $2" --serde --cache-key-tmpl="atto.community:{}");
|
||||
auto_method!(update_community_write_access(CommunityWriteAccess)@get_community_by_id:MANAGE_COMMUNITY_PAGES -> "UPDATE communities SET write_access = $1 WHERE id = $2" --serde --cache-key-tmpl="atto.community:{}");
|
||||
|
||||
auto_method!(incr_page_likes() -> "UPDATE journals SET likes = likes + 1 WHERE id = $1" --cache-key-tmpl="atto.journal:{}" --incr);
|
||||
auto_method!(incr_page_dislikes() -> "UPDATE journals SET likes = dislikes + 1 WHERE id = $1" --cache-key-tmpl="atto.journal:{}" --incr);
|
||||
auto_method!(decr_page_likes() -> "UPDATE journals SET likes = likes - 1 WHERE id = $1" --cache-key-tmpl="atto.journal:{}" --decr);
|
||||
auto_method!(decr_page_dislikes() -> "UPDATE journals SET likes = dislikes - 1 WHERE id = $1" --cache-key-tmpl="atto.journal:{}" --decr);
|
||||
auto_method!(incr_community_likes() -> "UPDATE communities SET likes = likes + 1 WHERE id = $1" --cache-key-tmpl="atto.community:{}" --incr);
|
||||
auto_method!(incr_community_dislikes() -> "UPDATE communities SET likes = dislikes + 1 WHERE id = $1" --cache-key-tmpl="atto.community:{}" --incr);
|
||||
auto_method!(decr_community_likes() -> "UPDATE communities SET likes = likes - 1 WHERE id = $1" --cache-key-tmpl="atto.community:{}" --decr);
|
||||
auto_method!(decr_community_dislikes() -> "UPDATE communities SET likes = dislikes - 1 WHERE id = $1" --cache-key-tmpl="atto.community:{}" --decr);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
pub const CREATE_TABLE_USERS: &str = include_str!("./sql/create_users.sql");
|
||||
pub const CREATE_TABLE_JOURNALS: &str = include_str!("./sql/create_journals.sql");
|
||||
pub const CREATE_TABLE_COMMUNITIES: &str = include_str!("./sql/create_communities.sql");
|
||||
pub const CREATE_TABLE_POSTS: &str = include_str!("./sql/create_posts.sql");
|
||||
pub const CREATE_TABLE_MEMBERSHIPS: &str = include_str!("./sql/create_memberships.sql");
|
||||
pub const CREATE_TABLE_REACTIONS: &str = include_str!("./sql/create_reactions.sql");
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
CREATE TABLE IF NOT EXISTS journals (
|
||||
CREATE TABLE IF NOT EXISTS communities (
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
created INTEGER NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
prompt TEXT NOT NULL,
|
||||
context TEXT NOT NULL,
|
||||
owner INTEGER NOT NULL,
|
||||
read_access TEXT NOT NULL,
|
||||
write_access TEXT NOT NULL,
|
|
@ -113,7 +113,7 @@ impl DataManager {
|
|||
}
|
||||
|
||||
// check permission in page
|
||||
let page = match self.get_page_by_id(data.community).await {
|
||||
let page = match self.get_community_by_id(data.community).await {
|
||||
Ok(p) => p,
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
|
@ -175,9 +175,9 @@ impl DataManager {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
auto_method!(delete_post()@get_post_by_id:MANAGE_JOURNAL_ENTRIES -> "DELETE FROM posts WHERE id = $1" --cache-key-tmpl="atto.post:{}");
|
||||
auto_method!(update_post_content(String)@get_post_by_id:MANAGE_JOURNAL_ENTRIES -> "UPDATE posts SET content = $1 WHERE id = $2" --cache-key-tmpl="atto.post:{}");
|
||||
auto_method!(update_post_context(PostContext)@get_post_by_id:MANAGE_JOURNAL_ENTRIES -> "UPDATE posts SET context = $1 WHERE id = $2" --serde --cache-key-tmpl="atto.post:{}");
|
||||
auto_method!(delete_post()@get_post_by_id:MANAGE_COMMUNITY_ENTRIES -> "DELETE FROM posts WHERE id = $1" --cache-key-tmpl="atto.post:{}");
|
||||
auto_method!(update_post_content(String)@get_post_by_id:MANAGE_COMMUNITY_ENTRIES -> "UPDATE posts SET content = $1 WHERE id = $2" --cache-key-tmpl="atto.post:{}");
|
||||
auto_method!(update_post_context(PostContext)@get_post_by_id:MANAGE_COMMUNITY_ENTRIES -> "UPDATE posts SET context = $1 WHERE id = $2" --serde --cache-key-tmpl="atto.post:{}");
|
||||
|
||||
auto_method!(incr_post_likes() -> "UPDATE posts SET likes = likes + 1 WHERE id = $1" --cache-key-tmpl="atto.post:{}" --incr);
|
||||
auto_method!(incr_post_dislikes() -> "UPDATE posts SET likes = dislikes + 1 WHERE id = $1" --cache-key-tmpl="atto.post:{}" --incr);
|
||||
|
|
|
@ -87,7 +87,7 @@ impl DataManager {
|
|||
// incr corresponding
|
||||
match data.asset_type {
|
||||
AssetType::Journal => {
|
||||
if let Err(e) = self.incr_page_likes(data.id).await {
|
||||
if let Err(e) = self.incr_community_likes(data.id).await {
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ impl DataManager {
|
|||
// decr corresponding
|
||||
match reaction.asset_type {
|
||||
AssetType::Journal => {
|
||||
if let Err(e) = self.decr_page_likes(reaction.asset).await {
|
||||
if let Err(e) = self.decr_community_likes(reaction.asset).await {
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ bitflags! {
|
|||
pub struct FinePermission: u32 {
|
||||
const DEFAULT = 1 << 0;
|
||||
const ADMINISTRATOR = 1 << 1;
|
||||
const MANAGE_JOURNAL_PAGES = 1 << 2;
|
||||
const MANAGE_JOURNAL_ENTRIES = 1 << 3;
|
||||
const MANAGE_JOURNAL_ENTRY_COMMENTS = 1 << 4;
|
||||
const MANAGE_COMMUNITY_PAGES = 1 << 2;
|
||||
const MANAGE_COMMUNITY_ENTRIES = 1 << 3;
|
||||
const MANAGE_POST_REPLIES = 1 << 4;
|
||||
const MANAGE_USERS = 1 << 5;
|
||||
const MANAGE_BANS = 1 << 6; // includes managing IP bans
|
||||
const MANAGE_WARNINGS = 1 << 7;
|
||||
|
@ -106,9 +106,9 @@ impl FinePermission {
|
|||
|
||||
/// Check if the given [`FinePermission`] qualifies as "Helper" status.
|
||||
pub fn check_helper(self) -> bool {
|
||||
self.check(FinePermission::MANAGE_JOURNAL_ENTRIES)
|
||||
&& self.check(FinePermission::MANAGE_JOURNAL_PAGES)
|
||||
&& self.check(FinePermission::MANAGE_JOURNAL_ENTRY_COMMENTS)
|
||||
self.check(FinePermission::MANAGE_COMMUNITY_ENTRIES)
|
||||
&& self.check(FinePermission::MANAGE_COMMUNITY_PAGES)
|
||||
&& self.check(FinePermission::MANAGE_POST_REPLIES)
|
||||
&& self.check(FinePermission::MANAGE_WARNINGS)
|
||||
&& self.check(FinePermission::VIEW_REPORTS)
|
||||
&& self.check(FinePermission::VIEW_AUDIT_LOG)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue