List authors of a blog

Update french translation accordingly

Fixes #129
This commit is contained in:
Bat
2018-07-18 23:08:49 +02:00
parent 216f334d75
commit ce256d6e39
8 changed files with 59 additions and 5 deletions
+10
View File
@@ -23,6 +23,7 @@ use plume_common::activity_pub::{
sign
};
use instance::*;
use users::User;
use schema::blogs;
pub type CustomGroup = CustomObject<ApSignature, Group>;
@@ -68,6 +69,15 @@ impl Blog {
Instance::get(conn, self.instance_id).expect("Couldn't find instance")
}
pub fn list_authors(&self, conn: &PgConnection) -> Vec<User> {
use schema::blog_authors;
use schema::users;
let authors_ids = blog_authors::table.filter(blog_authors::blog_id.eq(self.id)).select(blog_authors::author_id);
users::table.filter(users::id.eq(any(authors_ids)))
.load::<User>(conn)
.expect("Couldn't load authors of a blog")
}
pub fn find_for_author(conn: &PgConnection, author_id: i32) -> Vec<Blog> {
use schema::blog_authors;
let author_ids = blog_authors::table.filter(blog_authors::author_id.eq(author_id)).select(blog_authors::blog_id);