Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#49334] Meeting module: Update the migration to add manage_agendas where edit_meeting role is present (#14015)

Dombi Attila130ecc100b42
diff --git a/db/migrate/20231025144701_migrate_agenda_item_permissions.rb b/db/migrate/20231025144701_migrate_agenda_item_permissions.rb
index dc1e3f00590..f22088ec3e7 100644
--- a/db/migrate/20231025144701_migrate_agenda_item_permissions.rb
+++ b/db/migrate/20231025144701_migrate_agenda_item_permissions.rb
@@ -1,5 +1,37 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
class MigrateAgendaItemPermissions < ActiveRecord::Migration[7.0]
- def change
+ def up
RolePermission.where(permission: 'create_meeting_agendas').update_all(permission: 'manage_agendas')
end
+
+ def down
+ RolePermission.where(permission: 'manage_agendas').update_all(permission: 'create_meeting_agendas')
+ end
end
diff --git a/db/migrate/20231027102747_rollback_create_meeting_agendas_and_split_edit_meeting_role.rb b/db/migrate/20231027102747_rollback_create_meeting_agendas_and_split_edit_meeting_role.rb
new file mode 100644
index 00000000000..b8e9bada5a5
--- /dev/null
+++ b/db/migrate/20231027102747_rollback_create_meeting_agendas_and_split_edit_meeting_role.rb
@@ -0,0 +1,46 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require Rails.root.join("db/migrate/migration_utils/permission_adder")
+
+class RollbackCreateMeetingAgendasAndSplitEditMeetingRole < ActiveRecord::Migration[7.0]
+ def up
+ # Rollback the create_meeting_agendas permission
+ RolePermission.where(permission: 'manage_agendas').update_all(permission: 'create_meeting_agendas')
+
+ # Introduce manage_agendas permission, that is being split from the edit_meeting permission
+ ::Migration::MigrationUtils::PermissionAdder
+ .add(:edit_meetings,
+ :manage_agendas)
+ end
+
+ def down
+ RolePermission.where(permission: 'manage_agendas').destroy_all
+ RolePermission.where(permission: 'create_meeting_agendas').update_all(permission: 'manage_agendas')
+ end
+end
diff --git a/modules/meeting/app/seeders/common.yml b/modules/meeting/app/seeders/common.yml
index 698796c58a8..4735ff01df6 100644
--- a/modules/meeting/app/seeders/common.yml
+++ b/modules/meeting/app/seeders/common.yml
@@ -34,6 +34,7 @@ modules_permissions:
- :edit_meetings
- :delete_meetings
- :view_meetings
+ - :create_meeting_agendas
- :manage_agendas
- :close_meeting_agendas
- :send_meeting_agendas_notification
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index e0fa746dede..45fc6856cf3 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -124,7 +124,10 @@ en:
permission_edit_meetings: "Edit meetings"
permission_delete_meetings: "Delete meetings"
permission_view_meetings: "View meetings"
+ permission_create_meeting_agendas: "Create meeting agendas"
+ permission_create_meeting_agendas_explanation: "Allows editing the Classic Meeting's agenda content."
permission_manage_agendas: "Manage agendas"
+ permission_manage_agendas_explanation: "Allows managing the Dynamic Meeting's agenda items."
permission_close_meeting_agendas: "Close agendas"
permission_send_meeting_agendas_notification: "Send review notification for agendas"
permission_create_meeting_minutes: "Manage minutes"
diff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rb
index 26b4c0c9a2e..511bb8fd71a 100644
--- a/modules/meeting/lib/open_project/meeting/engine.rb
+++ b/modules/meeting/lib/open_project/meeting/engine.rb
@@ -65,9 +65,14 @@ module OpenProject::Meeting
{ meetings: [:icalendar] },
permissible_on: :project,
require: :member
+ permission :create_meeting_agendas,
+ {
+ meeting_agendas: %i[update preview]
+ },
+ permissible_on: :project,
+ require: :member
permission :manage_agendas,
{
- meeting_agendas: %i[update preview],
meeting_agenda_items: %i[new cancel_new create edit cancel_edit update destroy drop move]
},
permissible_on: :project, # TODO: Change this to :meeting when MeetingRoles are available
diff --git a/modules/meeting/spec/features/meetings_attachments_spec.rb b/modules/meeting/spec/features/meetings_attachments_spec.rb
index 07b9348913c..eb9e9b0c536 100644
--- a/modules/meeting/spec/features/meetings_attachments_spec.rb
+++ b/modules/meeting/spec/features/meetings_attachments_spec.rb
@@ -3,7 +3,7 @@ require 'features/page_objects/notification'
RSpec.describe 'Add an attachment to a meeting (agenda)', js: true, with_cuprite: false do
let(:role) do
- create(:project_role, permissions: %i[view_meetings edit_meetings manage_agendas])
+ create(:project_role, permissions: %i[view_meetings edit_meetings create_meeting_agendas])
end
let(:dev) do
diff --git a/modules/meeting/spec/features/meetings_show_spec.rb b/modules/meeting/spec/features/meetings_show_spec.rb
index 33d363bef9b..aaef1391d78 100644
--- a/modules/meeting/spec/features/meetings_show_spec.rb
+++ b/modules/meeting/spec/features/meetings_show_spec.rb
@@ -105,7 +105,7 @@ RSpec.describe 'Meetings', js: true do
end
context 'and edit permissions' do
- let(:permissions) { %i[view_meetings manage_agendas] }
+ let(:permissions) { %i[view_meetings create_meeting_agendas] }
let(:field) do
TextEditorField.new(page,
'',