Commit babfaa7c authored by hellekin's avatar hellekin

Make rubocop happy

parent 96f6c38d
...@@ -11,7 +11,11 @@ class ApplicationController < ActionController::API ...@@ -11,7 +11,11 @@ class ApplicationController < ActionController::API
if Rails.env.development? if Rails.env.development?
# @see https://github.com/varvet/pundit#ensuring-policies-and-scopes-are-used # @see https://github.com/varvet/pundit#ensuring-policies-and-scopes-are-used
after_action :verify_authorized, except: :index, if: proc { params[:pundit] == 'verify' } with_options if: proc { params[:pundit] == 'verify' } do
after_action :verify_policy_scoped, only: :index, if: proc { params[:pundit] == 'verify' } # rubocop:disable Rails/LexicallyScopedActionFilter
after_action :verify_authorized, except: :index
after_action :verify_policy_scoped, only: :index
# rubocop:enable Rails/LexicallyScopedActionFilter
end
end end
end end
# coding: utf-8
# frozen_string_literal: true # frozen_string_literal: true
require_relative '../../config/application' require_relative '../../config/application'
...@@ -12,7 +11,7 @@ raise ArgumentError, "RCR Agent does not exist!\n#{agent&.errors&.inspect}" unle ...@@ -12,7 +11,7 @@ raise ArgumentError, "RCR Agent does not exist!\n#{agent&.errors&.inspect}" unle
entries = JSON.parse File.read(Rails.root.join('doc', 'import', 'rcr-initiatives.json')) entries = JSON.parse File.read(Rails.root.join('doc', 'import', 'rcr-initiatives.json'))
rcr = agent.taxonomies.includes(:categories, :sections) rcr = agent.taxonomies.includes(:categories, :sections)
.find_by(name: 'RCR').categories.map(&:sections).flatten .find_by(name: 'RCR').categories.map(&:sections).flatten
# Data from RCR are very groovy. You can find letters in phone numbers and other # Data from RCR are very groovy. You can find letters in phone numbers and other
# inconsistencies. Therefore we try our best to import everything in one go and # inconsistencies. Therefore we try our best to import everything in one go and
...@@ -39,7 +38,8 @@ def find_section_for(ent, sections) ...@@ -39,7 +38,8 @@ def find_section_for(ent, sections)
sections.find do |i| sections.find do |i|
i.name == if ent['type_initiative'] == 'potager' i.name == if ent['type_initiative'] == 'potager'
sections_by_initiative[:potager][ent['type_potager'].to_s.strip || 'unspecified'] typot = ent['type_potager'].to_s.strip || 'unspecified'
sections_by_initiative[:potager][typot]
else else
sections_by_initiative[ent['type_initiative']] sections_by_initiative[ent['type_initiative']]
end end
...@@ -175,7 +175,9 @@ entries['initiatives'].each do |ent| ...@@ -175,7 +175,9 @@ entries['initiatives'].each do |ent|
if res.valid? if res.valid?
sec = find_section_for(initiative, rcr) sec = find_section_for(initiative, rcr)
if sec.nil? if sec.nil?
res.meta['missing_section'] = initiative['type_initiative'] unless initiative.key?('type_potager') unless initiative.key?('type_potager')
res.meta['missing_section'] = initiative['type_initiative']
end
else else
res.sections << sec res.sections << sec
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment