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

Prevent editing of meeting when closed

Oliver Günther08ab1b98f56d
diff --git a/modules/meeting/app/components/meetings/header_component.rb b/modules/meeting/app/components/meetings/header_component.rb
index ab40533134e..181d6910bc8 100644
--- a/modules/meeting/app/components/meetings/header_component.rb
+++ b/modules/meeting/app/components/meetings/header_component.rb
@@ -52,10 +52,6 @@ module Meetings
private
- def edit_enabled?
- User.current.allowed_to?(:edit_meetings, @meeting.project)
- end
-
def delete_enabled?
User.current.allowed_to?(:delete_meetings, @meeting.project)
end
@@ -89,7 +85,7 @@ module Meetings
def actions_partial
render(Primer::Alpha::ActionMenu.new) do |menu|
menu.with_show_button(icon: "kebab-horizontal", 'aria-label': t("label_meeting_actions"), test_selector: 'op-meetings-header-action-trigger')
- edit_action_item(menu) if edit_enabled?
+ edit_action_item(menu) if @meeting.editable?
download_ics_item(menu)
delete_action_item(menu) if delete_enabled?
end
diff --git a/modules/meeting/app/components/meetings/sidebar/details_component.rb b/modules/meeting/app/components/meetings/sidebar/details_component.rb
index 540ff73b5d8..04ac1143f91 100644
--- a/modules/meeting/app/components/meetings/sidebar/details_component.rb
+++ b/modules/meeting/app/components/meetings/sidebar/details_component.rb
@@ -53,16 +53,12 @@ module Meetings
private
- def edit_enabled?
- User.current.allowed_to?(:edit_meetings, @meeting.project)
- end
-
def heading_partial
flex_layout(align_items: :center, justify_content: :space_between) do |flex|
flex.with_column(flex: 1) do
render(Primer::Beta::Heading.new(tag: :h4)) { t("label_meeting_details") }
end
- if edit_enabled?
+ if @meeting.editable?
flex.with_column do
dialog_wrapper_partial
end
diff --git a/modules/meeting/app/components/meetings/sidebar/participants_component.rb b/modules/meeting/app/components/meetings/sidebar/participants_component.rb
index 10e6f279731..b12f94a9d62 100644
--- a/modules/meeting/app/components/meetings/sidebar/participants_component.rb
+++ b/modules/meeting/app/components/meetings/sidebar/participants_component.rb
@@ -47,7 +47,7 @@ module Meetings
flex.with_row(mt: 2) do
participant_list_partial(5)
end
- if edit_enabled?
+ if @meeting.editable?
flex.with_row(mt: 3) do
manage_button_partial
end
@@ -58,16 +58,12 @@ module Meetings
private
- def edit_enabled?
- User.current.allowed_to?(:edit_meetings, @meeting.project)
- end
-
def heading_partial
flex_layout(align_items: :center, justify_content: :space_between) do |flex|
flex.with_column(flex: 1) do
title_partial
end
- if edit_enabled?
+ if @meeting.editable?
flex.with_column do
dialog_wrapper_partial
end
diff --git a/modules/meeting/app/models/meeting.rb b/modules/meeting/app/models/meeting.rb
index 4909ad3e07f..522e689a917 100644
--- a/modules/meeting/app/models/meeting.rb
+++ b/modules/meeting/app/models/meeting.rb
@@ -142,8 +142,12 @@ class Meeting < ApplicationRecord
end
# Returns true if user or current user is allowed to view the meeting
- def visible?(user = nil)
- (user || User.current).allowed_to?(:view_meetings, project)
+ def visible?(user = User.current)
+ user.allowed_to?(:view_meetings, project)
+ end
+
+ def editable?(user = User.current)
+ open? && user.allowed_to?(:edit_meetings, project)
end
def invited_or_attended_participants