diff --git a/app/controllers/bio_eddie_assets_controller.rb b/app/controllers/bio_eddie_assets_controller.rb index b996810a9..13494f03b 100644 --- a/app/controllers/bio_eddie_assets_controller.rb +++ b/app/controllers/bio_eddie_assets_controller.rb @@ -23,6 +23,7 @@ class BioEddieAssetsController < ApplicationController }) } elsif asset && bio_eddie_params[:object_type] == 'Result' + log_registration_activity(asset) if bio_eddie_params[:schedule_for_registration] == 'true' render json: { status: 'created' }, status: :ok else render json: asset.errors, status: :unprocessable_entity @@ -35,6 +36,7 @@ class BioEddieAssetsController < ApplicationController create_edit_bio_eddie_activity(asset, current_user, :finish_editing) if asset + log_registration_activity(asset) if bio_eddie_params[:schedule_for_registration] == 'true' render json: { url: rails_representation_url(asset.medium_preview), id: asset.id, file_name: asset.blob.metadata['name'] } @@ -101,4 +103,19 @@ class BioEddieAssetsController < ApplicationController def bio_eddie_params params.permit(:id, :description, :object_id, :object_type, :name, :image, :schedule_for_registration) end + + def log_registration_activity(asset) + Activities::CreateActivityService + .call( + activity_type: :register_molecule, + owner: current_user, + team: asset.team, + project: asset.my_module.experiment.project, + subject: asset, + message_items: { + description: asset.blob.metadata['description'], + name: asset.blob.metadata['name'] + } + ) + end end diff --git a/app/services/bio_eddie_service.rb b/app/services/bio_eddie_service.rb index b5c21d0f2..6952b52ce 100644 --- a/app/services/bio_eddie_service.rb +++ b/app/services/bio_eddie_service.rb @@ -58,7 +58,7 @@ class BioEddieService StringIO.new(params[:image]) end - def attach_file(attachment, file, params, current_user) + def attach_file(attachment, file, params) attachment.attach( io: file, filename: "#{prepare_name(params[:name])}.svg", @@ -70,27 +70,10 @@ class BioEddieService asset_type: 'bio_eddie' } ) - - log_activity(attachment.record, current_user) if params[:schedule_for_registration] == 'true' end def prepare_name(sketch_name) sketch_name.presence || I18n.t('bio_eddie.new_molecule') end - - def log_activity(asset, current_user) - Activities::CreateActivityService - .call( - activity_type: :register_molecule, - owner: current_user, - team: asset.team, - project: asset.my_module.experiment.project, - subject: asset, - message_items: { - description: asset.blob.metadata['description'], - name: asset.blob.metadata['name'] - } - ) - end end end