Class: Thredded::ModerationController
Instance Method Summary
collapse
Methods included from UrlsHelper
#delete_post_path, #edit_post_path, #edit_preferences_path, #edit_preferences_url, #mark_unread_path, #permalink_path, #post_path, #post_url, #quote_post_path, #search_path, #topic_path, #topic_url, #user_path
Instance Method Details
#activity ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# File 'app/controllers/thredded/moderation_controller.rb', line 26
def activity
@posts = Thredded::PostsPageView.new(
thredded_current_user,
moderatable_posts
.order_newest_first
.preload(:user, :postable, :messageboard)
.page(current_page)
)
maybe_set_last_moderated_record_flash
end
|
#history ⇒ Object
20
21
22
23
24
|
# File 'app/controllers/thredded/moderation_controller.rb', line 20
def history
@post_moderation_records = accessible_post_moderation_records
.order(created_at: :desc)
.page(current_page)
end
|
#moderate_post ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'app/controllers/thredded/moderation_controller.rb', line 37
def moderate_post
return head(:bad_request) unless Thredded::Post.moderation_states.include?(params[:moderation_state])
flash[:last_moderated_record_id] = Thredded::ModeratePost.run!(
post: moderatable_posts.find(params[:id]),
moderation_state: params[:moderation_state],
moderator: thredded_current_user,
).id
redirect_back fallback_location: pending_moderation_path
end
|
#moderate_user ⇒ Object
69
70
71
72
73
74
|
# File 'app/controllers/thredded/moderation_controller.rb', line 69
def moderate_user
return head(:bad_request) unless Thredded::UserDetail.moderation_states.include?(params[:moderation_state])
user = Thredded.user_class.find(params[:id])
user.thredded_user_detail.update!(moderation_state: params[:moderation_state])
redirect_back fallback_location: user_moderation_path(user.id)
end
|
#pending ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
|
# File 'app/controllers/thredded/moderation_controller.rb', line 8
def pending
@posts = Thredded::PostsPageView.new(
thredded_current_user,
moderatable_posts
.pending_moderation
.order_oldest_first
.preload(:user, :postable)
.page(current_page)
)
maybe_set_last_moderated_record_flash
end
|
#user ⇒ Object
58
59
60
61
62
63
64
65
66
67
|
# File 'app/controllers/thredded/moderation_controller.rb', line 58
def user
@user = Thredded.user_class.find(params[:id])
posts_scope = @user.thredded_posts
.where(messageboard_id: policy_scope(Messageboard.all).pluck(:id))
.order_newest_first
.includes(:postable)
.page(current_page)
@posts = Thredded::PostsPageView.new(thredded_current_user, posts_scope)
end
|
#users ⇒ Object
47
48
49
50
51
52
53
54
55
56
|
# File 'app/controllers/thredded/moderation_controller.rb', line 47
def users
@users = Thredded.user_class
.left_join_thredded_user_details
.merge(Thredded::UserDetail.order(moderation_state_changed_at: :desc))
@query = params[:q].to_s
if @query.present?
@users = DbTextSearch::CaseInsensitive.new(@users, Thredded.user_name_column).prefix(@query)
end
@users = @users.page(current_page)
end
|