Sha256: 15761583edef6b9c209fbc811ccb5c4929b0add8c99344bf0d1bb0cb0155fb61

Contents?: true

Size: 1.34 KB

Versions: 46

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

module Decidim
  module Conferences
    module Admin
      # A command with all the business logic when updated a participatory
      # process admin in the system.
      class UpdateConferenceAdmin < NotifyRoleAssignedToConference
        # Public: Initializes the command.
        #
        # form - A form object with the params.
        # user_role - The ConferenceUSerRole to update
        def initialize(form, user_role)
          @form = form
          @user_role = user_role
        end

        # Executes the command. Broadcasts these events:
        #
        # - :ok when everything is valid.
        # - :invalid if the form wasn't valid and we couldn't proceed.
        #
        # Returns nothing.
        def call
          return broadcast(:invalid) if form.invalid?
          return broadcast(:invalid) unless user_role

          update_role!
          broadcast(:ok)
        end

        private

        attr_reader :form, :user_role

        def update_role!
          log_info = {
            resource: {
              title: user_role.user.name
            }
          }
          Decidim.traceability.update!(
            user_role,
            form.current_user,
            { role: form.role },
            log_info
          )
          send_notification user_role.user
        end
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
decidim-conferences-0.27.9 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.27.8 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.27.7 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.27.6 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.26.10 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.26.9 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.27.5 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.26.8 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.27.4 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.27.3 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.26.7 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.26.5 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.27.2 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.27.1 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.26.4 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.27.0 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.26.3 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.27.0.rc2 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.27.0.rc1 app/commands/decidim/conferences/admin/update_conference_admin.rb
decidim-conferences-0.26.2 app/commands/decidim/conferences/admin/update_conference_admin.rb