Sha256: 5737ef01059e2d46203d8b0a48a867bb28a10731790335d72e61f0dcaed46144

Contents?: true

Size: 611 Bytes

Versions: 1

Compression:

Stored size: 611 Bytes

Contents

# frozen_string_literal: true

module Decidim::ParticipatoryProcesses::UpdateParticipatoryProcessDecorator
  # Intercepts the `call` method and forces the Area of the user if it is a
  # department_admin user.
  def self.decorate
    Decidim::ParticipatoryProcesses::Admin::UpdateParticipatoryProcess.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::ParticipatoryProcesses::UpdateParticipatoryProcessDecorator.decorate

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-department_admin-0.7.2 app/decorators/decidim/participatory_processes/update_participatory_process_decorator.rb