|
|
|
@ -1,8 +1,11 @@
|
|
|
|
|
use crate::schema::{mod_remove_post, mod_lock_post, mod_remove_comment, mod_remove_community, mod_ban_from_community, mod_ban, mod_add_community, mod_add};
|
|
|
|
|
use super::*;
|
|
|
|
|
use crate::schema::{
|
|
|
|
|
mod_add, mod_add_community, mod_ban, mod_ban_from_community, mod_lock_post, mod_remove_comment,
|
|
|
|
|
mod_remove_community, mod_remove_post,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
|
|
|
|
#[table_name="mod_remove_post"]
|
|
|
|
|
#[table_name = "mod_remove_post"]
|
|
|
|
|
pub struct ModRemovePost {
|
|
|
|
|
pub id: i32,
|
|
|
|
|
pub mod_user_id: i32,
|
|
|
|
@ -13,7 +16,7 @@ pub struct ModRemovePost {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Insertable, AsChangeset, Clone, Serialize, Deserialize)]
|
|
|
|
|
#[table_name="mod_remove_post"]
|
|
|
|
|
#[table_name = "mod_remove_post"]
|
|
|
|
|
pub struct ModRemovePostForm {
|
|
|
|
|
pub mod_user_id: i32,
|
|
|
|
|
pub post_id: i32,
|
|
|
|
@ -24,21 +27,19 @@ pub struct ModRemovePostForm {
|
|
|
|
|
impl Crud<ModRemovePostForm> for ModRemovePost {
|
|
|
|
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_remove_post::dsl::*;
|
|
|
|
|
mod_remove_post.find(from_id)
|
|
|
|
|
.first::<Self>(conn)
|
|
|
|
|
mod_remove_post.find(from_id).first::<Self>(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
|
|
|
|
|
use crate::schema::mod_remove_post::dsl::*;
|
|
|
|
|
diesel::delete(mod_remove_post.find(from_id))
|
|
|
|
|
.execute(conn)
|
|
|
|
|
diesel::delete(mod_remove_post.find(from_id)).execute(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn create(conn: &PgConnection, form: &ModRemovePostForm) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_remove_post::dsl::*;
|
|
|
|
|
insert_into(mod_remove_post)
|
|
|
|
|
.values(form)
|
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
|
insert_into(mod_remove_post)
|
|
|
|
|
.values(form)
|
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn update(conn: &PgConnection, from_id: i32, form: &ModRemovePostForm) -> Result<Self, Error> {
|
|
|
|
@ -49,10 +50,8 @@ impl Crud<ModRemovePostForm> for ModRemovePost {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
|
|
|
|
#[table_name="mod_lock_post"]
|
|
|
|
|
#[table_name = "mod_lock_post"]
|
|
|
|
|
pub struct ModLockPost {
|
|
|
|
|
pub id: i32,
|
|
|
|
|
pub mod_user_id: i32,
|
|
|
|
@ -62,7 +61,7 @@ pub struct ModLockPost {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Insertable, AsChangeset, Clone, Serialize, Deserialize)]
|
|
|
|
|
#[table_name="mod_lock_post"]
|
|
|
|
|
#[table_name = "mod_lock_post"]
|
|
|
|
|
pub struct ModLockPostForm {
|
|
|
|
|
pub mod_user_id: i32,
|
|
|
|
|
pub post_id: i32,
|
|
|
|
@ -72,21 +71,19 @@ pub struct ModLockPostForm {
|
|
|
|
|
impl Crud<ModLockPostForm> for ModLockPost {
|
|
|
|
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_lock_post::dsl::*;
|
|
|
|
|
mod_lock_post.find(from_id)
|
|
|
|
|
.first::<Self>(conn)
|
|
|
|
|
mod_lock_post.find(from_id).first::<Self>(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
|
|
|
|
|
use crate::schema::mod_lock_post::dsl::*;
|
|
|
|
|
diesel::delete(mod_lock_post.find(from_id))
|
|
|
|
|
.execute(conn)
|
|
|
|
|
diesel::delete(mod_lock_post.find(from_id)).execute(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn create(conn: &PgConnection, form: &ModLockPostForm) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_lock_post::dsl::*;
|
|
|
|
|
insert_into(mod_lock_post)
|
|
|
|
|
.values(form)
|
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
|
insert_into(mod_lock_post)
|
|
|
|
|
.values(form)
|
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn update(conn: &PgConnection, from_id: i32, form: &ModLockPostForm) -> Result<Self, Error> {
|
|
|
|
@ -98,7 +95,7 @@ impl Crud<ModLockPostForm> for ModLockPost {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
|
|
|
|
#[table_name="mod_remove_comment"]
|
|
|
|
|
#[table_name = "mod_remove_comment"]
|
|
|
|
|
pub struct ModRemoveComment {
|
|
|
|
|
pub id: i32,
|
|
|
|
|
pub mod_user_id: i32,
|
|
|
|
@ -109,7 +106,7 @@ pub struct ModRemoveComment {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Insertable, AsChangeset, Clone, Serialize, Deserialize)]
|
|
|
|
|
#[table_name="mod_remove_comment"]
|
|
|
|
|
#[table_name = "mod_remove_comment"]
|
|
|
|
|
pub struct ModRemoveCommentForm {
|
|
|
|
|
pub mod_user_id: i32,
|
|
|
|
|
pub comment_id: i32,
|
|
|
|
@ -120,21 +117,19 @@ pub struct ModRemoveCommentForm {
|
|
|
|
|
impl Crud<ModRemoveCommentForm> for ModRemoveComment {
|
|
|
|
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_remove_comment::dsl::*;
|
|
|
|
|
mod_remove_comment.find(from_id)
|
|
|
|
|
.first::<Self>(conn)
|
|
|
|
|
mod_remove_comment.find(from_id).first::<Self>(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
|
|
|
|
|
use crate::schema::mod_remove_comment::dsl::*;
|
|
|
|
|
diesel::delete(mod_remove_comment.find(from_id))
|
|
|
|
|
.execute(conn)
|
|
|
|
|
diesel::delete(mod_remove_comment.find(from_id)).execute(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn create(conn: &PgConnection, form: &ModRemoveCommentForm) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_remove_comment::dsl::*;
|
|
|
|
|
insert_into(mod_remove_comment)
|
|
|
|
|
.values(form)
|
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
|
insert_into(mod_remove_comment)
|
|
|
|
|
.values(form)
|
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn update(conn: &PgConnection, from_id: i32, form: &ModRemoveCommentForm) -> Result<Self, Error> {
|
|
|
|
@ -146,7 +141,7 @@ impl Crud<ModRemoveCommentForm> for ModRemoveComment {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
|
|
|
|
#[table_name="mod_remove_community"]
|
|
|
|
|
#[table_name = "mod_remove_community"]
|
|
|
|
|
pub struct ModRemoveCommunity {
|
|
|
|
|
pub id: i32,
|
|
|
|
|
pub mod_user_id: i32,
|
|
|
|
@ -158,7 +153,7 @@ pub struct ModRemoveCommunity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Insertable, AsChangeset, Clone, Serialize, Deserialize)]
|
|
|
|
|
#[table_name="mod_remove_community"]
|
|
|
|
|
#[table_name = "mod_remove_community"]
|
|
|
|
|
pub struct ModRemoveCommunityForm {
|
|
|
|
|
pub mod_user_id: i32,
|
|
|
|
|
pub community_id: i32,
|
|
|
|
@ -170,24 +165,26 @@ pub struct ModRemoveCommunityForm {
|
|
|
|
|
impl Crud<ModRemoveCommunityForm> for ModRemoveCommunity {
|
|
|
|
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_remove_community::dsl::*;
|
|
|
|
|
mod_remove_community.find(from_id)
|
|
|
|
|
.first::<Self>(conn)
|
|
|
|
|
mod_remove_community.find(from_id).first::<Self>(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
|
|
|
|
|
use crate::schema::mod_remove_community::dsl::*;
|
|
|
|
|
diesel::delete(mod_remove_community.find(from_id))
|
|
|
|
|
.execute(conn)
|
|
|
|
|
diesel::delete(mod_remove_community.find(from_id)).execute(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn create(conn: &PgConnection, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_remove_community::dsl::*;
|
|
|
|
|
insert_into(mod_remove_community)
|
|
|
|
|
.values(form)
|
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
|
insert_into(mod_remove_community)
|
|
|
|
|
.values(form)
|
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn update(conn: &PgConnection, from_id: i32, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
|
|
|
|
|
fn update(
|
|
|
|
|
conn: &PgConnection,
|
|
|
|
|
from_id: i32,
|
|
|
|
|
form: &ModRemoveCommunityForm,
|
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_remove_community::dsl::*;
|
|
|
|
|
diesel::update(mod_remove_community.find(from_id))
|
|
|
|
|
.set(form)
|
|
|
|
@ -196,7 +193,7 @@ impl Crud<ModRemoveCommunityForm> for ModRemoveCommunity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
|
|
|
|
#[table_name="mod_ban_from_community"]
|
|
|
|
|
#[table_name = "mod_ban_from_community"]
|
|
|
|
|
pub struct ModBanFromCommunity {
|
|
|
|
|
pub id: i32,
|
|
|
|
|
pub mod_user_id: i32,
|
|
|
|
@ -209,7 +206,7 @@ pub struct ModBanFromCommunity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Insertable, AsChangeset, Clone, Serialize, Deserialize)]
|
|
|
|
|
#[table_name="mod_ban_from_community"]
|
|
|
|
|
#[table_name = "mod_ban_from_community"]
|
|
|
|
|
pub struct ModBanFromCommunityForm {
|
|
|
|
|
pub mod_user_id: i32,
|
|
|
|
|
pub other_user_id: i32,
|
|
|
|
@ -222,24 +219,26 @@ pub struct ModBanFromCommunityForm {
|
|
|
|
|
impl Crud<ModBanFromCommunityForm> for ModBanFromCommunity {
|
|
|
|
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_ban_from_community::dsl::*;
|
|
|
|
|
mod_ban_from_community.find(from_id)
|
|
|
|
|
.first::<Self>(conn)
|
|
|
|
|
mod_ban_from_community.find(from_id).first::<Self>(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
|
|
|
|
|
use crate::schema::mod_ban_from_community::dsl::*;
|
|
|
|
|
diesel::delete(mod_ban_from_community.find(from_id))
|
|
|
|
|
.execute(conn)
|
|
|
|
|
diesel::delete(mod_ban_from_community.find(from_id)).execute(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn create(conn: &PgConnection, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_ban_from_community::dsl::*;
|
|
|
|
|
insert_into(mod_ban_from_community)
|
|
|
|
|
.values(form)
|
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
|
insert_into(mod_ban_from_community)
|
|
|
|
|
.values(form)
|
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn update(conn: &PgConnection, from_id: i32, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
|
|
|
|
|
fn update(
|
|
|
|
|
conn: &PgConnection,
|
|
|
|
|
from_id: i32,
|
|
|
|
|
form: &ModBanFromCommunityForm,
|
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_ban_from_community::dsl::*;
|
|
|
|
|
diesel::update(mod_ban_from_community.find(from_id))
|
|
|
|
|
.set(form)
|
|
|
|
@ -247,9 +246,8 @@ impl Crud<ModBanFromCommunityForm> for ModBanFromCommunity {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
|
|
|
|
#[table_name="mod_ban"]
|
|
|
|
|
#[table_name = "mod_ban"]
|
|
|
|
|
pub struct ModBan {
|
|
|
|
|
pub id: i32,
|
|
|
|
|
pub mod_user_id: i32,
|
|
|
|
@ -261,7 +259,7 @@ pub struct ModBan {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Insertable, AsChangeset, Clone, Serialize, Deserialize)]
|
|
|
|
|
#[table_name="mod_ban"]
|
|
|
|
|
#[table_name = "mod_ban"]
|
|
|
|
|
pub struct ModBanForm {
|
|
|
|
|
pub mod_user_id: i32,
|
|
|
|
|
pub other_user_id: i32,
|
|
|
|
@ -273,21 +271,17 @@ pub struct ModBanForm {
|
|
|
|
|
impl Crud<ModBanForm> for ModBan {
|
|
|
|
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_ban::dsl::*;
|
|
|
|
|
mod_ban.find(from_id)
|
|
|
|
|
.first::<Self>(conn)
|
|
|
|
|
mod_ban.find(from_id).first::<Self>(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
|
|
|
|
|
use crate::schema::mod_ban::dsl::*;
|
|
|
|
|
diesel::delete(mod_ban.find(from_id))
|
|
|
|
|
.execute(conn)
|
|
|
|
|
diesel::delete(mod_ban.find(from_id)).execute(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn create(conn: &PgConnection, form: &ModBanForm) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_ban::dsl::*;
|
|
|
|
|
insert_into(mod_ban)
|
|
|
|
|
.values(form)
|
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
|
insert_into(mod_ban).values(form).get_result::<Self>(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn update(conn: &PgConnection, from_id: i32, form: &ModBanForm) -> Result<Self, Error> {
|
|
|
|
@ -299,7 +293,7 @@ impl Crud<ModBanForm> for ModBan {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
|
|
|
|
#[table_name="mod_add_community"]
|
|
|
|
|
#[table_name = "mod_add_community"]
|
|
|
|
|
pub struct ModAddCommunity {
|
|
|
|
|
pub id: i32,
|
|
|
|
|
pub mod_user_id: i32,
|
|
|
|
@ -310,7 +304,7 @@ pub struct ModAddCommunity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Insertable, AsChangeset, Clone, Serialize, Deserialize)]
|
|
|
|
|
#[table_name="mod_add_community"]
|
|
|
|
|
#[table_name = "mod_add_community"]
|
|
|
|
|
pub struct ModAddCommunityForm {
|
|
|
|
|
pub mod_user_id: i32,
|
|
|
|
|
pub other_user_id: i32,
|
|
|
|
@ -321,21 +315,19 @@ pub struct ModAddCommunityForm {
|
|
|
|
|
impl Crud<ModAddCommunityForm> for ModAddCommunity {
|
|
|
|
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_add_community::dsl::*;
|
|
|
|
|
mod_add_community.find(from_id)
|
|
|
|
|
.first::<Self>(conn)
|
|
|
|
|
mod_add_community.find(from_id).first::<Self>(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
|
|
|
|
|
use crate::schema::mod_add_community::dsl::*;
|
|
|
|
|
diesel::delete(mod_add_community.find(from_id))
|
|
|
|
|
.execute(conn)
|
|
|
|
|
diesel::delete(mod_add_community.find(from_id)).execute(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn create(conn: &PgConnection, form: &ModAddCommunityForm) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_add_community::dsl::*;
|
|
|
|
|
insert_into(mod_add_community)
|
|
|
|
|
.values(form)
|
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
|
insert_into(mod_add_community)
|
|
|
|
|
.values(form)
|
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn update(conn: &PgConnection, from_id: i32, form: &ModAddCommunityForm) -> Result<Self, Error> {
|
|
|
|
@ -347,7 +339,7 @@ impl Crud<ModAddCommunityForm> for ModAddCommunity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
|
|
|
|
#[table_name="mod_add"]
|
|
|
|
|
#[table_name = "mod_add"]
|
|
|
|
|
pub struct ModAdd {
|
|
|
|
|
pub id: i32,
|
|
|
|
|
pub mod_user_id: i32,
|
|
|
|
@ -357,7 +349,7 @@ pub struct ModAdd {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Insertable, AsChangeset, Clone, Serialize, Deserialize)]
|
|
|
|
|
#[table_name="mod_add"]
|
|
|
|
|
#[table_name = "mod_add"]
|
|
|
|
|
pub struct ModAddForm {
|
|
|
|
|
pub mod_user_id: i32,
|
|
|
|
|
pub other_user_id: i32,
|
|
|
|
@ -367,21 +359,17 @@ pub struct ModAddForm {
|
|
|
|
|
impl Crud<ModAddForm> for ModAdd {
|
|
|
|
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_add::dsl::*;
|
|
|
|
|
mod_add.find(from_id)
|
|
|
|
|
.first::<Self>(conn)
|
|
|
|
|
mod_add.find(from_id).first::<Self>(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
|
|
|
|
|
use crate::schema::mod_add::dsl::*;
|
|
|
|
|
diesel::delete(mod_add.find(from_id))
|
|
|
|
|
.execute(conn)
|
|
|
|
|
diesel::delete(mod_add.find(from_id)).execute(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn create(conn: &PgConnection, form: &ModAddForm) -> Result<Self, Error> {
|
|
|
|
|
use crate::schema::mod_add::dsl::*;
|
|
|
|
|
insert_into(mod_add)
|
|
|
|
|
.values(form)
|
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
|
insert_into(mod_add).values(form).get_result::<Self>(conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn update(conn: &PgConnection, from_id: i32, form: &ModAddForm) -> Result<Self, Error> {
|
|
|
|
@ -394,13 +382,13 @@ impl Crud<ModAddForm> for ModAdd {
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
mod tests {
|
|
|
|
|
use super::*;
|
|
|
|
|
use super::super::user::*;
|
|
|
|
|
use super::super::post::*;
|
|
|
|
|
use super::super::community::*;
|
|
|
|
|
use super::super::comment::*;
|
|
|
|
|
use super::super::community::*;
|
|
|
|
|
use super::super::post::*;
|
|
|
|
|
use super::super::user::*;
|
|
|
|
|
use super::*;
|
|
|
|
|
// use Crud;
|
|
|
|
|
#[test]
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_crud() {
|
|
|
|
|
let conn = establish_connection();
|
|
|
|
|
|
|
|
|
@ -445,7 +433,7 @@ mod tests {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let new_post = PostForm {
|
|
|
|
|
name: "A test post thweep".into(),
|
|
|
|
|
url: None,
|
|
|
|
@ -469,7 +457,7 @@ mod tests {
|
|
|
|
|
deleted: None,
|
|
|
|
|
read: None,
|
|
|
|
|
parent_id: None,
|
|
|
|
|
updated: None
|
|
|
|
|
updated: None,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
|
|
|
|
@ -484,7 +472,8 @@ mod tests {
|
|
|
|
|
removed: None,
|
|
|
|
|
};
|
|
|
|
|
let inserted_mod_remove_post = ModRemovePost::create(&conn, &mod_remove_post_form).unwrap();
|
|
|
|
|
let read_moderator_remove_post = ModRemovePost::read(&conn, inserted_mod_remove_post.id).unwrap();
|
|
|
|
|
let read_moderator_remove_post =
|
|
|
|
|
ModRemovePost::read(&conn, inserted_mod_remove_post.id).unwrap();
|
|
|
|
|
let expected_moderator_remove_post = ModRemovePost {
|
|
|
|
|
id: inserted_mod_remove_post.id,
|
|
|
|
|
post_id: inserted_post.id,
|
|
|
|
@ -519,8 +508,10 @@ mod tests {
|
|
|
|
|
reason: None,
|
|
|
|
|
removed: None,
|
|
|
|
|
};
|
|
|
|
|
let inserted_mod_remove_comment = ModRemoveComment::create(&conn, &mod_remove_comment_form).unwrap();
|
|
|
|
|
let read_moderator_remove_comment = ModRemoveComment::read(&conn, inserted_mod_remove_comment.id).unwrap();
|
|
|
|
|
let inserted_mod_remove_comment =
|
|
|
|
|
ModRemoveComment::create(&conn, &mod_remove_comment_form).unwrap();
|
|
|
|
|
let read_moderator_remove_comment =
|
|
|
|
|
ModRemoveComment::read(&conn, inserted_mod_remove_comment.id).unwrap();
|
|
|
|
|
let expected_moderator_remove_comment = ModRemoveComment {
|
|
|
|
|
id: inserted_mod_remove_comment.id,
|
|
|
|
|
comment_id: inserted_comment.id,
|
|
|
|
@ -539,8 +530,10 @@ mod tests {
|
|
|
|
|
removed: None,
|
|
|
|
|
expires: None,
|
|
|
|
|
};
|
|
|
|
|
let inserted_mod_remove_community = ModRemoveCommunity::create(&conn, &mod_remove_community_form).unwrap();
|
|
|
|
|
let read_moderator_remove_community = ModRemoveCommunity::read(&conn, inserted_mod_remove_community.id).unwrap();
|
|
|
|
|
let inserted_mod_remove_community =
|
|
|
|
|
ModRemoveCommunity::create(&conn, &mod_remove_community_form).unwrap();
|
|
|
|
|
let read_moderator_remove_community =
|
|
|
|
|
ModRemoveCommunity::read(&conn, inserted_mod_remove_community.id).unwrap();
|
|
|
|
|
let expected_moderator_remove_community = ModRemoveCommunity {
|
|
|
|
|
id: inserted_mod_remove_community.id,
|
|
|
|
|
community_id: inserted_community.id,
|
|
|
|
@ -561,8 +554,10 @@ mod tests {
|
|
|
|
|
banned: None,
|
|
|
|
|
expires: None,
|
|
|
|
|
};
|
|
|
|
|
let inserted_mod_ban_from_community = ModBanFromCommunity::create(&conn, &mod_ban_from_community_form).unwrap();
|
|
|
|
|
let read_moderator_ban_from_community = ModBanFromCommunity::read(&conn, inserted_mod_ban_from_community.id).unwrap();
|
|
|
|
|
let inserted_mod_ban_from_community =
|
|
|
|
|
ModBanFromCommunity::create(&conn, &mod_ban_from_community_form).unwrap();
|
|
|
|
|
let read_moderator_ban_from_community =
|
|
|
|
|
ModBanFromCommunity::read(&conn, inserted_mod_ban_from_community.id).unwrap();
|
|
|
|
|
let expected_moderator_ban_from_community = ModBanFromCommunity {
|
|
|
|
|
id: inserted_mod_ban_from_community.id,
|
|
|
|
|
community_id: inserted_community.id,
|
|
|
|
@ -603,8 +598,10 @@ mod tests {
|
|
|
|
|
community_id: inserted_community.id,
|
|
|
|
|
removed: None,
|
|
|
|
|
};
|
|
|
|
|
let inserted_mod_add_community = ModAddCommunity::create(&conn, &mod_add_community_form).unwrap();
|
|
|
|
|
let read_moderator_add_community = ModAddCommunity::read(&conn, inserted_mod_add_community.id).unwrap();
|
|
|
|
|
let inserted_mod_add_community =
|
|
|
|
|
ModAddCommunity::create(&conn, &mod_add_community_form).unwrap();
|
|
|
|
|
let read_moderator_add_community =
|
|
|
|
|
ModAddCommunity::read(&conn, inserted_mod_add_community.id).unwrap();
|
|
|
|
|
let expected_moderator_add_community = ModAddCommunity {
|
|
|
|
|
id: inserted_mod_add_community.id,
|
|
|
|
|
community_id: inserted_community.id,
|
|
|
|
@ -648,11 +645,23 @@ mod tests {
|
|
|
|
|
|
|
|
|
|
assert_eq!(expected_moderator_remove_post, read_moderator_remove_post);
|
|
|
|
|
assert_eq!(expected_moderator_lock_post, read_moderator_lock_post);
|
|
|
|
|
assert_eq!(expected_moderator_remove_comment, read_moderator_remove_comment);
|
|
|
|
|
assert_eq!(expected_moderator_remove_community, read_moderator_remove_community);
|
|
|
|
|
assert_eq!(expected_moderator_ban_from_community, read_moderator_ban_from_community);
|
|
|
|
|
assert_eq!(
|
|
|
|
|
expected_moderator_remove_comment,
|
|
|
|
|
read_moderator_remove_comment
|
|
|
|
|
);
|
|
|
|
|
assert_eq!(
|
|
|
|
|
expected_moderator_remove_community,
|
|
|
|
|
read_moderator_remove_community
|
|
|
|
|
);
|
|
|
|
|
assert_eq!(
|
|
|
|
|
expected_moderator_ban_from_community,
|
|
|
|
|
read_moderator_ban_from_community
|
|
|
|
|
);
|
|
|
|
|
assert_eq!(expected_moderator_ban, read_moderator_ban);
|
|
|
|
|
assert_eq!(expected_moderator_add_community, read_moderator_add_community);
|
|
|
|
|
assert_eq!(
|
|
|
|
|
expected_moderator_add_community,
|
|
|
|
|
read_moderator_add_community
|
|
|
|
|
);
|
|
|
|
|
assert_eq!(expected_moderator_add, read_moderator_add);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|