Class: Decidim::Admin::ConflictsController

Inherits:
ApplicationController show all
Defined in:
decidim-admin/app/controllers/decidim/admin/conflicts_controller.rb

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 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

#editObject


12
13
14
15
16
17
18
19
20
# File 'decidim-admin/app/controllers/decidim/admin/conflicts_controller.rb', line 12

def edit
  conflict = Decidim::Verifications::Conflict.find(params[:id])

  @form = form(TransferUserForm).from_params(
    user: conflict.current_user,
    managed_user: conflict.managed_user,
    conflict: conflict
  )
end

#indexObject


8
9
10
# File 'decidim-admin/app/controllers/decidim/admin/conflicts_controller.rb', line 8

def index
  @conflicts = Decidim::Verifications::Conflict.all
end

#updateObject


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'decidim-admin/app/controllers/decidim/admin/conflicts_controller.rb', line 22

def update
  conflict = Decidim::Verifications::Conflict.find(params[:id])

  @form = form(TransferUserForm).from_params(
    current_user: current_user,
    conflict: conflict,
    reason: params[:transfer_user][:reason],
    email: params[:transfer_user][:email]
  )

  TransferUser.call(@form) do
    on(:ok) do
      flash[:notice] = I18n.t("success", scope: "decidim.admin.conflicts.transfer")
      redirect_to conflicts_path
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("error", scope: "decidim.admin.conflicts.transfer")
      redirect_to decidim.root_path
    end
  end
end