Class: Decidim::Plans::PlanCollaboratorRequestsController

Inherits:
PlansController show all
Defined in:
app/controllers/decidim/plans/plan_collaborator_requests_controller.rb

Overview

Exposes Plan Request actions for collaboration between participants on a resource.

Instance Method Summary collapse

Methods inherited from PlansController

#close, #create, #destroy, #edit, #index, #new, #preview, #publish, #show, #update, #withdraw

Methods included from AttachedProposalsHelper

#attached_proposals_picker_field, #search_proposals

Methods inherited from ApplicationController

#plan_limit, #plan_limit_reached?, #plans

Instance Method Details

#request_acceptObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/decidim/plans/plan_collaborator_requests_controller.rb', line 26

def request_accept
  enforce_permission_to :edit, :plan, plan: @plan

  @accept_request_form = form(AcceptAccessToPlanForm).from_params(params)
  AcceptAccessToPlan.call(@accept_request_form, current_user) do
    on(:ok) do |requester_user|
      flash[:notice] = t("accepted_request.success", scope: "decidim.plans.requests", user: requester_user.nickname)
    end

    on(:invalid) do
      flash[:alert] = t("accepted_request.error", scope: "decidim.plans.requests")
    end
  end
  redirect_to Decidim::ResourceLocatorPresenter.new(@plan).path
end

#request_accessObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/decidim/plans/plan_collaborator_requests_controller.rb', line 10

def request_access
  enforce_permission_to :request_access, :plan, plan: @plan

  @request_access_form = form(RequestAccessToPlanForm).from_params(params)
  RequestAccessToPlan.call(@request_access_form, current_user) do
    on(:ok) do |_plan|
      flash[:notice] = t("access_requested.success", scope: "decidim.plans.requests")
    end

    on(:invalid) do
      flash[:alert] = t("access_requested.error", scope: "decidim.plans.requests")
    end
  end
  redirect_to Decidim::ResourceLocatorPresenter.new(@plan).path
end

#request_rejectObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/decidim/plans/plan_collaborator_requests_controller.rb', line 42

def request_reject
  enforce_permission_to :edit, :plan, plan: @plan

  @reject_request_form = form(RejectAccessToPlanForm).from_params(params)
  RejectAccessToPlan.call(@reject_request_form, current_user) do
    on(:ok) do |requester_user|
      flash[:notice] = t("rejected_request.success", scope: "decidim.plans.requests", user: requester_user.nickname)
    end

    on(:invalid) do
      flash.now[:alert] = t("rejected_request.error", scope: "decidim.plans.requests")
    end
  end
  redirect_to Decidim::ResourceLocatorPresenter.new(@plan).path
end