Class: RailsImagePostSolution::Admin::FrozenPostsController

Inherits:
RailsImagePostSolution::ApplicationController show all
Defined in:
app/controllers/rails_image_post_solution/admin/frozen_posts_controller.rb

Instance Method Summary collapse

Methods inherited from RailsImagePostSolution::ApplicationController

#default_url_options, #require_admin, #require_login

Instance Method Details

#destroy_commentObject



66
67
68
69
70
# File 'app/controllers/rails_image_post_solution/admin/frozen_posts_controller.rb', line 66

def destroy_comment
  comment = MultiplayRecruitmentComment.find(params[:id])
  comment.destroy
  redirect_to admin_frozen_posts_path, notice: I18n.t("admin.flash.comment_deleted")
end

#destroy_stageObject



60
61
62
63
64
# File 'app/controllers/rails_image_post_solution/admin/frozen_posts_controller.rb', line 60

def destroy_stage
  stage = Stage.find(params[:id])
  stage.destroy
  redirect_to admin_frozen_posts_path, notice: I18n.t("admin.flash.stage_deleted")
end

#indexObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/rails_image_post_solution/admin/frozen_posts_controller.rb', line 9

def index
  @filter = params[:filter] || "all"

  # Get frozen stages and comments
  stages = Stage.frozen.includes(:user).recent
  comments = MultiplayRecruitmentComment.frozen.includes(:user, :multiplay_recruitment).recent

  case @filter
  when "temporary"
    stages = stages.temporarily_frozen
    comments = comments.temporarily_frozen
  when "permanent"
    stages = stages.permanently_frozen
    comments = comments.permanently_frozen
  end

  # Combine into array and sort by frozen_at
  @frozen_posts = (stages.to_a + comments.to_a).sort_by(&:frozen_at).reverse

  # Statistics
  @stats = {
    total: Stage.frozen.count + MultiplayRecruitmentComment.frozen.count,
    temporary: Stage.temporarily_frozen.count + MultiplayRecruitmentComment.temporarily_frozen.count,
    permanent: Stage.permanently_frozen.count + MultiplayRecruitmentComment.permanently_frozen.count
  }
end

#permanent_freeze_commentObject



54
55
56
57
58
# File 'app/controllers/rails_image_post_solution/admin/frozen_posts_controller.rb', line 54

def permanent_freeze_comment
  comment = MultiplayRecruitmentComment.find(params[:id])
  comment.freeze_post!(type: :permanent, reason: params[:reason] || I18n.t("admin.flash.permanent_freeze_by_admin"))
  redirect_to admin_frozen_posts_path, notice: I18n.t("admin.flash.comment_permanently_frozen")
end

#permanent_freeze_stageObject



48
49
50
51
52
# File 'app/controllers/rails_image_post_solution/admin/frozen_posts_controller.rb', line 48

def permanent_freeze_stage
  stage = Stage.find(params[:id])
  stage.freeze_post!(type: :permanent, reason: params[:reason] || I18n.t("admin.flash.permanent_freeze_by_admin"))
  redirect_to admin_frozen_posts_path, notice: I18n.t("admin.flash.stage_permanently_frozen")
end

#unfreeze_commentObject



42
43
44
45
46
# File 'app/controllers/rails_image_post_solution/admin/frozen_posts_controller.rb', line 42

def unfreeze_comment
  comment = MultiplayRecruitmentComment.find(params[:id])
  comment.unfreeze!
  redirect_to admin_frozen_posts_path, notice: I18n.t("admin.flash.comment_unfrozen")
end

#unfreeze_stageObject



36
37
38
39
40
# File 'app/controllers/rails_image_post_solution/admin/frozen_posts_controller.rb', line 36

def unfreeze_stage
  stage = Stage.find(params[:id])
  stage.unfreeze!
  redirect_to admin_frozen_posts_path, notice: I18n.t("admin.flash.stage_unfrozen")
end