Skip to content

Commit

Permalink
Fix some RuboCop warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jvendetti committed May 20, 2023
1 parent d407ada commit b024e13
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
class SubmissionsController < ApplicationController
# frozen_string_literal: true

class SubmissionsController < ApplicationController
layout :determine_layout
before_action :authorize_and_redirect, :only=>[:edit,:update,:create,:new]
before_action :authorize_and_redirect, only: [:edit, :update, :create, :new]

def new
@ontology = LinkedData::Client::Models::Ontology.get(CGI.unescape(params[:ontology_id])) rescue nil
@ontology = LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology_id]).first unless @ontology
begin
# REVIEW: do we really need this double attempt to locate an ontology? I think find_by_acronym (below) should
# be sufficient. It's not evident that we call the new method with a full URI anymore.
@ontology = LinkedData::Client::Models::Ontology.get(CGI.unescape(params[:ontology_id]))
rescue MultiJson::ParseError
nil
end

@ontology ||= LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology_id]).first
@submission = @ontology.explore.latest_submission
@submission ||= LinkedData::Client::Models::OntologySubmission.new
end
Expand All @@ -16,21 +24,21 @@ def create

@submission = LinkedData::Client::Models::OntologySubmission.new(values: submission_params)
@ontology = LinkedData::Client::Models::Ontology.get(params[:submission][:ontology])

# Update summaryOnly on ontology object
@ontology.summaryOnly = @submission.isRemote.eql?("3")
@ontology.summaryOnly = @submission.isRemote.eql?('3')
@ontology.update

@submission_saved = @submission.save(cache_refresh_all: false)
if response_error?(@submission_saved)
@errors = response_errors(@submission_saved) # see application_controller::response_errors
if @errors && @errors[:uploadFilePath]
@errors = ["Please specify the location of your ontology"]
@errors = ['Please specify the location of your ontology']
elsif @errors && @errors[:contact]
@errors = ["Please enter a contact"]
@errors = ['Please enter a contact']
end

render "new"
render 'new'
else
redirect_to "/ontologies/success/#{@ontology.acronym}"
end
Expand All @@ -39,7 +47,7 @@ def create
def edit
@ontology = LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology_id]).first
submissions = @ontology.explore.submissions
@submission = submissions.select {|o| o.submissionId == params["id"].to_i}.first
@submission = submissions.select { |o| o.submissionId == params['id'].to_i }.first
end

def update
Expand All @@ -50,11 +58,11 @@ def update

@ontology = LinkedData::Client::Models::Ontology.get(params[:submission][:ontology])
submissions = @ontology.explore.submissions
@submission = submissions.select {|o| o.submissionId == params["id"].to_i}.first
@submission = submissions.select { |o| o.submissionId == params['id'].to_i }.first

@submission.update_from_params(submission_params)
# Update summaryOnly on ontology object
@ontology.summaryOnly = @submission.isRemote.eql?("3")
@ontology.summaryOnly = @submission.isRemote.eql?('3')
@ontology.update
error_response = @submission.update(cache_refresh_all: false)
if response_error?(error_response)
Expand All @@ -71,9 +79,8 @@ def submission_params
p = params.require(:submission).permit(:ontology, :description, :hasOntologyLanguage, :prefLabelProperty,
:synonymProperty, :definitionProperty, :authorProperty, :obsoleteProperty,
:obsoleteParent, :version, :status, :released, :isRemote, :pullLocation,
:filePath, { contact:[:name, :email] }, :homepage, :documentation,
:filePath, { contact: [:name, :email] }, :homepage, :documentation,
:publication)
p.to_h
end

end

0 comments on commit b024e13

Please sign in to comment.