Sha256: b340d29aaec2cb33dd40253321ed8a3323aa699c452230c935ec9c3cb0a9ebb8
Contents?: true
Size: 1.02 KB
Versions: 6
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true module Decidim module Plans # A command with all the business logic when a user reopens a plan. class ReopenPlan < Rectify::Command # Public: Initializes the command. # # plan - The plan to publish. # current_user - The current user. def initialize(plan, current_user) @plan = plan @current_user = current_user end # Executes the command. Broadcasts these events: # # - :ok when everything is valid and the plan is published. # - :invalid if the plan's author is not the current user. # # Returns nothing. def call return broadcast(:invalid) if @current_user.nil? close_plan broadcast(:ok, @plan) end private def close_plan Decidim.traceability.perform_action!( "reopen", @plan, @current_user, visibility: "public-only" ) do @plan.update closed_at: nil end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems