diff --git a/applications/admin.moon b/applications/admin.moon index fdcf889..5a14689 100644 --- a/applications/admin.moon +++ b/applications/admin.moon @@ -491,10 +491,17 @@ class AdminApplication extends lapis.Application [community_posts: "/community-posts"]: capture_errors_json with_params { {"page", shapes.page_number} + {"user_id", types.empty + types.db_id} + {"topic_id", types.empty + types.db_id} }, (params) => import Posts from require "community.models" - @pager = Posts\paginated "order by id desc", { + filter = db.clause { + user_id: params.user_id + topic_id: params.topic_id + }, allow_empty: true, prefix: "where" + + @pager = Posts\paginated "? order by id desc", filter, { per_page: 50 prepare_results: (posts) -> preload posts, "user", topic: { category: "streak" } diff --git a/views/admin/community_posts.moon b/views/admin/community_posts.moon index d365a53..38f7fcd 100644 --- a/views/admin/community_posts.moon +++ b/views/admin/community_posts.moon @@ -8,6 +8,11 @@ class AdminCommunityPosts extends require "widgets.admin.page" column_content: => h2 "Community posts" + + @filter_form (field) -> + field "user_id" + field "topic_id" + @render_pager @pager @column_table @posts, { @@ -37,6 +42,8 @@ class AdminCommunityPosts extends require "widgets.admin.page" if user\is_spam! strong " spam" } + "deleted" + "edits_count" {"text", (post) -> text @truncate post\extract_text!, 80 }