Class: Decidim::Proposals::CollaborativeDraftCollaboratorRequestsController

Inherits:
CollaborativeDraftsController show all
Defined in:
app/controllers/decidim/proposals/collaborative_draft_collaborator_requests_controller.rb

Overview

Exposes Collaborative Draft Request actions for collaboration between participants on a resource.

Instance Method Summary collapse

Methods inherited from CollaborativeDraftsController

#create, #edit, #index, #new, #publish, #show, #update, #withdraw

Methods inherited from ApplicationController

#proposal_limit, #proposal_limit_reached?, #proposals

Instance Method Details

#request_acceptObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/decidim/proposals/collaborative_draft_collaborator_requests_controller.rb', line 24

def request_accept
  @accept_request_form = form(AcceptAccessToCollaborativeDraftForm).from_params(params)
  AcceptAccessToCollaborativeDraft.call(@accept_request_form, current_user) do
    on(:ok) do |requester_user|
      flash[:notice] = t("accepted_request.success", scope: "decidim.proposals.collaborative_drafts.requests", user: requester_user.nickname)
    end

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

#request_accessObject



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

def request_access
  @request_access_form = form(RequestAccessToCollaborativeDraftForm).from_params(params)
  RequestAccessToCollaborativeDraft.call(@request_access_form, current_user) do
    on(:ok) do |_collaborative_draft|
      flash[:notice] = t("access_requested.success", scope: "decidim.proposals.collaborative_drafts.requests")
    end

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

#request_rejectObject



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/decidim/proposals/collaborative_draft_collaborator_requests_controller.rb', line 38

def request_reject
  @reject_request_form = form(RejectAccessToCollaborativeDraftForm).from_params(params)
  RejectAccessToCollaborativeDraft.call(@reject_request_form, current_user) do
    on(:ok) do |requester_user|
      flash[:notice] = t("rejected_request.success", scope: "decidim.proposals.collaborative_drafts.requests", user: requester_user.nickname)
    end

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