From f3a6c18a84df960a0e4e3823e048f6c47656481b Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Mon, 14 Oct 2019 14:50:05 +0200 Subject: [PATCH 1/6] Improve permission checking for reports [SCI-3991] --- app/controllers/concerns/report_actions.rb | 42 ++++++++++------------ app/controllers/reports_controller.rb | 18 +++++----- 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/app/controllers/concerns/report_actions.rb b/app/controllers/concerns/report_actions.rb index 9b279910f..7bc1e0ca6 100644 --- a/app/controllers/concerns/report_actions.rb +++ b/app/controllers/concerns/report_actions.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ReportActions extend ActiveSupport::Concern @@ -30,19 +32,18 @@ module ReportActions def generate_project_contents_json res = [] if params.include? :modules - modules = (params[:modules].select { |_, p| p == '1' }) - .keys - .collect(&:to_i) + module_ids = (params[:modules].select { |_, p| p == '1' }).keys.collect(&:to_i) # Get unique experiments from given modules - experiments = MyModule.where(id: modules).map(&:experiment).uniq + experiments = @project.experiments.distinct.joins(:my_modules).where('my_modules.id': module_ids) experiments.each do |experiment| res << generate_new_el(false) el = generate_el( 'reports/elements/experiment_element.html.erb', experiment: experiment ) - el[:children] = generate_experiment_contents_json(experiment, modules) + selected_modules = experiment.my_modules.where(id: module_ids) + el[:children] = generate_experiment_contents_json(selected_modules) res << el end end @@ -50,11 +51,9 @@ module ReportActions res end - def generate_experiment_contents_json(experiment, selected_modules) + def generate_experiment_contents_json(selected_modules) res = [] - experiment.my_modules.order(:workflow_order).each do |my_module| - next unless selected_modules.include?(my_module.id) - + selected_modules.order(:workflow_order).each do |my_module| res << generate_new_el(false) el = generate_el( 'reports/elements/my_module_element.html.erb', @@ -75,13 +74,12 @@ module ReportActions contents.values.each do |element| if contents.has_many elements = params.select { |k| k.starts_with?("module_#{element}") } - elements = elements.select { |_,v| v == '1' }.keys - elements.map! { |el| el.gsub('module_', '')}.map!{|el| el.split('_') } + elements = elements.select { |_, v| v == '1' }.keys + elements.map! { |el| el.gsub('module_', '') }.map! { |el| el.split('_') } elements.map! { |el| [el[0].to_sym, el[1].to_i] } break unless elements.empty? else - present = in_params?("module_#{element}".to_sym) || - in_params?(element.to_sym) + present = in_params?("module_#{element}".to_sym) || in_params?(element.to_sym) if present elements << [element.to_sym, nil] break @@ -131,8 +129,7 @@ module ReportActions step.checklists.asc.each do |checklist| res << generate_new_el(false) res << generate_el( - 'reports/elements/step_checklist_element.html.erb', - { checklist: checklist } + 'reports/elements/step_checklist_element.html.erb', checklist: checklist ) end end @@ -140,8 +137,7 @@ module ReportActions step.assets.each do |asset| res << generate_new_el(false) res << generate_el( - 'reports/elements/step_asset_element.html.erb', - { asset: asset } + 'reports/elements/step_asset_element.html.erb', asset: asset ) end end @@ -149,16 +145,14 @@ module ReportActions step.tables.each do |table| res << generate_new_el(false) res << generate_el( - 'reports/elements/step_table_element.html.erb', - { table: table } + 'reports/elements/step_table_element.html.erb', table: table ) end end if in_params? :step_comments res << generate_new_el(false) res << generate_el( - 'reports/elements/step_comments_element.html.erb', - { step: step, order: :asc } + 'reports/elements/step_comments_element.html.erb', step: step, order: :asc ) end res << generate_new_el(false) @@ -170,8 +164,7 @@ module ReportActions if in_params? :result_comments res << generate_new_el(true) res << generate_el( - 'reports/elements/result_comments_element.html.erb', - { result: result, order: :asc } + 'reports/elements/result_comments_element.html.erb', result: result, order: :asc ) else res << generate_new_el(false) @@ -180,11 +173,12 @@ module ReportActions end def elements_empty?(elements) - return true if elements.blank? || elements.count == 0 + return true if elements.blank? || elements.count.zero? if elements.count == 1 el = elements[0] return true if el.include?(:new_element) && el[:new_element] + return false end false diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index da1046f68..b958d5f98 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -325,22 +325,20 @@ class ReportsController < ApplicationController if elements_empty? elements format.json { render json: {}, status: :no_content } else - format.json { + format.json do render json: { status: :ok, elements: elements } - } + end end end end def experiment_contents - experiment = @project.experiments.find_by_id(params[:id]) - exp_module_ids = experiment.my_modules.pluck(:id) - modules = (params[:modules].select { |k, p| exp_module_ids.include?(k.to_i) && p == '1' }) - .keys - .collect(&:to_i) + experiment = @project.experiments.find_by(id: params[:id]) + module_ids = (params[:modules].select { |_, p| p == '1' }).keys.collect(&:to_i) + selected_modules = experiment.my_modules.where(id: module_ids) respond_to do |format| if experiment.blank? @@ -348,7 +346,7 @@ class ReportsController < ApplicationController elsif modules.blank? format.json { render json: {}, status: :no_content } else - elements = generate_experiment_contents_json(experiment, modules) + elements = generate_experiment_contents_json(selected_modules) end if elements_empty? elements @@ -451,12 +449,12 @@ class ReportsController < ApplicationController AvailableRepository = Struct.new(:id, :name) def load_vars - @report = Report.find_by_id(params[:id]) + @report = current_team.reports.find_by(id: params[:id]) render_404 unless @report end def load_vars_nested - @project = Project.find_by_id(params[:project_id]) + @project = current_team.projects.find_by(id: params[:project_id]) render_404 unless @project render_403 unless can_read_project?(@project) end From 53402c9ce10721387e118ab34a722099c3c654e0 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Thu, 17 Oct 2019 13:30:14 +0200 Subject: [PATCH 2/6] Fix images in reports, impove speed of report generation [SCI-3990][SCI-3993] --- Dockerfile | 6 +++++- Dockerfile.production | 6 +++++- Gemfile | 4 ++-- Gemfile.lock | 9 ++++---- app/controllers/concerns/report_actions.rb | 2 +- app/helpers/reports_helper.rb | 6 ++++-- app/models/concerns/tiny_mce_images.rb | 2 +- app/models/my_module.rb | 1 + .../_my_module_activity_element.html.erb | 2 +- .../elements/_my_module_element.html.erb | 2 +- .../_my_module_result_asset_element.html.erb | 21 ++++++++++++------- .../_result_comments_element.html.erb | 6 +++--- .../elements/_step_comments_element.html.erb | 6 +++--- .../modal/_project_contents_inner.html.erb | 2 +- config/initializers/extends/report_extends.rb | 6 +++--- config/initializers/wicked_pdf.rb | 18 +++++++++------- db/structure.sql | 3 ++- docker-compose.yml | 2 +- 18 files changed, 63 insertions(+), 41 deletions(-) diff --git a/Dockerfile b/Dockerfile index 417d4f432..0511c1a16 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,14 @@ FROM ruby:2.6.4-buster MAINTAINER BioSistemika +ARG WKHTMLTOPDF_PACKAGE_URL=https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb + RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - && \ echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' >> /etc/apt/sources.list && \ wget -O /usr/bin/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/77.0.3865.40/chromedriver_linux64.zip && \ unzip /usr/bin/chromedriver_linux64.zip -d /usr/bin/ # additional dependecies -# libSSL-1.0 is required by wkhtmltopdf binary # libreoffice for file preview generation RUN apt-get update -qq && \ apt-get install -y \ @@ -24,6 +25,9 @@ RUN apt-get update -qq && \ libreoffice \ libfile-mimeinfo-perl \ google-chrome-stable=77.* && \ + wget -q -O /tmp/wkhtmltox_amd64.deb $WKHTMLTOPDF_PACKAGE_URL && \ + apt-get install -y /tmp/wkhtmltox_amd64.deb && \ + rm /tmp/wkhtmltox_amd64.deb && \ npm install -g yarn && \ ln -s /usr/lib/x86_64-linux-gnu/libvips.so.42 /usr/lib/x86_64-linux-gnu/libvips.so && \ rm -rf /var/lib/apt/lists/* diff --git a/Dockerfile.production b/Dockerfile.production index 5f622c57e..627cdc66b 100644 --- a/Dockerfile.production +++ b/Dockerfile.production @@ -1,8 +1,9 @@ FROM ruby:2.6.4-buster MAINTAINER BioSistemika +ARG WKHTMLTOPDF_PACKAGE_URL=https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb + # additional dependecies -# libSSL-1.0 is required by wkhtmltopdf binary # libreoffice for file preview generation RUN apt-get update -qq && \ apt-get install -y \ @@ -21,6 +22,9 @@ RUN apt-get update -qq && \ sudo graphviz --no-install-recommends \ libreoffice \ libfile-mimeinfo-perl && \ + wget -q -O /tmp/wkhtmltox_amd64.deb $WKHTMLTOPDF_PACKAGE_URL && \ + apt-get install -y /tmp/wkhtmltox_amd64.deb && \ + rm /tmp/wkhtmltox_amd64.deb && \ npm install -g yarn && \ ln -s /usr/lib/x86_64-linux-gnu/libvips.so.42 /usr/lib/x86_64-linux-gnu/libvips.so && \ rm -rf /var/lib/apt/lists/* diff --git a/Gemfile b/Gemfile index fa443c790..08e0f79e6 100644 --- a/Gemfile +++ b/Gemfile @@ -80,8 +80,8 @@ gem 'silencer' # Silence certain Rails logs gem 'sneaky-save', git: 'https://github.com/einzige/sneaky-save' gem 'turbolinks', '~> 5.1.1' gem 'underscore-rails' -gem 'wicked_pdf', '~> 1.1.0' -gem 'wkhtmltopdf-heroku', '2.12.4' +gem 'wicked_pdf', '~> 1.4.0' +gem 'wkhtmltopdf-heroku', '2.12.5' gem 'aws-sdk-rails' gem 'aws-sdk-s3' diff --git a/Gemfile.lock b/Gemfile.lock index c512d0bdf..f556ae955 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -579,8 +579,9 @@ GEM websocket-extensions (>= 0.1.0) websocket-extensions (0.1.4) whacamole (1.2.0) - wicked_pdf (1.1.0) - wkhtmltopdf-heroku (2.12.4.0) + wicked_pdf (1.4.0) + activesupport + wkhtmltopdf-heroku (2.12.5.0) xpath (3.2.0) nokogiri (~> 1.8) yomu (0.1.5) @@ -694,8 +695,8 @@ DEPENDENCIES webmock webpacker (~> 4.0.0) whacamole - wicked_pdf (~> 1.1.0) - wkhtmltopdf-heroku (= 2.12.4) + wicked_pdf (~> 1.4.0) + wkhtmltopdf-heroku (= 2.12.5) yomu RUBY VERSION diff --git a/app/controllers/concerns/report_actions.rb b/app/controllers/concerns/report_actions.rb index 7bc1e0ca6..d6856e4db 100644 --- a/app/controllers/concerns/report_actions.rb +++ b/app/controllers/concerns/report_actions.rb @@ -42,7 +42,7 @@ module ReportActions 'reports/elements/experiment_element.html.erb', experiment: experiment ) - selected_modules = experiment.my_modules.where(id: module_ids) + selected_modules = experiment.my_modules.includes(:tags).where(id: module_ids) el[:children] = generate_experiment_contents_json(selected_modules) res << el end diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb index 498e73060..07957a7c0 100644 --- a/app/helpers/reports_helper.rb +++ b/app/helpers/reports_helper.rb @@ -98,8 +98,10 @@ module ReportsHelper end # "Hack" to omit file preview URL because of WKHTML issues - def report_image_asset_url(asset, _type = :asset, klass = nil) - image_tag(asset.generate_base64(:medium), class: klass) + def report_image_asset_url(asset) + image_tag(asset.medium_preview + .processed + .service_url(expires_in: Constants::URL_LONG_EXPIRE_TIME)) end # "Hack" to load Glyphicons css directly from the CDN diff --git a/app/models/concerns/tiny_mce_images.rb b/app/models/concerns/tiny_mce_images.rb index c13d455c1..0e577fc4f 100644 --- a/app/models/concerns/tiny_mce_images.rb +++ b/app/models/concerns/tiny_mce_images.rb @@ -20,7 +20,7 @@ module TinyMceImages tiny_mce_assets.each do |tm_asset| next unless tm_asset&.image&.attached? - new_tm_asset_src = tm_asset.convert_variant_to_base64(tm_asset.preview) + new_tm_asset_src = tm_asset.preview.processed.service_url(expires_in: Constants::URL_LONG_EXPIRE_TIME) html_description = Nokogiri::HTML(description) tm_asset_to_update = html_description.css( "img[data-mce-token=\"#{Base62.encode(tm_asset.id)}\"]" diff --git a/app/models/my_module.rb b/app/models/my_module.rb index 407cfa7af..29fe9e1d6 100644 --- a/app/models/my_module.rb +++ b/app/models/my_module.rb @@ -370,6 +370,7 @@ class MyModule < ApplicationRecord def repository_json_hot(repository_id, order) data = [] repository_rows + .includes(:created_by) .where(repository_id: repository_id) .order(created_at: order).find_each do |row| row_json = [] diff --git a/app/views/reports/elements/_my_module_activity_element.html.erb b/app/views/reports/elements/_my_module_activity_element.html.erb index 25b845d03..4758e3562 100644 --- a/app/views/reports/elements/_my_module_activity_element.html.erb +++ b/app/views/reports/elements/_my_module_activity_element.html.erb @@ -19,7 +19,7 @@
- <% if activities.count > 0 %> + <% if activities.any? %>
    <% activities.each do |activity| %> diff --git a/app/views/reports/elements/_my_module_element.html.erb b/app/views/reports/elements/_my_module_element.html.erb index 3c1316fe3..3c9e4c9a2 100644 --- a/app/views/reports/elements/_my_module_element.html.erb +++ b/app/views/reports/elements/_my_module_element.html.erb @@ -48,7 +48,7 @@
    <%=t "projects.reports.elements.module.tags_header" %>
    - <% if my_module.tags.count > 0 %> + <% if my_module.tags.any? %> <% my_module.tags.each do |tag| %>
    <%= tag.name %> diff --git a/app/views/reports/elements/_my_module_result_asset_element.html.erb b/app/views/reports/elements/_my_module_result_asset_element.html.erb index e934d8adf..3ff08a35a 100644 --- a/app/views/reports/elements/_my_module_result_asset_element.html.erb +++ b/app/views/reports/elements/_my_module_result_asset_element.html.erb @@ -4,7 +4,14 @@ <% comments = result.result_comments %> <% timestamp = asset.created_at %> <% icon_class = 'fas ' + (is_image ? 'fa-image' : 'fa-file') %> -
    " data-name="<%= result.name %>" data-icon-class="<%= icon_class %>"> +
    " + data-name="<%= result.name %>" + data-icon-class="<%= icon_class %>">
    @@ -13,23 +20,21 @@
    <%= result.name %> <% if result.archived? %> - <%=t 'search.index.archived' %> + <%= t('search.index.archived') %> <% end %>
    <% if defined? export_all and export_all %> - <%=t "projects.reports.elements.result_asset.file_name", - file: filename %> + <%= t("projects.reports.elements.result_asset.file_name", file: filename) %> <% else %> - <%=t "projects.reports.elements.result_asset.file_name", - file: truncate(asset.file_name, - length: Constants::FILENAME_TRUNCATION_LENGTH) %> + <%= t("projects.reports.elements.result_asset.file_name", + file: truncate(asset.file_name, length: Constants::FILENAME_TRUNCATION_LENGTH)) %> <% end %>
    - <%=t "projects.reports.elements.result_asset.user_time", user: result.user.full_name, timestamp: l(timestamp, format: :full) %> + <%= t("projects.reports.elements.result_asset.user_time", user: result.user.full_name, timestamp: l(timestamp, format: :full)) %>
    <%= render partial: "reports/elements/element_controls.html.erb" %> diff --git a/app/views/reports/elements/_result_comments_element.html.erb b/app/views/reports/elements/_result_comments_element.html.erb index b6635caef..9193e5373 100644 --- a/app/views/reports/elements/_result_comments_element.html.erb +++ b/app/views/reports/elements/_result_comments_element.html.erb @@ -19,14 +19,14 @@
    - <% if comments.count == 0 %> - <%=t "projects.reports.elements.result_comments.no_comments" %> - <% else %> + <% if comments.any? %>
      <% comments.each do |comment| %> <%= render partial: 'shared/comments/item.html.erb', locals: { comment: comment, readonly: true, report: true } %> <% end %>
    + <% else %> + <%=t "projects.reports.elements.result_comments.no_comments" %> <% end %>
    diff --git a/app/views/reports/elements/_step_comments_element.html.erb b/app/views/reports/elements/_step_comments_element.html.erb index f5ef00921..1f26ae3b9 100644 --- a/app/views/reports/elements/_step_comments_element.html.erb +++ b/app/views/reports/elements/_step_comments_element.html.erb @@ -19,14 +19,14 @@
    - <% if comments.count == 0 %> - <%=t "projects.reports.elements.step_comments.no_comments" %> - <% else %> + <% if comments.any? %>
      <% comments.each do |comment| %> <%= render partial: 'shared/comments/item.html.erb', locals: { comment: comment, readonly: true, report: true } %> <% end %>
    + <% else %> + <%=t "projects.reports.elements.step_comments.no_comments" %> <% end %>
    diff --git a/app/views/reports/new/modal/_project_contents_inner.html.erb b/app/views/reports/new/modal/_project_contents_inner.html.erb index 6304104de..c6b3146c7 100644 --- a/app/views/reports/new/modal/_project_contents_inner.html.erb +++ b/app/views/reports/new/modal/_project_contents_inner.html.erb @@ -11,7 +11,7 @@ <%= form.check_box :project, label: project.name %>
      - <% project.experiments.is_archived(false).each do |experiment| %> + <% project.experiments.includes(:my_module_groups).is_archived(false).each do |experiment| %> <% next unless experiment.my_modules.is_archived(false).exists? %>
    • <%= form.check_box "experiment_#{experiment.id}", label: experiment.name %> diff --git a/config/initializers/extends/report_extends.rb b/config/initializers/extends/report_extends.rb index 7ac2c4009..fbf2dcf56 100644 --- a/config/initializers/extends/report_extends.rb +++ b/config/initializers/extends/report_extends.rb @@ -78,21 +78,21 @@ module ReportExtends true, [:result], proc do |my_module| - my_module.results.select { |r| r.is_asset && r.active? } + my_module.results.joins(:result_asset).select { |r| r.active? } end), ModuleElement.new([:result_tables], :result_tables, true, [:result], proc do |my_module| - my_module.results.select { |r| r.is_table && r.active? } + my_module.results.joins(:result_table).select { |r| r.active? } end), ModuleElement.new([:result_texts], :result_texts, true, [:result], proc do |my_module| - my_module.results.select { |r| r.is_text && r.active? } + my_module.results.joins(:result_text).select { |r| r.active? } end), ModuleElement.new([:activity], :activity, diff --git a/config/initializers/wicked_pdf.rb b/config/initializers/wicked_pdf.rb index 14ca09afd..566a74539 100644 --- a/config/initializers/wicked_pdf.rb +++ b/config/initializers/wicked_pdf.rb @@ -1,21 +1,25 @@ +# frozen_string_literal: true + WickedPdf.config ||= {} +ENV['PATH'].split(':').each do |path| + exe_path = File.join(path, 'wkhtmltopdf') + WickedPdf.config[:exe_path] = File.join(path, 'wkhtmltopdf') if File.file?(exe_path) +end # WickedPdfHelper patch that fixes issue with including application.css # in environments like Heroku where assets.compile option is disabled and # it is not acceptable to enable it. -if Rails.env.production? and Rails.configuration.assets.compile == false - +if Rails.env.production? && Rails.configuration.assets.compile == false WickedPdf::WickedPdfHelper::Assets.module_eval do - def read_asset(source) - manifest = Rails.application.assets_manifest - path = File.join(manifest.dir, manifest.assets[source]) - File.read(path) + manifest = Rails.application.assets_manifest + path = File.join(manifest.dir, manifest.assets[source]) + File.read(path) end def asset_exists?(source) - Rails.application.assets_manifest.assets.key?(source) + Rails.application.assets_manifest.assets.key?(source) end end end diff --git a/db/structure.sql b/db/structure.sql index 7c5435c87..f36ed4d02 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -6520,6 +6520,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20190812072649'), ('20190830141257'), ('20190910125740'), -('20191001133557'); +('20191001133557'), +('20191009146101'); diff --git a/docker-compose.yml b/docker-compose.yml index e0f2d6002..f869b0af3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: volumes: - scinote_development_postgres:/var/lib/postgresql/data ports: - - "6543:5432" + - "5432:5432" web: build: From 2637aed85326d64d87dbf3a35f75aa1b1d3ea660 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Thu, 17 Oct 2019 13:38:36 +0200 Subject: [PATCH 3/6] Fix code styling [SCI-3990][SCI-3993] --- config/initializers/extends/report_extends.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/initializers/extends/report_extends.rb b/config/initializers/extends/report_extends.rb index fbf2dcf56..a7f59e217 100644 --- a/config/initializers/extends/report_extends.rb +++ b/config/initializers/extends/report_extends.rb @@ -78,21 +78,21 @@ module ReportExtends true, [:result], proc do |my_module| - my_module.results.joins(:result_asset).select { |r| r.active? } + my_module.results.joins(:result_asset).select(&:active?) end), ModuleElement.new([:result_tables], :result_tables, true, [:result], proc do |my_module| - my_module.results.joins(:result_table).select { |r| r.active? } + my_module.results.joins(:result_table).select(&:active?) end), ModuleElement.new([:result_texts], :result_texts, true, [:result], proc do |my_module| - my_module.results.joins(:result_text).select { |r| r.active? } + my_module.results.joins(:result_text).select(&:active?) end), ModuleElement.new([:activity], :activity, From 0af8629f980cc43182f7c19a8c5620db2e4b8e2a Mon Sep 17 00:00:00 2001 From: Miha Mencin Date: Thu, 17 Oct 2019 09:29:19 +0200 Subject: [PATCH 4/6] SCI-3994 fix for excel import --- app/services/import_repository/import_records.rb | 12 +++++++----- app/services/spreadsheet_parser.rb | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/services/import_repository/import_records.rb b/app/services/import_repository/import_records.rb index ba80a4b0a..4715dbe2a 100644 --- a/app/services/import_repository/import_records.rb +++ b/app/services/import_repository/import_records.rb @@ -17,11 +17,13 @@ module ImportRepository private def run_import_actions - @repository.import_records( - SpreadsheetParser.open_spreadsheet(@temp_file.file), - @mappings, - @user - ) + @temp_file.file.open do |temp_file| + @repository.import_records( + SpreadsheetParser.open_spreadsheet(temp_file), + @mappings, + @user + ) + end end def run_checks diff --git a/app/services/spreadsheet_parser.rb b/app/services/spreadsheet_parser.rb index 700697169..3657270e4 100644 --- a/app/services/spreadsheet_parser.rb +++ b/app/services/spreadsheet_parser.rb @@ -7,8 +7,8 @@ class SpreadsheetParser filename = file.original_filename file_path = file.path else - filename = file.filename.to_s - file_path = file.service_url + filename = File.basename(file.path) + file_path = file.path end case File.extname(filename) From 4cba412e312ef989dd5701a061c6638ed959d4f4 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Thu, 17 Oct 2019 16:44:15 +0200 Subject: [PATCH 5/6] Fix protocols table select all checkbox [SCI-3999] --- app/assets/javascripts/protocols/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/protocols/index.js b/app/assets/javascripts/protocols/index.js index 789c63637..2f7b01387 100644 --- a/app/assets/javascripts/protocols/index.js +++ b/app/assets/javascripts/protocols/index.js @@ -12,7 +12,6 @@ var repositoryType; function init() { updateButtons(); initProtocolsTable(); - initRowSelection(); initKeywordFiltering(); initProtocolPreviewModal(); initLinkedChildrenModal(); @@ -99,6 +98,7 @@ function initProtocolsTable() { }, fnDrawCallback: function(settings, json) { animateSpinner(this, false); + initRowSelection(); $.initTooltips(); }, preDrawCallback: function(settings) { @@ -129,6 +129,8 @@ function initProtocolsTable() { } function initRowSelection() { + let protocolsTableScrollHead = protocolsTableEl.closest('.dataTables_scroll').find('.dataTables_scrollHead'); + // Handle click on table cells with checkboxes protocolsTableEl.on("click", "tbody td, thead th:first-child", function(e) { $(this).parent().find("input[type='checkbox']").trigger("click"); @@ -164,11 +166,11 @@ function initRowSelection() { }); // Handle click on "Select all" control - protocolsTableEl.find("thead input[name='select_all']").on("click", function(e) { + protocolsTableScrollHead.find("thead input[name='select_all']").on('click', function(e) { if (this.checked) { - protocolsTableEl.find("tbody input[type='checkbox']:not(:checked)").trigger("click"); + protocolsTableEl.find("tbody input[type='checkbox']:not(:checked)").trigger('click'); } else { - protocolsTableEl.find("tbody input[type='checkbox']:checked").trigger("click"); + protocolsTableEl.find("tbody input[type='checkbox']:checked").trigger('click'); } // Prevent click event from propagating to parent From 61805cb83754bedc5adfdec4b4dc08ad8d722cc8 Mon Sep 17 00:00:00 2001 From: Alex Kriuchykhin Date: Fri, 18 Oct 2019 13:35:48 +0200 Subject: [PATCH 6/6] Bump version to 1.17.3 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 06fb41b63..b9a05a6dc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.17.2 +1.17.3