Skip to content

Commit

Permalink
handling validation errors #1981
Browse files Browse the repository at this point in the history
  • Loading branch information
stuzart committed Sep 24, 2024
1 parent 7de81f7 commit da8e381
Show file tree
Hide file tree
Showing 3 changed files with 394 additions and 4 deletions.
18 changes: 14 additions & 4 deletions app/controllers/investigations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,30 @@ def new_object_based_on_existing_one
def submit_fairdata_station
path = params[:datastation_data].path
datastation_inv = Seek::FairDataStation::Reader.new.parse_graph(path).first
error = false
if datastation_inv.external_id != @investigation.external_identifier
flash[:error] = "This #{t('investigation')} does not match the identifier provided in the FAIR Data Station metadata"
error = true
else
begin
Investigation.transaction do
@investigation = Seek::FairDataStation::Writer.new.update_isa(@investigation, datastation_inv, current_person, @investigation.projects, @investigation.policy)
@investigation.save!
end
rescue ActiveRecord::RecordInvalid => e
flash[:error] = e.message
error = true
end
end
if error
respond_to do |format|
format.html { render action: :update_from_fairdata_station, status: :unprocessable_entity }
end
else
@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


end

def export_isatab_json
Expand Down
Loading

0 comments on commit da8e381

Please sign in to comment.