Sha256: 7f92674af3e9c45971f5bac782c1dc84f5a43d5604f78fe05d0c4ec7dcdc4afd

Contents?: true

Size: 1.37 KB

Versions: 25

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

module Decidim
  module Conferences
    module Admin
      # This command is executed when the user updates the conference diploma configuration.
      class UpdateDiploma < Decidim::Command
        # Initializes a UpdateDiploma Command.
        #
        # form - The form from which to get the data.
        # conference - The current instance of the conference to be updated.
        def initialize(form, conference)
          @form = form
          @conference = conference
        end

        # Updates the conference if valid.
        #
        # Broadcasts :ok if successful, :invalid otherwise.
        def call
          return broadcast(:invalid) if form.invalid?

          @conference.with_lock do
            update_conference_diploma
            Decidim.traceability.perform_action!(:update_diploma, @conference, form.current_user) do
              @conference
            end
          end

          broadcast(:ok)
        end

        private

        attr_reader :form, :conference

        def update_conference_diploma
          @conference.main_logo = @form.main_logo if @form.main_logo.present?
          @conference.signature = @form.signature if @form.signature.present?
          @conference.signature_name = @form.signature_name
          @conference.sign_date = @form.sign_date

          @conference.save!
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-conferences-0.29.1 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.28.4 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.27.9 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.29.0 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.28.3 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.27.8 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.29.0.rc4 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.29.0.rc3 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.29.0.rc2 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.29.0.rc1 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.28.2 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.27.7 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.28.1 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.27.6 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.28.0 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.27.5 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.28.0.rc5 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.28.0.rc4 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.27.4 app/commands/decidim/conferences/admin/update_diploma.rb
decidim-conferences-0.27.3 app/commands/decidim/conferences/admin/update_diploma.rb