Class: Decidim::Admin::ConflictsController

Inherits:
ApplicationController show all
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



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

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
11
12
# File 'app/controllers/decidim/admin/conflicts_controller.rb', line 8

def index
  @conflicts = Decidim::Verifications::Conflict.joins(:current_user).where(
    decidim_users: { decidim_organization_id: current_organization.id }
  )
end

#updateObject



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

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