Class: Decidim::Plans::AcceptAccessToPlan
- Inherits:
-
RespondToAccessRequest
- Object
- Rectify::Command
- RespondToAccessRequest
- Decidim::Plans::AcceptAccessToPlan
- Defined in:
- app/commands/decidim/plans/accept_access_to_plan.rb
Overview
A command with all the business logic to accept a user request to contribute to a plan.
Instance Method Summary collapse
- #authors_event ⇒ Object
- #authors_event_class ⇒ Object
-
#call ⇒ Object
Executes the command.
- #recipients ⇒ Object
- #requester_event ⇒ Object
- #requester_event_class ⇒ Object
Methods inherited from RespondToAccessRequest
#initialize, #notify_plan_authors, #notify_plan_requester
Constructor Details
This class inherits a constructor from Decidim::Plans::RespondToAccessRequest
Instance Method Details
#authors_event ⇒ Object
36 37 38 |
# File 'app/commands/decidim/plans/accept_access_to_plan.rb', line 36 def "decidim.events.plans.plan_access_accepted" end |
#authors_event_class ⇒ Object
40 41 42 |
# File 'app/commands/decidim/plans/accept_access_to_plan.rb', line 40 def Decidim::Plans::PlanAccessAcceptedEvent end |
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if it wasn’t valid and we couldn’t proceed.
Returns nothing.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/commands/decidim/plans/accept_access_to_plan.rb', line 14 def call return broadcast(:invalid) if @form.invalid? return broadcast(:invalid) if @current_user.nil? transaction do @plan.requesters.delete @requester_user Decidim::.create( coauthorable: @plan, author: @requester_user ) end notify_plan_requester broadcast(:ok, @requester_user) end |
#recipients ⇒ Object
32 33 34 |
# File 'app/commands/decidim/plans/accept_access_to_plan.rb', line 32 def recipients @plan. - [@requester_user] end |
#requester_event ⇒ Object
44 45 46 |
# File 'app/commands/decidim/plans/accept_access_to_plan.rb', line 44 def requester_event "decidim.events.plans.plan_access_requester_accepted" end |
#requester_event_class ⇒ Object
48 49 50 |
# File 'app/commands/decidim/plans/accept_access_to_plan.rb', line 48 def requester_event_class Decidim::Plans::PlanAccessRequesterAcceptedEvent end |