Skip to content

Commit

Permalink
Refactor decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
laurajaime committed Jul 17, 2024
1 parent 518d74e commit b97cd07
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ GIT

GIT
remote: https://github.com/gencat/decidim-module-department_admin.git
revision: 902fa7609da0106c4e7721800dfe0e7bf60af5aa
revision: a202f8a49b19157eb1b2a455b82f33ce8d955c23
branch: upgrade/0.27
specs:
decidim-department_admin (0.7.0)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

# To avoid admin users to delete special process groups

module Decidim::ParticipatoryProcesses::Admin::ParticipatoryProcessGroupsControllerDecorator
#
# Decorate to avoid admin users to delete special process groups
#
def self.decorate
Decidim::ParticipatoryProcesses::Admin::ParticipatoryProcessGroupsController.class_eval do

alias_method :original_destroy, :destroy

def destroy
byebug
forbidden_groups_ids = [
Rails.application.config.process.to_s,
Rails.application.config.regulation.to_s
]
if forbidden_groups_ids.include?(params[:id])
flash[:alert] = "Protected ParticipatoryProcessGroup, can't be deleted."
redirect_to participatory_process_groups_path
else
original_destroy
end
end
end
end
end

::Decidim::ParticipatoryProcesses::Admin::ParticipatoryProcessGroupsControllerDecorator.decorate

This file was deleted.

1 change: 0 additions & 1 deletion decidim-regulations/lib/decidim/regulations/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class Engine < ::Rails::Engine
Dir.glob(Decidim::Regulations::Engine.root + "app/decorators/**/*_decorator*.rb").each do |c|
require_dependency(c)
end
::Decidim::ParticipatoryProcesses::Admin::ParticipatoryProcessGroupsController.prepend(Decidim::Regulations::Admin::AvoidDeletionOfRegulationsGroup)
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions docs/HOW_TO_UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,13 @@ These are custom modules and this is what you have to keep in mind when updating
##### Modified files:
* `app/controllers/decidim/regulations/`
* `app/decorators/lib/decidim/filter_form_builder_decorator.rb`
* `app/decorators/decidim/participatory_processes/admin/participatory_process_groups_controller_decorator.rb`
* `app/decorators/decidim/participatory_processes/helpers/participatory_process_helper_decorator.rb`
* Override participatory_process_cta_path in order to use it via `decidim_participatory_processes`
* `app/views/decidim/regulations/regulation/_order_by_regulations.html (order_by_processes)`
* Change the rendered cell
* `app/views/decidim/regulations/regulation/_promoted_process.html`
* Access `participatory_process_path` url helper via `decidim_participatory_processes`
*`app/decorators/decidim/participatory_processes/helpers/participatory_process_helper_decorator.rb`
* Override participatory_process_cta_path in order to use it via `decidim_participatory_processes`
* `app/views/decidim/regulations/regulation/index.html`
* Add section to show floating help (L:12-14)
* Change traslations from *_processes to *_regulation
Expand Down

0 comments on commit b97cd07

Please sign in to comment.