mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-23 07:13:57 +08:00
Save last_modified_by on protocol update [SCI-8021]
This commit is contained in:
parent
e317ca0134
commit
4eab2c25f3
3 changed files with 13 additions and 5 deletions
|
@ -231,7 +231,7 @@ class ProtocolsController < ApplicationController
|
|||
escape_input(keyword)
|
||||
end
|
||||
end
|
||||
if @protocol.update_keywords(params[:keywords])
|
||||
if @protocol.update_keywords(params[:keywords], current_user)
|
||||
format.json do
|
||||
log_activity(:edit_keywords_in_protocol_repository, nil, protocol: @protocol.id)
|
||||
render json: @protocol, serializer: ProtocolSerializer, user: current_user
|
||||
|
@ -243,7 +243,7 @@ class ProtocolsController < ApplicationController
|
|||
end
|
||||
|
||||
def update_authors
|
||||
if @protocol.update(authors: params.require(:protocol)[:authors])
|
||||
if @protocol.update(authors: params.require(:protocol)[:authors], last_modified_by: current_user)
|
||||
log_activity(:edit_authors_in_protocol_repository, nil, protocol: @protocol.id)
|
||||
render json: @protocol, serializer: ProtocolSerializer, user: current_user
|
||||
else
|
||||
|
@ -252,7 +252,7 @@ class ProtocolsController < ApplicationController
|
|||
end
|
||||
|
||||
def update_name
|
||||
if @protocol.update(name: params.require(:protocol)[:name])
|
||||
if @protocol.update(name: params.require(:protocol)[:name], last_modified_by: current_user)
|
||||
log_activity(:edit_protocol_name_in_repository, nil, protocol: @protocol.id)
|
||||
render json: {}, status: :ok
|
||||
else
|
||||
|
@ -264,7 +264,7 @@ class ProtocolsController < ApplicationController
|
|||
old_description = @protocol.description
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
if @protocol.update(description: params.require(:protocol)[:description])
|
||||
if @protocol.update(description: params.require(:protocol)[:description], last_modified_by: current_user)
|
||||
log_activity(:edit_description_in_protocol_repository, nil, protocol: @protocol.id)
|
||||
TinyMceAsset.update_images(@protocol, params[:tiny_mce_images], current_user)
|
||||
protocol_annotation_notification(old_description)
|
||||
|
@ -285,6 +285,7 @@ class ProtocolsController < ApplicationController
|
|||
@protocol.record_timestamps = false
|
||||
@protocol.created_at = ts
|
||||
@protocol.updated_at = ts
|
||||
@protocol.last_modified_by = current_user
|
||||
|
||||
if @protocol.save
|
||||
log_activity(:create_protocol_in_repository, nil, protocol: @protocol.id)
|
||||
|
|
|
@ -474,7 +474,7 @@ class Protocol < ApplicationRecord
|
|||
result
|
||||
end
|
||||
|
||||
def update_keywords(keywords)
|
||||
def update_keywords(keywords, user)
|
||||
result = true
|
||||
begin
|
||||
Protocol.transaction do
|
||||
|
@ -487,6 +487,7 @@ class Protocol < ApplicationRecord
|
|||
kw = ProtocolKeyword.find_or_create_by(name: kw_name, team: team)
|
||||
protocol_keywords << kw
|
||||
end
|
||||
update(last_modified_by: user)
|
||||
end
|
||||
end
|
||||
rescue StandardError
|
||||
|
@ -537,6 +538,7 @@ class Protocol < ApplicationRecord
|
|||
self.updated_at = source.published_on
|
||||
self.parent_updated_at = source.published_on
|
||||
self.added_by = current_user
|
||||
self.last_modified_by = current_user
|
||||
self.parent = source
|
||||
self.linked_at = Time.zone.now
|
||||
save!
|
||||
|
@ -559,6 +561,7 @@ class Protocol < ApplicationRecord
|
|||
self.parent = source
|
||||
self.parent_updated_at = source.published_on
|
||||
self.added_by = current_user
|
||||
self.last_modified_by = current_user
|
||||
self.linked_at = Time.zone.now
|
||||
self.protocol_type = Protocol.protocol_types[:linked]
|
||||
save!
|
||||
|
@ -568,6 +571,7 @@ class Protocol < ApplicationRecord
|
|||
clone.team = team
|
||||
clone.protocol_type = :in_repository_draft
|
||||
clone.added_by = current_user
|
||||
clone.last_modified_by = current_user
|
||||
# Don't proceed further if clone is invalid
|
||||
return clone if clone.invalid?
|
||||
|
||||
|
@ -590,6 +594,7 @@ class Protocol < ApplicationRecord
|
|||
draft.published_on = nil
|
||||
draft.version_comment = nil
|
||||
draft.previous_version = self
|
||||
draft.last_modified_by = current_user
|
||||
|
||||
return draft if draft.invalid?
|
||||
|
||||
|
@ -622,6 +627,7 @@ class Protocol < ApplicationRecord
|
|||
authors: authors,
|
||||
description: description,
|
||||
added_by: current_user,
|
||||
last_modified_by: current_user,
|
||||
team: team,
|
||||
protocol_type: :in_repository_draft,
|
||||
skip_user_assignments: true
|
||||
|
|
|
@ -187,6 +187,7 @@ class Step < ApplicationRecord
|
|||
return if saved_changes.keys.sort == %w(completed completed_on updated_at)
|
||||
|
||||
# rubocop:disable Rails/SkipsModelValidations
|
||||
protocol.update(last_modified_by: last_modified_by) if last_modified_by
|
||||
protocol.touch
|
||||
# rubocop:enable Rails/SkipsModelValidations
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue