Skip to content

Commit

Permalink
crude controller action and views for investigation to support updati…
Browse files Browse the repository at this point in the history
…ng from FDS #1981

for testing out
  • Loading branch information
stuzart committed Sep 20, 2024
1 parent 71f2c0c commit 4d00fca
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 4 deletions.
14 changes: 13 additions & 1 deletion app/controllers/investigations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class InvestigationsController < ApplicationController

before_action :investigations_enabled?
before_action :find_assets, :only=>[:index]
before_action :find_and_authorize_requested_item,:only=>[:edit, :manage, :update, :manage_update, :destroy, :show,:new_object_based_on_existing_one]
before_action :find_and_authorize_requested_item,:only=>[:edit, :manage, :update, :manage_update, :destroy, :show, :update_from_fairdata_station, :submit_fairdata_station, :new_object_based_on_existing_one]

#project_membership_required_appended is an alias to project_membership_required, but is necesary to include the actions
#defined in the application controller
Expand Down Expand Up @@ -34,6 +34,18 @@ def new_object_based_on_existing_one

end

def submit_fairdata_station
path = params[:datastation_data].path
datastation_inv = Seek::FairDataStation::Reader.new.parse_graph(path).first
raise 'identifiers dont match' if datastation_inv.external_id != @investigation.external_identifier
@investigation = Seek::FairDataStation::Writer.new.update_isa(@investigation, datastation_inv, current_person, @investigation.projects, @investigation.policy)
@investigation.save!

respond_to do |format|
format.html { redirect_to(@investigation) }
end
end

def export_isatab_json
the_hash = IsaTabConverter.convert_investigation(Investigation.find(params[:id]))
send_data JSON.pretty_generate(the_hash) , filename: 'isatab.json'
Expand Down
6 changes: 6 additions & 0 deletions app/views/investigations/_buttons.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,11 @@
<%= order_icon(item, current_user, order_studies_investigation_path(item), item.studies, 'study') -%>
<% if Seek::Config.fair_data_station_enabled && item.can_manage? %>
<li>
<%= image_tag_for_key('import', update_from_fairdata_station_investigation_path(item), "Update from FAIRData Station", nil, "Update from FAIRData Station") -%>
</li>
<% end %>
<%= delete_icon item, current_user -%>
<% end -%>
14 changes: 14 additions & 0 deletions app/views/investigations/update_from_fairdata_station.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<%= render :partial => "general/page_title",:locals=>{:title=>"Update from FAIRData Station for #{ t('investigation') } #{link_to(@investigation.title, @investigation)}".html_safe} %>
<%= form_tag submit_fairdata_station_investigation_path(@investigation), multipart: true do %>
<%= panel('FAIR Data Station turtle (ttl) metadata file') do %>
<%= file_field_tag "datastation_data", accept: '.ttl' -%>
<% end %>

<div>
<%= submit_tag("Submit", class: 'btn btn-primary') %>
</div>
<% end %>
8 changes: 5 additions & 3 deletions app/views/projects/_buttons.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,16 @@
<%= order_icon(item,current_user, order_investigations_project_path(item), item.investigations, 'investigation') %>
<% end %>
<% if admin_logged_in? || item.can_manage? -%>
<%= delete_icon(item,current_user,"Any members will also be removed from the #{t('project')}, are you sure?") %>
<% end -%>
<% if Seek::Config.fair_data_station_enabled %>
<li>
<%= image_tag_for_key('import', import_from_fairdata_station_project_path(item), "Import from FAIRData Station", nil, "Import from FAIRData Station") -%>
</li>
<% end %>
<% if admin_logged_in? || item.can_manage? -%>
<%= delete_icon(item,current_user,"Any members will also be removed from the #{t('project')}, are you sure?") %>
<% end -%>
<% end -%>
<% end -%>
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@
get :manage
get :order_studies
patch :manage_update
get :update_from_fairdata_station
post :submit_fairdata_station
end
resources :people, :programmes, :projects, :assays, :studies, :models, :sops, :workflows, :data_files, :publications, :documents, :observation_units, :samples, only: [:index]
end
Expand Down
1 change: 1 addition & 0 deletions lib/seek/permissions/translator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Translator
manage manage_update notification read_interaction write_interaction report_problem storage_report
select_sample_type extraction_status persistence_status extract_samples confirm_extraction cancel_extraction
upload_fulltext upload_pdf soft_delete_fulltext has_matching_sample_type unzip unzip_status confirm_unzip unzip_persistence_status cancel_unzip
update_from_fairdata_station submit_fairdata_station
]).freeze
}.freeze

Expand Down

0 comments on commit 4d00fca

Please sign in to comment.