Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix participatory space resourceable decorator for v0.28 #69

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Following Semantic Versioning 2.

## next version:

## Version 0.8.1 (MINOR)
- Fix: Use prepend instead of overriding to apply Lib::Decidim::ParticipatorySpaceResourceableDecorator.

## Version 0.8.0 (MINOR)
- Upgrade Decidim to v0.28
- Upgrade Ruby to 3.1.1
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ GIT
PATH
remote: .
specs:
decidim-department_admin (0.8.0)
decidim-department_admin (0.8.1)
decidim-admin (~> 0.28.0)
decidim-core (~> 0.28.0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,35 @@

module Lib::Decidim::ParticipatorySpaceResourceableDecorator
#
# This decorator overrided method to avoid .to_sym error when logged in user is Department Admin
# Override affects only line `case role_name&.to_sym`
# Furthermore added new ParticipatorySpaceRole case for DeparmentAdmin
# - Add new ParticipatorySpaceRole case for DeparmentAdmin.
# - Add .to_sym to the `case` test, to avoid error when logged in user is Department Admin
# This override affects only line `case role_name&.to_sym`
#
def self.decorate
Decidim::ParticipatorySpaceResourceable.class_eval do
def user_role_config_for(user, role_name)
case role_name&.to_sym
when :organization_admin
Decidim::ParticipatorySpaceRoleConfig::Admin.new(user)
when :admin # ParticipatorySpace admin
Decidim::ParticipatorySpaceRoleConfig::ParticipatorySpaceAdmin.new(user)
when :department_admin
Decidim::ParticipatorySpaceRoleConfig::DepartmentAdmin.new(user)
when :valuator
Decidim::ParticipatorySpaceRoleConfig::Valuator.new(user)
when :moderator
Decidim::ParticipatorySpaceRoleConfig::Moderator.new(user)
when :collaborator
Decidim::ParticipatorySpaceRoleConfig::Collaborator.new(user)
else
Decidim::ParticipatorySpaceRoleConfig::NullObject.new(user)
end
end
def user_role_config_for(user, role_name)
case role_name&.to_sym
when :organization_admin
Decidim::ParticipatorySpaceRoleConfig::Admin.new(user)
when :admin # ParticipatorySpace admin
Decidim::ParticipatorySpaceRoleConfig::ParticipatorySpaceAdmin.new(user)
when :department_admin
Decidim::ParticipatorySpaceRoleConfig::DepartmentAdmin.new(user)
when :valuator
Decidim::ParticipatorySpaceRoleConfig::Valuator.new(user)
when :moderator
Decidim::ParticipatorySpaceRoleConfig::Moderator.new(user)
when :collaborator
Decidim::ParticipatorySpaceRoleConfig::Collaborator.new(user)
else
Decidim::ParticipatorySpaceRoleConfig::NullObject.new(user)
end
end
end

Lib::Decidim::ParticipatorySpaceResourceableDecorator.decorate
require "decidim/assembly"
Decidim::Assembly.prepend(Lib::Decidim::ParticipatorySpaceResourceableDecorator)
require "decidim/participatory_process"
Decidim::ParticipatoryProcess.prepend(Lib::Decidim::ParticipatorySpaceResourceableDecorator)
if Decidim::DepartmentAdmin.conferences_defined?
require "decidim/conference"
Decidim::Conference.prepend(Lib::Decidim::ParticipatorySpaceResourceableDecorator)
end
1 change: 1 addition & 0 deletions lib/decidim/department_admin/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Engine < ::Rails::Engine
# force the concern to be included so that registry is initialized
# we choose some random class already including it
require "decidim/participatory_processes/admin/categories_controller"
require "decidim/participatory_processes/admin/components_controller"
artifact = ::Decidim::ParticipatoryProcesses::Admin::Concerns::ParticipatoryProcessAdmin
ParticipatoryProcessesAdminConcernPermissions = Class.new(::Decidim::DepartmentAdmin::Permissions)
register_new_permissions_for(artifact, ParticipatoryProcessesAdminConcernPermissions)
Expand Down
2 changes: 1 addition & 1 deletion lib/decidim/department_admin/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Decidim
module DepartmentAdmin
# see CHANGELOG.md
def self.version
"0.8.0"
"0.8.1"
end
end
end
Loading