Merge pull request #1755 from mlorb/ml-sci-3349

Change author of copied inventory item [SCI-3349]
This commit is contained in:
Miha Mencin 2019-05-13 15:54:38 +02:00 committed by GitHub
commit 367ecba488
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,7 +28,7 @@ module RepositoryActions
def duplicate_row(id)
row = RepositoryRow.find_by_id(id)
new_row = RepositoryRow.new(
row.attributes.merge(new_row_attributes(row.name))
row.attributes.merge(new_row_attributes(row.name, @user.id))
)
if new_row.save
@ -46,10 +46,11 @@ module RepositoryActions
end
end
def new_row_attributes(name)
def new_row_attributes(name, user_id)
timestamp = DateTime.now
{ id: nil,
name: "#{name} (1)",
created_by_id: user_id,
created_at: timestamp,
updated_at: timestamp }
end