aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXinhui2016-12-27 17:33:46 +0100
committerXinhui2016-12-27 17:33:46 +0100
commit2b20966f6ea209765bc3f113345334128f54b465 (patch)
tree2a4e6792d1372953e31c109611181bf99f7a4f66
parent69a059042c04f4537a75415eb083295311f71be1 (diff)
downloadchouette-core-2b20966f6ea209765bc3f113345334128f54b465.tar.bz2
Wip Imports
Refs #2261
-rw-r--r--app/controllers/imports_controller.rb28
-rw-r--r--app/models/referential.rb1
-rw-r--r--app/models/workbench.rb2
-rw-r--r--app/views/imports/_form.html.slim5
-rw-r--r--app/views/imports/_import.html.slim24
-rw-r--r--app/views/imports/_imports.html.slim9
-rw-r--r--app/views/imports/index.html.slim8
-rw-r--r--app/views/imports/new.html.slim4
-rw-r--r--app/views/imports/show.html.slim28
-rw-r--r--app/views/workbenches/show.html.slim1
-rw-r--r--config/routes.rb14
11 files changed, 31 insertions, 93 deletions
diff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rb
index 712192aaa..4664bc430 100644
--- a/app/controllers/imports_controller.rb
+++ b/app/controllers/imports_controller.rb
@@ -1,20 +1,24 @@
-class ImportsController < ChouetteController
+class ImportsController < BreadcrumbController
defaults :resource_class => Import
respond_to :html
- belongs_to :referential
+ belongs_to :workbench
- def show
- show! do
- build_breadcrumb :show
- end
- end
+ # def show
+ # show! do
+ # build_breadcrumb :show
+ # end
+ # end
- def index
- index! do
- build_breadcrumb :index
- end
- end
+ # def index
+ # index! do
+ # build_breadcrumb :index
+ # end
+ # end
def new
+ ap params
+ ap @workbench
+ ap '------------'
+ @import = Import.new
end
end
diff --git a/app/models/referential.rb b/app/models/referential.rb
index 979647f21..f58647136 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -34,7 +34,6 @@ class Referential < ActiveRecord::Base
has_many :companies, through: :line_referential
has_many :group_of_lines, through: :line_referential
has_many :networks, through: :line_referential
- has_many :imports
has_many :metadatas, class_name: "ReferentialMetadata", inverse_of: :referential, dependent: :destroy
accepts_nested_attributes_for :metadatas
diff --git a/app/models/workbench.rb b/app/models/workbench.rb
index 419790edb..68fcc9d55 100644
--- a/app/models/workbench.rb
+++ b/app/models/workbench.rb
@@ -8,7 +8,7 @@ class Workbench < ActiveRecord::Base
has_many :companies, through: :line_referential
has_many :group_of_lines, through: :line_referential
has_many :stop_areas, through: :stop_area_referential
-
+ has_many :imports
validates :name, presence: true
validates :organisation, presence: true
diff --git a/app/views/imports/_form.html.slim b/app/views/imports/_form.html.slim
new file mode 100644
index 000000000..2da071f97
--- /dev/null
+++ b/app/views/imports/_form.html.slim
@@ -0,0 +1,5 @@
+= simple_form_for import do |f|
+ = f.input :name
+ = f.input :file
+ = f.input :workbench
+ = f.button :submit
diff --git a/app/views/imports/_import.html.slim b/app/views/imports/_import.html.slim
deleted file mode 100644
index 7d4753358..000000000
--- a/app/views/imports/_import.html.slim
+++ /dev/null
@@ -1,24 +0,0 @@
-#index_item.panel.panel-default.import
- .panel-heading
- .panel-title.clearfix
- span.pull-right
- = link_to referential_import_path(@referential, import.id), method: :delete, :data => {:confirm => t('imports.actions.destroy_confirm')}, class: 'btn btn-danger btn-sm' do
- span.fa.fa-trash-o
-
- h5
- = link_to( referential_import_path(@referential, import.id), class: 'preview', :title => "#{ImportTask.model_name.human.capitalize} #{import.name}") do
- = job_status_title(import)
-
- .panel-body
- p
- = link_to font_awesome_classic_tag("fa-file-#{import.filename_extension}-o") + t("imports.show.imported_file"), imported_file_referential_import_path(@referential, import.id) if import.file_path?
-
- p
- = link_to font_awesome_classic_tag("fa-external-link") + t("imports.show.compliance_check"), compliance_check_referential_import_path(@referential, import.id) if import.compliance_check?
-
- .panel-footer
- = import_attributes_tag(import)
-
- .history
- = l(import.created_at, :format => "%d/%m/%Y %H:%M") if import.created_at
- = " | #{import.user_name}" \ No newline at end of file
diff --git a/app/views/imports/_imports.html.slim b/app/views/imports/_imports.html.slim
deleted file mode 100644
index 3605fd10b..000000000
--- a/app/views/imports/_imports.html.slim
+++ /dev/null
@@ -1,9 +0,0 @@
-.page_info
- span.search = t("will_paginate.page_entries_info.search")
- = page_entries_info @imports
-
-.imports.paginated_content
- = paginated_content @imports, "imports/import"
-
-.pagination
- = will_paginate @imports, :container => false, renderer: RemoteBootstrapPaginationLinkRenderer \ No newline at end of file
diff --git a/app/views/imports/index.html.slim b/app/views/imports/index.html.slim
index b1922d005..cc76aad71 100644
--- a/app/views/imports/index.html.slim
+++ b/app/views/imports/index.html.slim
@@ -1,13 +1,5 @@
= title_tag t('.title')
.warning = t('.warning')
-
-#imports
- = render 'imports'
-
- content_for :sidebar do
ul.actions
- li
- = link_to t('imports.actions.new'), new_referential_import_task_path(@referential), class: 'add'
- li
- = link_to t('rule_parameter_sets.actions.index'), organisation_rule_parameter_sets_path, class: 'link' \ No newline at end of file
diff --git a/app/views/imports/new.html.slim b/app/views/imports/new.html.slim
index 2ddd078cb..ae8aad4ee 100644
--- a/app/views/imports/new.html.slim
+++ b/app/views/imports/new.html.slim
@@ -1 +1,5 @@
+= title_tag t('.title')
= @import.inspect
+= @workbench.inspect
+.row
+ .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-8.col-sm-offset-2
diff --git a/app/views/imports/show.html.slim b/app/views/imports/show.html.slim
index 5992af311..d8b5a80e2 100644
--- a/app/views/imports/show.html.slim
+++ b/app/views/imports/show.html.slim
@@ -1,27 +1 @@
-.title.row
- .col-md-8
- = title_tag job_status_title(@import)
-
- .col-md-4
- = import_attributes_tag(@import)
-
-- if @import.report.failure_code?
- .alert.alert-danger
- = t("iev.failure.#{@import.report.failure_code}")
-
-.progress_bars
- = progress_bar_tag(@import)
-
-.import_show
- .links
- = link_to font_awesome_classic_tag("fa-file-#{@import.filename_extension}-o") + t("imports.show.imported_file"), imported_file_referential_import_path(@referential, @import.id) if @import.file_path?
- = link_to font_awesome_classic_tag("fa-external-link") + t("imports.show.compliance_check"), compliance_check_referential_import_path(@referential, @import.id) if @import.compliance_check?
-
- = render(partial: 'shared/ie_report', locals: {job: @import, line_items: @line_items})
-
-- content_for :sidebar do
- ul.actions
- li
- = link_to t('imports.actions.destroy'), referential_import_path(@referential, @import.id), method: :delete, data: {confirm: t('imports.actions.destroy_confirm')}, class: 'remove'
-
- = history_tag(@import) \ No newline at end of file
+h1 = @import.inspect
diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim
index a6cef4904..678e6722e 100644
--- a/app/views/workbenches/show.html.slim
+++ b/app/views/workbenches/show.html.slim
@@ -72,3 +72,4 @@
- content_for :sidebar do
ul.actions
li = link_to t('referentials.actions.new'), new_referential_path(workbench_id: @workbench), class: 'add'
+ li = link_to t('referentials.actions.import'), new_workbench_import_path(workbench_id: @workbench), class: 'add'
diff --git a/config/routes.rb b/config/routes.rb
index 30aea2295..182a152a6 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,7 +1,9 @@
require 'sidekiq/web'
ChouetteIhm::Application.routes.draw do
- resources :workbenches, :only => [:show]
+ resources :workbenches, :only => [:show] do
+ resources :imports
+ end
devise_for :users, :controllers => {
:registrations => 'users/registrations', :invitations => 'users/invitations'
@@ -119,16 +121,6 @@ ChouetteIhm::Application.routes.draw do
end
resources :import_tasks, :only => [:new, :create]
- resources :imports
- # fixme #2261
- # member do
- # get "imported_file"
- # get "rule_parameter_set"
- # get "compliance_check"
- # get 'export', defaults: { format: 'zip' }
- # end
- # end
-
resources :export_tasks, :only => [:new, :create] do
collection do
get 'references'