diff --git a/app/controllers/import_resources_controller.rb b/app/controllers/import_resources_controller.rb deleted file mode 100644 index 71cfcaba14..0000000000 --- a/app/controllers/import_resources_controller.rb +++ /dev/null @@ -1,55 +0,0 @@ -class ImportResourcesController < ChouetteController - defaults resource_class: Import::Resource, collection_name: 'import_resources', instance_name: 'import_resource' - respond_to :html - belongs_to :import, :parent_class => Import::Base - - def index - index! do |format| - format.html { - @import_resources = decorate_import_resources(@import_resources) - } - end - end - - def download - if params[:token] == resource.token_download - send_file resource.file.path - else - user_not_authorized - end - end - - protected - - def workbench - return unless params[:workbench_id] - @workbench ||= current_organisation&.workbenches&.find(params[:workbench_id]) - end - - def workgroup - return unless params[:workgroup_id] - @workgroup ||= current_organisation&.workgroups.owned&.find(params[:workgroup_id]) - end - - def context - @context ||= workgroup || workbench - end - - def parent - @parent ||= context.imports.find params[:import_id] - end - - def collection - @import_resources ||= parent.resources - end - - def resource - @import_resource ||= parent.resources.find params[:id] - end - - private - - def decorate_import_resources(import_resources) - ImportResourcesDecorator.decorate(import_resources) - end -end diff --git a/app/decorators/import_resources_decorator.rb b/app/decorators/import_resources_decorator.rb deleted file mode 100644 index 88a8057cfc..0000000000 --- a/app/decorators/import_resources_decorator.rb +++ /dev/null @@ -1,12 +0,0 @@ -class ImportResourcesDecorator < AF83::Decorator - delegate :where - - def lines_imported - where(status: :OK, resource_type: :line).count - end - - def lines_in_zipfile - where(resource_type: :line).count - end - -end diff --git a/app/views/import_resources/index.html.slim b/app/views/import_resources/index.html.slim deleted file mode 100644 index 8a25d936bb..0000000000 --- a/app/views/import_resources/index.html.slim +++ /dev/null @@ -1,50 +0,0 @@ -- breadcrumb :import_resources, @import, @import_resources -.page_content.import_messages - .container-fluid - .row - .col-lg-12 - = definition_list t('metadatas'),{ 'Bilan d\'import' => link_to(@import.parent.name, workbench_import_path(@import.parent.workbench, @import.parent) ), - 'Jeu de données associé' => ( @import.referential.present? ? link_to(@import.referential.name, referential_path(@import.referential)) : '-' ) } - - .row - .col-lg-12 - h1 - span.status_icon = operation_status(@import.status) - span = t('.table_state', lines_imported: @import_resources.lines_imported , lines_in_zipfile: @import_resources.lines_in_zipfile ) - - if @import_resources.present? - .col-lg-12 - h2 = t('.table_title') - .col-lg-12 - = t('.table_explanation') - .col-lg-12 - = table_builder_2 @import_resources.where(resource_type: :file), - [ \ - TableBuilderHelper::Column.new( \ - key: :name, \ - attribute: 'name', \ - sortable: false, \ - ), \ - TableBuilderHelper::Column.new( \ - key: :status, \ - attribute: Proc.new { |n| import_resource_status(n.status) }, \ - sortable: false, \ - ), \ - TableBuilderHelper::Column.new( \ - name: 'Résultat des tests' , \ - attribute: Proc.new { |n| I18n.t('import_resources.index.metrics', n.metrics.deep_symbolize_keys) }, \ - sortable: false, \ - ), \ - TableBuilderHelper::Column.new( \ - name: 'Téléchargement' , \ - attribute: Proc.new { |n| ''.html_safe }, \ - sortable: false, \ - link_to: lambda do |import_resource| \ - workbench_import_import_resource_import_messages_path(import_resource.import.workbench, import_resource.import, import_resource, format: 'csv' ) \ - end \ - ), \ - ], - cls: 'table has-search' - - else - .col-lg-12 - - @import.messages.each do |message| - = I18n.t("import_messages.#{message.message_key}") diff --git a/app/views/import_resources/show.html.slim b/app/views/import_resources/show.html.slim deleted file mode 100644 index 2d080ebd66..0000000000 --- a/app/views/import_resources/show.html.slim +++ /dev/null @@ -1,52 +0,0 @@ -- breadcrumb :import_resource, @import_resource - -.page_content.import_messages - .container-fluid - .row - .col-lg-12 - - metadata = { 'Bilan d\'import' => link_to(@import_resource.root_import.name, workbench_import_path(@import_resource.root_import.workbench, @import_resource.root_import) ), - 'Jeu de données associé' => ( @import_resource.referential.present? ? link_to(@import_resource.referential.name, referential_path(@import_resource.referential)) : '-' ) } - - metadata = metadata.update({t('.status') => operation_status(@import_resource.status, verbose: true) }) - = definition_list t('metadatas'), metadata - - - .col-lg-12 - .error_messages - = render 'shared/iev_interfaces/messages', messages: @import_resource.messages - - - // XXX - //- if @import_resource.children.present? - - if @import_resource&.netex_import&.resources.present? - .col-lg-12 - h2 = t('.table_title') - .col-lg-12 - = t('.table_explanation') - .col-lg-12 - = table_builder_2 @import_resource.netex_import.resources.where(resource_type: :file), - [ \ - TableBuilderHelper::Column.new( \ - key: :name, \ - attribute: 'name', \ - sortable: false, \ - ), \ - TableBuilderHelper::Column.new( \ - key: :status, \ - attribute: Proc.new { |n| import_resource_status(n.status) }, \ - sortable: false, \ - ), \ - TableBuilderHelper::Column.new( \ - name: 'Résultat des tests' , \ - attribute: Proc.new { |n| I18n.t('import_resources.index.metrics', n.metrics.deep_symbolize_keys) }, \ - sortable: false, \ - ), \ - TableBuilderHelper::Column.new( \ - name: 'Téléchargement' , \ - attribute: Proc.new { |n| ''.html_safe }, \ - sortable: false, \ - link_to: lambda do |import_resource| \ - workbench_import_import_resource_import_messages_path(import_resource.import.workbench, import_resource.import, import_resource, format: 'csv' ) \ - end \ - ), \ - ], - cls: 'table has-search' diff --git a/config/locales/import_resources.en.yml b/config/locales/import_resources.en.yml index a108ea139c..8498946983 100644 --- a/config/locales/import_resources.en.yml +++ b/config/locales/import_resources.en.yml @@ -1,21 +1,9 @@ en: - import: - resources: &resources - index: - title: "NeTEx conformity" - table_state: "%{lines_imported} line(s) imported on %{lines_in_zipfile} presents in zip file" - metrics: "%{error_count} errors, %{warning_count} warnings" import_resources: - <<: *resources + index: + metrics: "%{error_count} errors, %{warning_count} warnings" activerecord: - models: - import_resource: - zero: "netex conformity" - one: "netex conformity" - other: "netex conformities" attributes: import/resource: name: "Filename" status: "Status" - resource_type: Resource Type - number_of_resources: Number of resources diff --git a/config/locales/import_resources.fr.yml b/config/locales/import_resources.fr.yml index fc74f8cab5..10e4a4b00a 100644 --- a/config/locales/import_resources.fr.yml +++ b/config/locales/import_resources.fr.yml @@ -1,26 +1,9 @@ fr: - import: - resources: &resources - table: &table - table_state: "%{lines_imported} ligne(s) importée(s) sur %{lines_in_zipfile} présente(s) dans l'archive" - index: - <<: *table - title: "Rapport de conformité NeTEx" - metrics: "%{error_count} errors, %{warning_count} warnings" - show: - <<: *table - title: Rapport d'import import_resources: - <<: *resources + index: + metrics: "%{error_count} errors, %{warning_count} warnings" activerecord: - models: - import_resource: - zero: "rapport de conformité Netex" - one: "rapport de conformité Netex" - other: "rapports de conformité Netex" attributes: import/resource: name: "Fichier" status: "État" - number_of_resources: Nombre de ressources - resource_type: Type de ressource diff --git a/spec/controllers/import_resources_controller_spec.rb b/spec/controllers/import_resources_controller_spec.rb deleted file mode 100644 index d749875de3..0000000000 --- a/spec/controllers/import_resources_controller_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -RSpec.describe ImportResourcesController, :type => :controller do - login_user - - let(:organisation){ @user.organisation } - let(:workbench) { create :workbench, organisation: organisation } - let(:import) { create :import, workbench: workbench } - let(:import_resource) { create :import_resource, import: import } - - describe "GET index" do - let(:request){ get :index, params: { workbench_id: workbench.id, import_id: import.id }} - it_behaves_like 'checks current_organisation' - end - - describe "GET show" do - let(:request){ get :show, params: { workbench_id: workbench.id, import_id: import.id, id: import_resource.id }} - it_behaves_like 'checks current_organisation' - end -end