Class: Decidim::Admin::ModerationsController

Inherits:
ApplicationController show all
Includes:
Moderations::Admin::Filterable
Defined in:
decidim-admin/app/controllers/decidim/admin/moderations_controller.rb

Overview

This controller allows admins to manage moderations in a participatory process.

Instance Method Summary collapse

Methods inherited from ApplicationController

#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path

Methods included from Headers::HttpCachingDisabler

#disable_http_caching

Methods included from NeedsSnippets

#snippets

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#hideObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'decidim-admin/app/controllers/decidim/admin/moderations_controller.rb', line 36

def hide
  enforce_permission_to :hide, permission_resource

  Admin::HideResource.call(reportable, current_user) do
    on(:ok) do
      flash[:notice] = I18n.t("reportable.hide.success", scope: "decidim.moderations.admin")
      redirect_to moderations_path
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("reportable.hide.invalid", scope: "decidim.moderations.admin")
      redirect_to moderations_path
    end
  end
end

#indexObject



11
12
13
# File 'decidim-admin/app/controllers/decidim/admin/moderations_controller.rb', line 11

def index
  enforce_permission_to :read, permission_resource
end

#showObject



15
16
17
18
# File 'decidim-admin/app/controllers/decidim/admin/moderations_controller.rb', line 15

def show
  enforce_permission_to :read, permission_resource
  @moderation = collection.find(params[:id])
end

#unhideObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'decidim-admin/app/controllers/decidim/admin/moderations_controller.rb', line 52

def unhide
  enforce_permission_to :unhide, permission_resource

  Admin::UnhideResource.call(reportable, current_user) do
    on(:ok) do
      flash[:notice] = I18n.t("reportable.unhide.success", scope: "decidim.moderations.admin")
      redirect_to moderations_path
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("reportable.unhide.invalid", scope: "decidim.moderations.admin")
      redirect_to moderations_path
    end
  end
end

#unreportObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'decidim-admin/app/controllers/decidim/admin/moderations_controller.rb', line 20

def unreport
  enforce_permission_to :unreport, permission_resource

  Admin::UnreportResource.call(reportable, current_user) do
    on(:ok) do
      flash[:notice] = I18n.t("reportable.unreport.success", scope: "decidim.moderations.admin")
      redirect_to moderations_path
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("reportable.unreport.invalid", scope: "decidim.moderations.admin")
      redirect_to moderations_path
    end
  end
end