Sha256: 01413ebc5c76e8d611a0f133f98a4e699467b9545082d8da37ab2862784f0160

Contents?: true

Size: 609 Bytes

Versions: 1

Compression:

Stored size: 609 Bytes

Contents

# frozen_string_literal: true

# Intercepts the `call` method and forces the Area of the user if it is a
# department_admin user.
module Decidim::Conferences::UpdateConferenceDecorator
  def self.decorate
    return unless Decidim::DepartmentAdmin.conferences_defined?

    Decidim::Conferences::Admin::UpdateConference.class_eval do
      alias_method :original_call, :call

      def call
        author = form.current_user
        form.area_id = author.areas.first.id if author.department_admin?
        original_call
      end
    end
  end
end

::Decidim::Conferences::UpdateConferenceDecorator.decorate

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-department_admin-0.7.2 app/decorators/decidim/conferences/update_conference_decorator.rb