Class: Thredded::ModerationController
Instance Method Summary
collapse
Methods included from UrlsHelper
#delete_post_path, #edit_post_path, #edit_preferences_path, #edit_preferences_url, #post_path, #post_url, #search_path, #topic_path, #topic_url, #user_path
Instance Method Details
#activity ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/thredded/moderation_controller.rb', line 29
def activity
@posts = PostsPageView.new(
thredded_current_user,
moderatable_posts
.order_newest_first
.preload(:user, :postable)
.page(current_page)
)
if flash[:last_moderated_record_id]
@last_moderated_record = accessible_post_moderation_records.find(flash[:last_moderated_record_id].to_i)
end
end
|
#history ⇒ Object
23
24
25
26
27
|
# File 'app/controllers/thredded/moderation_controller.rb', line 23
def history
@post_moderation_records = accessible_post_moderation_records
.order(created_at: :desc)
.page(current_page)
end
|
#moderate_post ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/thredded/moderation_controller.rb', line 42
def moderate_post
return head(:bad_request) unless Thredded::Post.moderation_states.include?(params[:moderation_state])
flash[:last_moderated_record_id] = 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
74
75
76
77
78
79
|
# File 'app/controllers/thredded/moderation_controller.rb', line 74
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
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'app/controllers/thredded/moderation_controller.rb', line 9
def pending
@posts = PostsPageView.new(
thredded_current_user,
moderatable_posts
.pending_moderation
.order_oldest_first
.preload(:user, :postable)
.page(current_page)
)
if flash[:last_moderated_record_id]
@last_moderated_record = accessible_post_moderation_records.find(flash[:last_moderated_record_id].to_i)
end
end
|
#user ⇒ Object
63
64
65
66
67
68
69
70
71
72
|
# File 'app/controllers/thredded/moderation_controller.rb', line 63
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 = PostsPageView.new(thredded_current_user, posts_scope)
end
|
#users ⇒ Object
52
53
54
55
56
57
58
59
60
61
|
# File 'app/controllers/thredded/moderation_controller.rb', line 52
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
|