commit
e831fd4e5a
9 changed files with 88 additions and 34 deletions
|
@ -154,7 +154,7 @@ GEM
|
|||
mimemagic (~> 0.3)
|
||||
nokogiri (~> 1.10, >= 1.10.4)
|
||||
rubyzip (>= 1.3.0, < 3)
|
||||
chartkick (3.3.1)
|
||||
chartkick (3.4.0)
|
||||
childprocess (3.0.0)
|
||||
chunky_png (1.3.11)
|
||||
clamav-client (3.2.0)
|
||||
|
|
|
@ -56,4 +56,12 @@ module ChampHelper
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def datetime_start_year(date)
|
||||
if date == nil || date.year == 0 || date.year >= Date.today.year - 1
|
||||
Date.today.year - 1
|
||||
else
|
||||
date.year
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -58,7 +58,7 @@ class Procedure < ApplicationRecord
|
|||
|
||||
has_many :types_de_champ, -> { root.public_only.ordered }, inverse_of: :procedure, dependent: :destroy
|
||||
has_many :types_de_champ_private, -> { root.private_only.ordered }, class_name: 'TypeDeChamp', inverse_of: :procedure, dependent: :destroy
|
||||
has_many :revisions, class_name: 'ProcedureRevision', inverse_of: :procedure, dependent: :destroy
|
||||
has_many :revisions, -> { order(:id) }, class_name: 'ProcedureRevision', inverse_of: :procedure, dependent: :destroy
|
||||
belongs_to :draft_revision, class_name: 'ProcedureRevision', optional: true
|
||||
belongs_to :published_revision, class_name: 'ProcedureRevision', optional: true
|
||||
has_many :deleted_dossiers, dependent: :destroy
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- parsed_value = champ.value.present? ? Time.zone.parse(champ.value) : nil
|
||||
|
||||
.datetime
|
||||
= form.datetime_select(:value, selected: parsed_value, start_year: 1950, end_year: 2100, minute_step: 5, include_blank: true)
|
||||
= form.datetime_select(:value, selected: parsed_value, start_year: datetime_start_year(parsed_value), end_year: Date.today.year + 50, minute_step: 5, include_blank: true)
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
def domains_for_stage(stage)
|
||||
case stage
|
||||
when 'dev'
|
||||
['web1.dev', 'web2.dev']
|
||||
when 'prod'
|
||||
['web1', 'web2', 'web3', 'web4']
|
||||
def domains_for_stage
|
||||
if ENV['DOMAINS'].present?
|
||||
ENV['DOMAINS'].split
|
||||
else
|
||||
raise "STAGE #{stage} is unknown. It must be either dev or prod."
|
||||
raise "DOMAINS is empty. It must be something like DOMAINS='web1.dev web2.dev'"
|
||||
end
|
||||
end
|
||||
|
||||
task :setup do
|
||||
domains = domains_for_stage(ENV.fetch('STAGE'))
|
||||
domains = domains_for_stage
|
||||
|
||||
domains.each do |domain|
|
||||
sh "mina setup domain=#{domain}"
|
||||
|
@ -18,7 +15,7 @@ task :setup do
|
|||
end
|
||||
|
||||
task :deploy do
|
||||
domains = domains_for_stage(ENV.fetch('STAGE'))
|
||||
domains = domains_for_stage
|
||||
branch = ENV.fetch('BRANCH')
|
||||
|
||||
domains.each do |domain|
|
||||
|
@ -27,14 +24,14 @@ task :deploy do
|
|||
end
|
||||
|
||||
task :post_deploy do
|
||||
domains = domains_for_stage(ENV.fetch('STAGE'))
|
||||
domains = domains_for_stage
|
||||
branch = ENV.fetch('BRANCH')
|
||||
|
||||
sh "mina post_deploy domain=#{domains.first} branch=#{branch}"
|
||||
end
|
||||
|
||||
task :rollback do
|
||||
domains = domains_for_stage(ENV.fetch('STAGE'))
|
||||
domains = domains_for_stage
|
||||
branch = ENV.fetch('BRANCH')
|
||||
|
||||
domains.each do |domain|
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: fix_geo_areas_geometry'
|
||||
task fix_geo_areas_geometry: :environment do
|
||||
puts "Running deploy task 'fix_geo_areas_geometry'"
|
||||
|
||||
geometry_collections = GeoArea.where("geometry -> 'type' = '\"GeometryCollection\"'")
|
||||
multi_polygons = GeoArea.where("geometry -> 'type' = '\"MultiPolygon\"'")
|
||||
|
||||
def valid_geometry?(geometry)
|
||||
RGeo::GeoJSON.decode(geometry.to_json, geo_factory: RGeo::Geographic.simple_mercator_factory)
|
||||
true
|
||||
rescue
|
||||
false
|
||||
end
|
||||
|
||||
progress = ProgressReport.new(geometry_collections.count)
|
||||
geometry_collections.find_each do |geometry_collection|
|
||||
geometry_collection.geometry['geometries'].each do |geometry|
|
||||
if valid_geometry?(geometry)
|
||||
geometry_collection.champ.geo_areas.create!(geometry: geometry, source: 'selection_utilisateur')
|
||||
end
|
||||
end
|
||||
|
||||
geometry_collection.destroy
|
||||
progress.inc
|
||||
end
|
||||
progress.finish
|
||||
|
||||
progress = ProgressReport.new(multi_polygons.count)
|
||||
multi_polygons.find_each do |multi_polygon|
|
||||
multi_polygon.geometry['coordinates'].each do |coordinates|
|
||||
geometry = {
|
||||
type: 'Polygon',
|
||||
coordinates: coordinates
|
||||
}
|
||||
|
||||
if valid_geometry?(geometry)
|
||||
multi_polygon.champ.geo_areas.create!(geometry: geometry, source: 'selection_utilisateur')
|
||||
end
|
||||
end
|
||||
|
||||
multi_polygon.destroy
|
||||
progress.inc
|
||||
end
|
||||
progress.finish
|
||||
|
||||
# Update task as completed. If you remove the line below, the task will
|
||||
# run with every deploy (or every time you call after_party:run).
|
||||
AfterParty::TaskRecord
|
||||
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
|
||||
end
|
||||
end
|
|
@ -48,7 +48,7 @@ FactoryBot.define do
|
|||
factory :simple_procedure do
|
||||
after(:build) do |procedure, _evaluator|
|
||||
procedure.for_individual = true
|
||||
procedure.types_de_champ << create(:type_de_champ, libelle: 'Texte obligatoire', mandatory: true)
|
||||
procedure.types_de_champ << build(:type_de_champ, libelle: 'Texte obligatoire', mandatory: true)
|
||||
procedure.path = generate(:published_path)
|
||||
procedure.publish!
|
||||
end
|
||||
|
@ -97,7 +97,7 @@ FactoryBot.define do
|
|||
|
||||
after(:build) do |procedure, evaluator|
|
||||
evaluator.types_de_champ_count.times do
|
||||
type_de_champ = create(:type_de_champ)
|
||||
type_de_champ = build(:type_de_champ)
|
||||
|
||||
procedure.types_de_champ << type_de_champ
|
||||
end
|
||||
|
@ -111,7 +111,7 @@ FactoryBot.define do
|
|||
|
||||
after(:build) do |procedure, evaluator|
|
||||
evaluator.types_de_champ_private_count.times do
|
||||
type_de_champ = create(:type_de_champ, :private)
|
||||
type_de_champ = build(:type_de_champ, :private)
|
||||
|
||||
procedure.types_de_champ_private << type_de_champ
|
||||
end
|
||||
|
@ -120,7 +120,7 @@ FactoryBot.define do
|
|||
|
||||
trait :with_type_de_champ_mandatory do
|
||||
after(:build) do |procedure, _evaluator|
|
||||
type_de_champ = create(:type_de_champ, mandatory: true)
|
||||
type_de_champ = build(:type_de_champ, mandatory: true)
|
||||
|
||||
procedure.types_de_champ << type_de_champ
|
||||
end
|
||||
|
@ -128,7 +128,7 @@ FactoryBot.define do
|
|||
|
||||
trait :with_datetime do
|
||||
after(:build) do |procedure, _evaluator|
|
||||
type_de_champ = create(:type_de_champ_datetime, mandatory: true)
|
||||
type_de_champ = build(:type_de_champ_datetime, mandatory: true)
|
||||
|
||||
procedure.types_de_champ << type_de_champ
|
||||
end
|
||||
|
@ -136,7 +136,7 @@ FactoryBot.define do
|
|||
|
||||
trait :with_dossier_link do
|
||||
after(:build) do |procedure, _evaluator|
|
||||
type_de_champ = create(:type_de_champ_dossier_link)
|
||||
type_de_champ = build(:type_de_champ_dossier_link)
|
||||
|
||||
procedure.types_de_champ << type_de_champ
|
||||
end
|
||||
|
@ -144,7 +144,7 @@ FactoryBot.define do
|
|||
|
||||
trait :with_yes_no do
|
||||
after(:build) do |procedure, _evaluator|
|
||||
type_de_champ = create(:type_de_champ_yes_no)
|
||||
type_de_champ = build(:type_de_champ_yes_no)
|
||||
|
||||
procedure.types_de_champ << type_de_champ
|
||||
end
|
||||
|
@ -152,23 +152,24 @@ FactoryBot.define do
|
|||
|
||||
trait :with_piece_justificative do
|
||||
after(:build) do |procedure, _evaluator|
|
||||
type_de_champ = create(:type_de_champ_piece_justificative)
|
||||
type_de_champ = build(:type_de_champ_piece_justificative)
|
||||
|
||||
procedure.types_de_champ << type_de_champ
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_repetition do
|
||||
after(:build) do |procedure, _evaluator|
|
||||
type_de_champ = create(:type_de_champ_repetition)
|
||||
type_de_champ = build(:type_de_champ_repetition)
|
||||
procedure.types_de_champ << type_de_champ
|
||||
|
||||
type_de_champ.types_de_champ << create(:type_de_champ, libelle: 'sub type de champ')
|
||||
type_de_champ.types_de_champ << build(:type_de_champ, libelle: 'sub type de champ')
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_number do
|
||||
after(:build) do |procedure, _evaluator|
|
||||
type_de_champ = create(:type_de_champ_number)
|
||||
type_de_champ = build(:type_de_champ_number)
|
||||
|
||||
procedure.types_de_champ << type_de_champ
|
||||
end
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
FactoryBot.define do
|
||||
factory :type_de_champ do
|
||||
private { false }
|
||||
|
||||
# Previous line is kept blank so that rubocop does not complain
|
||||
sequence(:libelle) { |n| "Libelle du champ #{n}" }
|
||||
sequence(:description) { |n| "description du champ #{n}" }
|
||||
type_champ { TypeDeChamp.type_champs.fetch(:text) }
|
||||
order_place { 1 }
|
||||
mandatory { false }
|
||||
add_attribute(:private) { false }
|
||||
|
||||
factory :type_de_champ_text do
|
||||
type_champ { TypeDeChamp.type_champs.fetch(:text) }
|
||||
|
@ -117,9 +115,7 @@ FactoryBot.define do
|
|||
end
|
||||
|
||||
trait :private do
|
||||
private { true }
|
||||
|
||||
# Previous line is kept blank so that rubocop does not complain
|
||||
add_attribute(:private) { true }
|
||||
sequence(:libelle) { |n| "Libelle champ privé #{n}" }
|
||||
sequence(:description) { |n| "description du champ privé #{n}" }
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ feature 'The user' do
|
|||
fill_in('text', with: 'super texte')
|
||||
fill_in('textarea', with: 'super textarea')
|
||||
fill_in('date', with: '12-12-2012')
|
||||
select_date_and_time(Time.zone.parse('06/01/1985 7h05'), form_id_for_datetime('datetime'))
|
||||
select_date_and_time(Time.zone.parse('06/01/2030 7h05'), form_id_for_datetime('datetime'))
|
||||
fill_in('number', with: '42')
|
||||
check('checkbox')
|
||||
choose('Madame')
|
||||
|
@ -50,7 +50,7 @@ feature 'The user' do
|
|||
expect(champ_value_for('text')).to eq('super texte')
|
||||
expect(champ_value_for('textarea')).to eq('super textarea')
|
||||
expect(champ_value_for('date')).to eq('2012-12-12')
|
||||
expect(champ_value_for('datetime')).to eq('06/01/1985 07:05')
|
||||
expect(champ_value_for('datetime')).to eq('06/01/2030 07:05')
|
||||
expect(champ_value_for('number')).to eq('42')
|
||||
expect(champ_value_for('checkbox')).to eq('on')
|
||||
expect(champ_value_for('civilite')).to eq('Mme')
|
||||
|
@ -74,7 +74,7 @@ feature 'The user' do
|
|||
expect(page).to have_field('text', with: 'super texte')
|
||||
expect(page).to have_field('textarea', with: 'super textarea')
|
||||
expect(page).to have_field('date', with: '2012-12-12')
|
||||
check_date_and_time(Time.zone.parse('06/01/1985 7:05'), form_id_for_datetime('datetime'))
|
||||
check_date_and_time(Time.zone.parse('06/01/2030 7:05'), form_id_for_datetime('datetime'))
|
||||
expect(page).to have_field('number', with: '42')
|
||||
expect(page).to have_checked_field('checkbox')
|
||||
expect(page).to have_checked_field('Madame')
|
||||
|
|
Loading…
Reference in a new issue