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

work around stale object error not being thrown

ulferts12b507171c20
diff --git a/modules/meeting/app/controllers/meeting_contents_controller.rb b/modules/meeting/app/controllers/meeting_contents_controller.rb
index 207d64432b7..1872af185e0 100644
--- a/modules/meeting/app/controllers/meeting_contents_controller.rb
+++ b/modules/meeting/app/controllers/meeting_contents_controller.rb
@@ -61,18 +61,17 @@ class MeetingContentsController < ApplicationController
def update
(render_403; return) unless @content.editable? # TODO: not tested!
- @content.attributes = content_params
- @content.author = User.current
+ @content.attributes = content_params.merge(author: User.current)
@content.attach_files(permitted_params.attachments.to_h)
- if @content.save
- flash[:notice] = I18n.t(:notice_successful_update)
- redirect_back_or_default controller: '/meetings', action: 'show', id: @meeting
+
+ if [email protected]_version_changed?
+ if @content.save
+ flash[:notice] = I18n.t(:notice_successful_update)
+ redirect_back_or_default controller: '/meetings', action: 'show', id: @meeting
+ end
+ else
+ render_conflict
end
- rescue ActiveRecord::StaleObjectError
- # Optimistic locking exception
- flash.now[:error] = I18n.t(:notice_locking_conflict)
- params[:tab] ||= 'minutes' if @meeting.agenda.present? && @meeting.agenda.locked?
- render 'meetings/show'
end
def history
@@ -137,6 +136,12 @@ class MeetingContentsController < ApplicationController
render_404
end
+ def render_conflict
+ flash.now[:error] = I18n.t(:notice_locking_conflict)
+ params[:tab] ||= 'minutes' if @meeting.agenda.present? && @meeting.agenda.locked?
+ render 'meetings/show'
+ end
+
def content_params
params.require(@content_type).permit(:text, :lock_version, :comment)
end