Skip to content

Commit

Permalink
refactor: Remove override and add extend
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentinchampenois committed Nov 13, 2024
1 parent 1d63139 commit ce01f90
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 83 deletions.
77 changes: 0 additions & 77 deletions app/commands/decidim/admin/create_attachment.rb

This file was deleted.

19 changes: 13 additions & 6 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,27 @@ class Application < Rails::Application
end

config.after_initialize do
# Controllers
require "extends/controllers/decidim/devise/sessions_controller_extends"
require "extends/controllers/decidim/editor_images_controller_extends"
require "extends/services/decidim/iframe_disabler_extends"
require "extends/helpers/decidim/icon_helper_extends"
require "extends/commands/decidim/initiatives/admin/update_initiative_answer_extends"
require "extends/controllers/decidim/proposals/proposals_controller_extends"
require "extends/controllers/decidim/newsletters_controller_extends"
require "extends/controllers/decidim/initiatives/committee_requests_controller_extends"
# Models
require "extends/models/decidim/budgets/project_extends"
require "extends/models/decidim/authorization_extends"
# Services
require "extends/services/decidim/iframe_disabler_extends"
# Helpers
require "extends/helpers/decidim/icon_helper_extends"
# Forms
require "extends/forms/decidim/initiatives/initiative_form_extends"
require "extends/forms/decidim/initiatives/admin/initiative_form_extends"
# Commands
require "extends/commands/decidim/initiatives/admin/update_initiative_answer_extends"
require "extends/commands/decidim/budgets/admin/import_proposals_to_budgets_extends"
require "extends/controllers/decidim/newsletters_controller_extends"
require "extends/commands/decidim/admin/destroy_participatory_space_private_user_extends"
require "extends/controllers/decidim/proposals/proposals_controller_extends"
require "extends/forms/decidim/initiatives/initiative_form_extends"
require "extends/commands/decidim/admin/create_attachment_extends"

Decidim::GraphiQL::Rails.config.tap do |config|
config.initial_query = "{\n deployment {\n version\n branch\n remote\n upToDate\n currentCommit\n latestCommit\n locallyModified\n }\n}".html_safe
Expand Down
25 changes: 25 additions & 0 deletions lib/extends/commands/decidim/admin/create_attachment_extends.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require "active_support/concern"

module CreateAttachmentExtends
extend ActiveSupport::Concern

included do
def notify_followers
return unless @attachment.attached_to.is_a?(Decidim::Followable)
return unless form.send_notification_to_followers

Decidim::EventsManager.publish(
event: "decidim.events.attachments.attachment_created",
event_class: Decidim::AttachmentCreatedEvent,
resource: @attachment,
followers: @attachment.attached_to.followers,
extra: { force_email: true },
force_send: true
)
end
end
end

Decidim::Admin::CreateAttachment.include(CreateAttachmentExtends)

0 comments on commit ce01f90

Please sign in to comment.