|
|
@ -61,18 +61,17 @@ class MeetingContentsController < ApplicationController |
|
|
|
|
|
|
|
|
|
|
|
def update |
|
|
|
def update |
|
|
|
(render_403; return) unless @content.editable? # TODO: not tested! |
|
|
|
(render_403; return) unless @content.editable? # TODO: not tested! |
|
|
|
@content.attributes = content_params |
|
|
|
@content.attributes = content_params.merge(author: User.current) |
|
|
|
@content.author = User.current |
|
|
|
|
|
|
|
@content.attach_files(permitted_params.attachments.to_h) |
|
|
|
@content.attach_files(permitted_params.attachments.to_h) |
|
|
|
if @content.save |
|
|
|
|
|
|
|
flash[:notice] = I18n.t(:notice_successful_update) |
|
|
|
if !@content.lock_version_changed? |
|
|
|
redirect_back_or_default controller: '/meetings', action: 'show', id: @meeting |
|
|
|
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 |
|
|
|
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 |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def history |
|
|
|
def history |
|
|
@ -137,6 +136,12 @@ class MeetingContentsController < ApplicationController |
|
|
|
render_404 |
|
|
|
render_404 |
|
|
|
end |
|
|
|
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 |
|
|
|
def content_params |
|
|
|
params.require(@content_type).permit(:text, :lock_version, :comment) |
|
|
|
params.require(@content_type).permit(:text, :lock_version, :comment) |
|
|
|
end |
|
|
|
end |
|
|
|