Class: Decidim::Admin::ConflictsController

Inherits:
ApplicationController show all
Includes:
VerificationConflicts::Filterable
Defined in:
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

Instance Method Details

#editObject

[View source]

18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/decidim/admin/conflicts_controller.rb', line 18

def edit
  enforce_permission_to :index, :impersonatable_user

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

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

#indexObject

[View source]

14
15
16
# File 'app/controllers/decidim/admin/conflicts_controller.rb', line 14

def index
  enforce_permission_to :index, :impersonatable_user
end

#updateObject

[View source]

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/decidim/admin/conflicts_controller.rb', line 30

def update
  enforce_permission_to :index, :impersonatable_user

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

  @form = form(TransferUserForm).from_params(
    current_user:,
    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