Skip to content

Commit

Permalink
fixed routing issue when using locales. fixed issue requiring cdm_dir…
Browse files Browse the repository at this point in the history
…s to be set.
  • Loading branch information
sephirothkod committed Nov 17, 2017
1 parent 216ee5b commit 8760731
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
6 changes: 4 additions & 2 deletions app/controllers/cdm_migrator/cdm_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def initialize
super
@cdm_url = CdmMigrator::Engine.config["cdm_url"]
@cdm_port = CdmMigrator::Engine.config["cdm_port"]
@cdm_dirs = CdmMigrator::Engine.config["cdm_dirs"]
@cdm_dirs = CdmMigrator::Engine.config["cdm_dirs"] || false
end

before_action :set_exclusive_fields, only: [:generate, :mappings]
Expand Down Expand Up @@ -83,7 +83,9 @@ def generate
def mappings
json = JSON.parse(Net::HTTP.get_response(URI.parse("#{@cdm_url}:#{@cdm_port}/dmwebservices/index.php?q=dmGetCollectionFieldInfo/"+params['collection']+'/json')).body)
@cdm_terms = json.collect { |c| [c['name'],c['nick']] }
get_dirs
if @cdm_dirs
get_dirs
end
end

def collection
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/cdm_migrator/csv_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def create
CsvUploadJob.perform_later(params[:csv_import][:csv_file].path, params[:csv_import][:mvs], @current_user)
#perform(params[:csv_import][:csv_file].path, params[:csv_import][:mvs], @current_user)
flash[:notice] = "csv successfully uploaded"
redirect_to "/csv/upload"
redirect_to csv_upload_path
end

def perform(csv, mvs, current_user)
Expand Down
4 changes: 2 additions & 2 deletions app/views/cdm_migrator/cdm/mappings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ table td{
border:1px solid black;
}
</style>
<%= form_tag cdm_generate_path+".csv" do %>
<%= form_tag cdm_generate_path.gsub("generate",".csv") do %>
<%= hidden_field_tag "collection", params[:collection] %>
<%= hidden_field_tag "file_system", params[:file_system] %>
<table>
Expand All @@ -27,7 +27,7 @@ border:1px solid black;
</tr>
<% end %>
</table>
<%= select_tag "mappings_url", options_for_select(@dirs) %>
<%= select_tag "mappings_url", options_for_select(@dirs) if @cdm_dirs %>
<%= hidden_field_tag "work", params[:work] %>
<%= submit_tag 'generate csv' %>
<% end %>
4 changes: 2 additions & 2 deletions app/views/cdm_migrator/csv/upload.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= form_for :csv_import, url: "/csv/upload" do |f| %>
<%= form_for :csv_import, url: csv_create_path do |f| %>
<%= f.label 'Multi-value Separator:' %>
<%= f.text_field 'mvs' %>
<br />
Expand All @@ -7,4 +7,4 @@
<%= f.submit 'Save' %>
<% end %>
<br />
<%= link_to "template", "/csv/generate.csv" %>
<%= link_to "template", csv_generate_path %>
6 changes: 3 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CdmMigrator::Engine.routes.draw do
get '/csv/upload', to: 'csv#upload'
post '/csv/upload', to: 'csv#create'
get '/csv/generate', to: 'csv#generate'
get '/csv/upload', to: 'csv#upload', as: 'csv_upload'
post '/csv/upload', to: 'csv#create', as: 'csv_create'
get '/csv/generate', to: 'csv#generate', as: 'csv_generate'

get 'cdm/collection', to: 'cdm#collection'
get 'cdm/mappings/', to: 'cdm#mappings', as: 'cdm_mappings'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
cdm_url: 'http://your-content-dm-host'
cdm_port: 8080
cdm_port: 8080
cdm_dirs:
dir1: '/dir1/path/goes/here'
dir2: '/dir2/path/goes/here'

0 comments on commit 8760731

Please sign in to comment.