Define admin_search_user route

This commit is contained in:
Kitaiti Makoto 2023-03-20 00:59:46 +09:00
parent a1a19e091a
commit a394c3f210

View file

@ -160,7 +160,7 @@ pub fn toggle_block(
)) ))
} }
#[get("/admin/users?<page>")] #[get("/admin/users?<page>", rank = 2)]
pub fn admin_users( pub fn admin_users(
_mod: Moderator, _mod: Moderator,
page: Option<Page>, page: Option<Page>,
@ -171,6 +171,24 @@ pub fn admin_users(
Ok(render!(instance::users( Ok(render!(instance::users(
&(&conn, &rockets).to_context(), &(&conn, &rockets).to_context(),
User::get_local_page(&conn, page.limits())?, User::get_local_page(&conn, page.limits())?,
None,
page.0,
Page::total(User::count_local(&conn)? as i32)
)))
}
#[get("/admin/users?<user>&<page>", rank = 1)]
pub fn admin_search_users(
_mod: Moderator,
user: String,
page: Option<Page>,
conn: DbConn,
rockets: PlumeRocket,
) -> Result<Ructe, ErrorPage> {
let page = page.unwrap_or_default();
Ok(render!(instance::users(
&(&conn, &rockets).to_context(),
User::search_local_by_name(&conn, &user, page.limits())?,
Some(user.as_str()),
page.0, page.0,
Page::total(User::count_local(&conn)? as i32) Page::total(User::count_local(&conn)? as i32)
))) )))