Merge pull request #4318 from betagouv/dev

2019-09-16-01
This commit is contained in:
Nicolas Bouilleaud 2019-09-16 15:24:22 +02:00 committed by GitHub
commit 5382ec7220
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
336 changed files with 798 additions and 3186 deletions

View file

@ -4,6 +4,7 @@ require:
AllCops: AllCops:
Exclude: Exclude:
- "db/schema.rb" - "db/schema.rb"
- "db/migrate/20190730153555_recreate_structure.rb"
- "bin/*" - "bin/*"
- "node_modules/**/*" - "node_modules/**/*"
@ -866,7 +867,14 @@ Style/ClassVars:
Enabled: false Enabled: false
Style/CollectionMethods: Style/CollectionMethods:
Enabled: false PreferredMethods:
collect: map
collect!: map!
inject: reduce
detect: find
select: filter
find_all: filter
Enabled: true
Style/ColonMethodCall: Style/ColonMethodCall:
Enabled: true Enabled: true

View file

@ -189,10 +189,10 @@ GEM
delayed_job (> 2.0.3) delayed_job (> 2.0.3)
rack-protection (>= 1.5.5) rack-protection (>= 1.5.5)
sinatra (>= 1.4.4) sinatra (>= 1.4.4)
devise (4.6.1) devise (4.7.1)
bcrypt (~> 3.0) bcrypt (~> 3.0)
orm_adapter (~> 0.1) orm_adapter (~> 0.1)
railties (>= 4.1.0, < 6.0) railties (>= 4.1.0)
responders responders
warden (~> 1.2.3) warden (~> 1.2.3)
devise-async (1.0.0) devise-async (1.0.0)
@ -440,7 +440,7 @@ GEM
puma (3.12.0) puma (3.12.0)
pundit (2.0.1) pundit (2.0.1)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
rack (2.0.6) rack (2.0.7)
rack-attack (6.0.0) rack-attack (6.0.0)
rack (>= 1.0, < 3) rack (>= 1.0, < 3)
rack-mini-profiler (1.0.1) rack-mini-profiler (1.0.1)
@ -477,7 +477,7 @@ GEM
rails-dom-testing (2.0.3) rails-dom-testing (2.0.3)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
nokogiri (>= 1.6) nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4) rails-html-sanitizer (1.2.0)
loofah (~> 2.2, >= 2.2.2) loofah (~> 2.2, >= 2.2.2)
rails-i18n (5.1.2) rails-i18n (5.1.2)
i18n (>= 0.7, < 2) i18n (>= 0.7, < 2)
@ -489,7 +489,7 @@ GEM
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0) thor (>= 0.19.0, < 2.0)
rainbow (3.0.0) rainbow (3.0.0)
rake (12.3.2) rake (12.3.3)
rake-progressbar (0.0.5) rake-progressbar (0.0.5)
rb-fsevent (0.10.3) rb-fsevent (0.10.3)
rb-inotify (0.10.0) rb-inotify (0.10.0)
@ -503,9 +503,9 @@ GEM
regexp_parser (1.3.0) regexp_parser (1.3.0)
request_store (1.4.1) request_store (1.4.1)
rack (>= 1.4) rack (>= 1.4)
responders (2.4.1) responders (3.0.0)
actionpack (>= 4.2.0, < 6.0) actionpack (>= 5.0)
railties (>= 4.2.0, < 6.0) railties (>= 5.0)
rest-client (2.0.2) rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0) http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0) mime-types (>= 1.16, < 4.0)

View file

@ -36,7 +36,7 @@ module CreateAvisConcern
if failed.any? if failed.any?
flash.now.alert = failed flash.now.alert = failed
.select { |avis| avis.errors.present? } .filter { |avis| avis.errors.present? }
.map { |avis| "#{avis.email} : #{avis.errors.full_messages.join(', ')}" } .map { |avis| "#{avis.email} : #{avis.errors.full_messages.join(', ')}" }
# When an error occurs, return the avis back to the controller # When an error occurs, return the avis back to the controller

View file

@ -76,7 +76,7 @@ module Instructeurs
if @current_filters.count > 0 if @current_filters.count > 0
filtered_ids = procedure_presentation.filtered_ids(@dossiers, statut) filtered_ids = procedure_presentation.filtered_ids(@dossiers, statut)
filtered_sorted_ids = sorted_ids.select { |id| filtered_ids.include?(id) } filtered_sorted_ids = sorted_ids.filter { |id| filtered_ids.include?(id) }
else else
filtered_sorted_ids = sorted_ids filtered_sorted_ids = sorted_ids
end end

View file

@ -24,11 +24,11 @@ class RootController < ApplicationController
.map.with_index { |type_de_champ, i| type_de_champ.champ.build(id: i) } .map.with_index { |type_de_champ, i| type_de_champ.champ.build(id: i) }
all_champs all_champs
.select { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:header_section) } .filter { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:header_section) }
.each { |champ| champ.type_de_champ.libelle = 'un super titre de section' } .each { |champ| champ.type_de_champ.libelle = 'un super titre de section' }
all_champs all_champs
.select { |champ| [TypeDeChamp.type_champs.fetch(:drop_down_list), TypeDeChamp.type_champs.fetch(:multiple_drop_down_list)].include?(champ.type_champ) } .filter { |champ| [TypeDeChamp.type_champs.fetch(:drop_down_list), TypeDeChamp.type_champs.fetch(:multiple_drop_down_list)].include?(champ.type_champ) }
.each do |champ| .each do |champ|
champ.type_de_champ.drop_down_list = DropDownList.new(type_de_champ: champ.type_de_champ) champ.type_de_champ.drop_down_list = DropDownList.new(type_de_champ: champ.type_de_champ)
champ.drop_down_list.value = champ.drop_down_list.value =
@ -47,7 +47,7 @@ class RootController < ApplicationController
type_champ_values.each do |(type_champ, value)| type_champ_values.each do |(type_champ, value)|
all_champs all_champs
.select { |champ| champ.type_champ == type_champ } .filter { |champ| champ.type_champ == type_champ }
.each { |champ| champ.value = value } .each { |champ| champ.value = value }
end end

View file

@ -356,7 +356,7 @@ class StatsController < ApplicationController
if weekly_dossiers_count == 0 if weekly_dossiers_count == 0
result = 0 result = 0
else else
weekly_dossier_with_avis_count = weekly_dossiers.select { |dossier| dossier.avis.present? }.count weekly_dossier_with_avis_count = weekly_dossiers.filter { |dossier| dossier.avis.present? }.count
result = percentage(weekly_dossier_with_avis_count, weekly_dossiers_count) result = percentage(weekly_dossier_with_avis_count, weekly_dossiers_count)
end end

View file

@ -6,7 +6,7 @@ module Users
.includes(:procedure) .includes(:procedure)
.map(&:procedure) .map(&:procedure)
.uniq .uniq
.select(&:publiee?) .filter(&:publiee?)
@popular_demarches = Procedure @popular_demarches = Procedure
.includes(:service) .includes(:service)

View file

@ -54,6 +54,10 @@ class Champ < ApplicationRecord
value value
end end
def for_tag
value.present? ? value.to_s : ''
end
def main_value_name def main_value_name
:value :value
end end

View file

@ -2,19 +2,19 @@ class Champs::CarteChamp < Champ
# We are not using scopes here as we want to access # We are not using scopes here as we want to access
# the following collections on unsaved records. # the following collections on unsaved records.
def cadastres def cadastres
geo_areas.select do |area| geo_areas.filter do |area|
area.source == GeoArea.sources.fetch(:cadastre) area.source == GeoArea.sources.fetch(:cadastre)
end end
end end
def quartiers_prioritaires def quartiers_prioritaires
geo_areas.select do |area| geo_areas.filter do |area|
area.source == GeoArea.sources.fetch(:quartier_prioritaire) area.source == GeoArea.sources.fetch(:quartier_prioritaire)
end end
end end
def parcelles_agricoles def parcelles_agricoles
geo_areas.select do |area| geo_areas.filter do |area|
area.source == GeoArea.sources.fetch(:parcelle_agricole) area.source == GeoArea.sources.fetch(:parcelle_agricole)
end end
end end

View file

@ -9,6 +9,10 @@ class Champs::DateChamp < Champ
value.present? ? I18n.l(Date.parse(value)) : "" value.present? ? I18n.l(Date.parse(value)) : ""
end end
def for_tag
value.present? ? I18n.l(Date.parse(value)) : ""
end
private private
def format_before_save def format_before_save

View file

@ -9,6 +9,10 @@ class Champs::DatetimeChamp < Champ
value.present? ? I18n.l(Time.zone.parse(value)) : "" value.present? ? I18n.l(Time.zone.parse(value)) : ""
end end
def for_tag
value.present? ? I18n.l(Time.zone.parse(value)) : ""
end
private private
def format_before_save def format_before_save

View file

@ -30,7 +30,11 @@ class Champs::LinkedDropDownListChamp < Champ
end end
def to_s def to_s
value.present? ? [primary_value, secondary_value].select(&:present?).join(' / ') : "" value.present? ? [primary_value, secondary_value].filter(&:present?).join(' / ') : ""
end
def for_tag
value.present? ? [primary_value, secondary_value].filter(&:present?).join(' / ') : ""
end end
def for_export def for_export

View file

@ -13,6 +13,10 @@ class Champs::MultipleDropDownListChamp < Champ
selected_options.join(', ') selected_options.join(', ')
end end
def for_tag
selected_options.join(', ')
end
def for_export def for_export
value.present? ? selected_options.join(', ') : nil value.present? ? selected_options.join(', ') : nil
end end

View file

@ -4,6 +4,6 @@ class Champs::PaysChamp < Champs::TextChamp
end end
def self.disabled_options def self.disabled_options
pays.select { |v| (v =~ /^--.*--$/).present? } pays.filter { |v| (v =~ /^--.*--$/).present? }
end end
end end

View file

@ -19,6 +19,14 @@ class Champs::RepetitionChamp < Champ
# The user cannot enter any information here so it doesnt make much sense to search # The user cannot enter any information here so it doesnt make much sense to search
end end
def for_tag
([libelle] + rows.map do |champs|
champs.map do |champ|
"#{champ.libelle} : #{champ}"
end.join("\n")
end).join("\n\n")
end
def rows_for_export def rows_for_export
rows.each.with_index(1).map do |champs, index| rows.each.with_index(1).map do |champs, index|
Champs::RepetitionChamp::Row.new(index: index, dossier_id: dossier_id.to_s, champs: champs) Champs::RepetitionChamp::Row.new(index: index, dossier_id: dossier_id.to_s, champs: champs)

View file

@ -9,6 +9,10 @@ class Champs::YesNoChamp < Champ
processed_value processed_value
end end
def for_tag
processed_value
end
def for_export def for_export
processed_value processed_value
end end

View file

@ -179,7 +179,7 @@ module TagsSubstitutionConcern
raise NameError.new("The class #{self.class.name} includes TagsSubstitutionConcern, it should define the DOSSIER_STATE constant but it does not", :DOSSIER_STATE) raise NameError.new("The class #{self.class.name} includes TagsSubstitutionConcern, it should define the DOSSIER_STATE constant but it does not", :DOSSIER_STATE)
end end
tags.select { |tag| tag[:available_for_states].include?(self.class::DOSSIER_STATE) } tags.filter { |tag| tag[:available_for_states].include?(self.class::DOSSIER_STATE) }
end end
def champ_public_tags def champ_public_tags
@ -213,12 +213,12 @@ module TagsSubstitutionConcern
tags_and_datas tags_and_datas
.map { |(tags, data)| [filter_tags(tags), data] } .map { |(tags, data)| [filter_tags(tags), data] }
.inject(text) { |acc, (tags, data)| replace_tags_with_values_from_data(acc, tags, data) } .reduce(text) { |acc, (tags, data)| replace_tags_with_values_from_data(acc, tags, data) }
end end
def replace_tags_with_values_from_data(text, tags, data) def replace_tags_with_values_from_data(text, tags, data)
if data.present? if data.present?
tags.inject(text) do |acc, tag| tags.reduce(text) do |acc, tag|
replace_tag(acc, tag, data) replace_tag(acc, tag, data)
end end
else else

View file

@ -426,15 +426,15 @@ class Dossier < ApplicationRecord
end end
def check_mandatory_champs def check_mandatory_champs
(champs + champs.select(&:repetition?).flat_map(&:champs)) (champs + champs.filter(&:repetition?).flat_map(&:champs))
.select(&:mandatory_and_blank?) .filter(&:mandatory_and_blank?)
.map do |champ| .map do |champ|
"Le champ #{champ.libelle.truncate(200)} doit être rempli." "Le champ #{champ.libelle.truncate(200)} doit être rempli."
end end
end end
def modifier_annotations!(instructeur) def modifier_annotations!(instructeur)
champs_private.select(&:value_previously_changed?).each do |champ| champs_private.filter(&:value_previously_changed?).each do |champ|
log_dossier_operation(instructeur, :modifier_annotation, champ) log_dossier_operation(instructeur, :modifier_annotation, champ)
end end
end end

View file

@ -9,7 +9,7 @@ class DropDownList < ApplicationRecord
end end
def disabled_options def disabled_options
options.select { |v| (v =~ /^--.*--$/).present? } options.filter { |v| (v =~ /^--.*--$/).present? }
end end
def multiple def multiple

View file

@ -74,7 +74,7 @@ class Instructeur < ApplicationRecord
active_procedure_overviews = procedures active_procedure_overviews = procedures
.publiees .publiees
.map { |procedure| procedure.procedure_overview(start_date) } .map { |procedure| procedure.procedure_overview(start_date) }
.select(&:had_some_activities?) .filter(&:had_some_activities?)
if active_procedure_overviews.count == 0 if active_procedure_overviews.count == 0
nil nil

View file

@ -30,7 +30,7 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
description: "#{description} (menu primaire)", description: "#{description} (menu primaire)",
lambda: -> (champs) { lambda: -> (champs) {
champs champs
.detect { |champ| champ.type_de_champ == tdc } .find { |champ| champ.type_de_champ == tdc }
&.primary_value &.primary_value
} }
} }
@ -41,7 +41,7 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
description: "#{description} (menu secondaire)", description: "#{description} (menu secondaire)",
lambda: -> (champs) { lambda: -> (champs) {
champs champs
.detect { |champ| champ.type_de_champ == tdc } .find { |champ| champ.type_de_champ == tdc }
&.secondary_value &.secondary_value
} }
} }

View file

@ -14,7 +14,7 @@ class TypesDeChamp::TypeDeChampBase
libelle: libelle, libelle: libelle,
description: description, description: description,
lambda: -> (champs) { lambda: -> (champs) {
champs.detect { |champ| champ.type_de_champ == tdc } champs.find { |champ| champ.type_de_champ == tdc }&.for_tag
} }
} }
] ]

View file

@ -39,7 +39,7 @@ class AdministrateurUsageStatisticsService
ds_nb_demarches_brouillons: nb_demarches_by_administrateur_id_and_state[[administrateur.id, "brouillon"]], ds_nb_demarches_brouillons: nb_demarches_by_administrateur_id_and_state[[administrateur.id, "brouillon"]],
nb_demarches_test: nb_dossiers_by_procedure_id nb_demarches_test: nb_dossiers_by_procedure_id
.select { |procedure_id, count| count > 0 && is_brouillon(procedure_id) } .filter { |procedure_id, count| count > 0 && is_brouillon(procedure_id) }
.count, .count,
nb_demarches_prod: nb_dossiers_by_procedure_id nb_demarches_prod: nb_dossiers_by_procedure_id
.reject { |procedure_id, count| count == 0 || is_brouillon(procedure_id) } .reject { |procedure_id, count| count == 0 || is_brouillon(procedure_id) }

View file

@ -1,7 +1,7 @@
class PiecesJustificativesService class PiecesJustificativesService
def self.liste_pieces_justificatives(dossier) def self.liste_pieces_justificatives(dossier)
champs_blocs_repetables = dossier.champs champs_blocs_repetables = dossier.champs
.select { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:repetition) } .filter { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:repetition) }
.flat_map(&:champs) .flat_map(&:champs)
champs_pieces_justificatives_with_attachments( champs_pieces_justificatives_with_attachments(
@ -15,7 +15,7 @@ class PiecesJustificativesService
end end
def self.serialize_types_de_champ_as_type_pj(procedure) def self.serialize_types_de_champ_as_type_pj(procedure)
tdcs = procedure.types_de_champ.select { |type_champ| type_champ.old_pj.present? } tdcs = procedure.types_de_champ.filter { |type_champ| type_champ.old_pj.present? }
tdcs.map.with_index do |type_champ, order_place| tdcs.map.with_index do |type_champ, order_place|
description = type_champ.description description = type_champ.description
if /^(?<original_description>.*?)(?:[\r\n]+)Récupérer le formulaire vierge pour mon dossier : (?<lien_demarche>http.*)$/m =~ description if /^(?<original_description>.*?)(?:[\r\n]+)Récupérer le formulaire vierge pour mon dossier : (?<lien_demarche>http.*)$/m =~ description
@ -32,7 +32,7 @@ class PiecesJustificativesService
end end
def self.serialize_champs_as_pjs(dossier) def self.serialize_champs_as_pjs(dossier)
dossier.champs.select { |champ| champ.type_de_champ.old_pj }.map do |champ| dossier.champs.filter { |champ| champ.type_de_champ.old_pj }.map do |champ|
{ {
created_at: champ.created_at&.in_time_zone('UTC'), created_at: champ.created_at&.in_time_zone('UTC'),
type_de_piece_justificative_id: champ.type_de_champ.old_pj[:stable_id], type_de_piece_justificative_id: champ.type_de_champ.old_pj[:stable_id],
@ -46,7 +46,7 @@ class PiecesJustificativesService
def self.champs_pieces_justificatives_with_attachments(champs) def self.champs_pieces_justificatives_with_attachments(champs)
champs champs
.select { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative) } .filter { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative) }
.filter { |pj| pj.piece_justificative_file.attached? } .filter { |pj| pj.piece_justificative_file.attached? }
end end
end end

View file

@ -122,7 +122,7 @@ class ProcedureExportService
@etablissements = @dossiers.flat_map do |dossier| @etablissements = @dossiers.flat_map do |dossier|
[dossier.champs, dossier.champs_private] [dossier.champs, dossier.champs_private]
.flatten .flatten
.select { |champ| champ.is_a?(Champs::SiretChamp) } .filter { |champ| champ.is_a?(Champs::SiretChamp) }
end.map(&:etablissement).compact end.map(&:etablissement).compact
if @etablissements.any? if @etablissements.any?

View file

@ -40,7 +40,7 @@ class ProcedureExportV2Service
@etablissements ||= dossiers.flat_map do |dossier| @etablissements ||= dossiers.flat_map do |dossier|
[dossier.champs, dossier.champs_private] [dossier.champs, dossier.champs_private]
.flatten .flatten
.select { |champ| champ.is_a?(Champs::SiretChamp) } .filter { |champ| champ.is_a?(Champs::SiretChamp) }
end.map(&:etablissement).compact + dossiers.map(&:etablissement).compact end.map(&:etablissement).compact + dossiers.map(&:etablissement).compact
end end
@ -52,7 +52,7 @@ class ProcedureExportV2Service
@champs_repetables ||= dossiers.flat_map do |dossier| @champs_repetables ||= dossiers.flat_map do |dossier|
[dossier.champs, dossier.champs_private] [dossier.champs, dossier.champs_private]
.flatten .flatten
.select { |champ| champ.is_a?(Champs::RepetitionChamp) } .filter { |champ| champ.is_a?(Champs::RepetitionChamp) }
end.group_by(&:libelle) end.group_by(&:libelle)
end end

View file

@ -7,7 +7,7 @@ class ZxcvbnService
wxcvbn = compute_zxcvbn wxcvbn = compute_zxcvbn
score = wxcvbn.score score = wxcvbn.score
length = @password.blank? ? 0 : @password.length length = @password.blank? ? 0 : @password.length
vulnerabilities = wxcvbn.match_sequence.map { |m| m.matched_word.nil? ? m.token : m.matched_word }.select { |s| s.length > 2 }.join(', ') vulnerabilities = wxcvbn.match_sequence.map { |m| m.matched_word.nil? ? m.token : m.matched_word }.filter { |s| s.length > 2 }.join(', ')
[score, vulnerabilities, length] [score, vulnerabilities, length]
end end

View file

@ -16,14 +16,12 @@ end
# this will immediately migrate the default features to be controlled. # this will immediately migrate the default features to be controlled.
def setup_features(features) def setup_features(features)
features.each do |feature| features.each do |feature|
if Flipper.exist?(feature) if !Flipper.exist?(feature)
return
end
# Disable feature by default # Disable feature by default
Flipper.disable(feature) Flipper.disable(feature)
end end
end end
end
# A list of features to be deployed on first push # A list of features to be deployed on first push
features = [ features = [
@ -39,8 +37,15 @@ features = [
:xray :xray
] ]
def database_exists?
ActiveRecord::Base.connection
true
rescue ActiveRecord::NoDatabaseError
false
end
ActiveSupport.on_load(:active_record) do ActiveSupport.on_load(:active_record) do
if ActiveRecord::Base.connection.data_source_exists? 'flipper_features' if database_exists? && ActiveRecord::Base.connection.data_source_exists?('flipper_features')
setup_features(features) setup_features(features)
end end
end end

View file

@ -1,7 +0,0 @@
class CreateDossiers < ActiveRecord::Migration
def change
create_table :dossiers do |t|
t.string :description
end
end
end

View file

@ -1,19 +0,0 @@
class CreateEntreprise < ActiveRecord::Migration
def change
create_table :entreprises do |t|
t.string :siren
t.integer :capital_social
t.string :numero_tva_intracommunautaire
t.string :forme_juridique
t.string :forme_juridique_code
t.string :nom_commercial
t.string :raison_sociale
t.string :siret_siege_social
t.string :code_effectif_entreprise
t.integer :date_creation
t.string :nom
t.string :prenom
end
add_reference :entreprises, :dossier, references: :dossiers
end
end

View file

@ -1,20 +0,0 @@
class CreateEtablissements < ActiveRecord::Migration
def change
create_table :etablissements do |t|
t.string :siret
t.boolean :siege_social
t.string :naf
t.string :libelle_naf
t.string :adresse
t.string :numero_voie
t.string :type_voie
t.string :nom_voie
t.string :complement_adresse
t.string :code_postal
t.string :localite
t.string :code_insee_localite
end
add_reference :etablissements, :dossier, references: :dossiers
add_reference :etablissements, :entreprise, references: :entreprises
end
end

View file

@ -1,5 +0,0 @@
class AddAutorisationDonneesToDossiers < ActiveRecord::Migration
def change
add_column :dossiers, :autorisation_donnees, :boolean
end
end

View file

@ -1,6 +0,0 @@
class AddPositionToDossiers < ActiveRecord::Migration
def change
add_column :dossiers, :position_lat, :string
add_column :dossiers, :position_lon, :string
end
end

View file

@ -1,5 +0,0 @@
class AddRefDossierToDossiers < ActiveRecord::Migration
def change
add_column :dossiers, :ref_dossier, :string
end
end

View file

@ -1,8 +0,0 @@
class CreateDossierPdfs < ActiveRecord::Migration
def change
create_table :dossier_pdfs do |t|
t.string :ref_dossier_pdf
end
add_reference :dossier_pdfs, :dossier, references: :dossiers
end
end

View file

@ -1,10 +0,0 @@
class AddDetailsProjetToDossiers < ActiveRecord::Migration
def change
add_column :dossiers, :nom_projet, :string
add_column :dossiers, :montant_projet, :string
add_column :dossiers, :montant_aide_demande, :string
add_column :dossiers, :date_previsionnelle, :string
add_column :dossiers, :lien_plus_infos, :string
add_column :dossiers, :mail_contact, :string
end
end

View file

@ -1,41 +0,0 @@
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
t.timestamps
end
add_index :users, :email, unique: true
add_index :users, :reset_password_token, unique: true
# add_index :users, :confirmation_token, unique: true
# add_index :users, :unlock_token, unique: true
end
end

View file

@ -1,41 +0,0 @@
class DeviseCreatePros < ActiveRecord::Migration
def change
create_table(:pros) do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
t.timestamps
end
add_index :pros, :email, unique: true
add_index :pros, :reset_password_token, unique: true
# add_index :pros, :confirmation_token, unique: true
# add_index :pros, :unlock_token, unique: true
end
end

View file

@ -1,13 +0,0 @@
class CreateCommentaires < ActiveRecord::Migration
def change
create_table :commentaires do |t|
t.string :email
t.date :created_at
t.string :body
t.references :dossier, index: true
t.timestamps null: false
end
add_foreign_key :commentaires, :dossiers
end
end

View file

@ -1,5 +0,0 @@
class AddDossierTermineToDossiers < ActiveRecord::Migration
def change
add_column :dossiers, :dossier_termine, :boolean
end
end

View file

@ -1,9 +0,0 @@
class CreateEvenementVies < ActiveRecord::Migration
def change
create_table :evenement_vies do |t|
t.string :nom
t.timestamps null: false
end
end
end

View file

@ -1,5 +0,0 @@
class AddUseAdmiFacileToEvenementVie < ActiveRecord::Migration
def change
add_column :evenement_vies, :use_admi_facile, :boolean
end
end

View file

@ -1,17 +0,0 @@
class CreateRefPiecesJointes < ActiveRecord::Migration
def change
create_table :ref_pieces_jointes do |t|
t.string :CERFA
t.string :nature
t.string :libelle_complet
t.string :etablissement
t.string :libelle
t.string :description
t.string :demarche
t.string :administration_emetrice
t.boolean :api_entreprise
t.timestamps null: false
end
end
end

View file

@ -1,21 +0,0 @@
class CreateRefFormulaires < ActiveRecord::Migration
def change
create_table :ref_formulaires do |t|
t.string :ref_demarche
t.string :nom
t.string :objet
t.string :ministere
t.string :cigle_ministere
t.string :direction
t.string :evenement_vie
t.string :publics
t.string :lien_demarche
t.string :lien_fiche_signaletique
t.string :lien_notice
t.string :categorie
t.boolean :mail_pj
t.timestamps null: false
end
end
end

View file

@ -1,5 +0,0 @@
class AddUseAdmiFacileToRefFormulaire < ActiveRecord::Migration
def change
add_column :ref_formulaires, :use_admi_facile, :boolean
end
end

View file

@ -1,5 +0,0 @@
class AddRefFormulaireToDossier < ActiveRecord::Migration
def change
add_column :dossiers, :ref_formulaire, :string
end
end

View file

@ -1,5 +0,0 @@
class AddRefPiecesJointesRefToDossierPdf < ActiveRecord::Migration
def change
add_reference :dossier_pdfs, :ref_pieces_jointes, index: true
end
end

View file

@ -1,6 +0,0 @@
class FixRefFormulaireToDossier < ActiveRecord::Migration
def change
remove_column :dossiers, :ref_formulaire, :integer
add_reference :dossiers, :ref_formulaire, index: true
end
end

View file

@ -1,5 +0,0 @@
class RenameRefDossierPdfIntoContent < ActiveRecord::Migration
def change
rename_column :dossier_pdfs, :ref_dossier_pdf, :content
end
end

View file

@ -1,5 +0,0 @@
class RenameDossierPdfintofPieceJointe < ActiveRecord::Migration
def change
rename_table :dossier_pdfs, :pieces_jointes
end
end

View file

@ -1,6 +0,0 @@
class RenameRefPieceJointToTypePieceJointe < ActiveRecord::Migration
def change
rename_table :ref_pieces_jointes, :types_piece_jointe
rename_column :pieces_jointes, :ref_pieces_jointes_id, :type_piece_jointe_id
end
end

View file

@ -1,6 +0,0 @@
class RenameRefFormulaireIntoFormulaire < ActiveRecord::Migration
def change
rename_table :ref_formulaires, :formulaires
rename_column :dossiers, :ref_formulaire_id, :formulaire_id
end
end

View file

@ -1,5 +0,0 @@
class AddFormulaireIdToTypePieceJointe < ActiveRecord::Migration
def change
add_column :types_piece_jointe, :formulaire_id, :integer
end
end

View file

@ -1,5 +0,0 @@
class RenameRefDemarcheIntoDemarcheId < ActiveRecord::Migration
def change
rename_column :formulaires, :ref_demarche, :demarche_id
end
end

View file

@ -1,8 +0,0 @@
class LinkTypePieceJointeToFormulaire < ActiveRecord::Migration
# def up
# TypePieceJointe.find_each do |type_piece_jointe|
# forms = Formulaire.find_by_demarche_id(type_piece_jointe.CERFA)
# type_piece_jointe.update(formulaire_id: forms.id) if forms.present?
# end
# end
end

View file

@ -1,5 +0,0 @@
class RenameEvenementVieFromDemarcheIntoEvenementVieId < ActiveRecord::Migration
def change
rename_column :formulaires, :evenement_vie, :evenement_vie_id
end
end

View file

@ -1,9 +0,0 @@
class CreateCerfas < ActiveRecord::Migration
def change
create_table :cerfas do |t|
t.string :content
t.references :dossier, index: true
end
add_foreign_key :cerfas, :dossiers
end
end

View file

@ -1,6 +0,0 @@
class ChangeDatePrevisionnelDataType < ActiveRecord::Migration
def change
remove_column :dossiers, :date_previsionnelle
add_column :dossiers, :date_previsionnelle, :date
end
end

View file

@ -1,5 +0,0 @@
class AddEmailContactToFormulaire < ActiveRecord::Migration
def change
add_column :formulaires, :email_contact, :string
end
end

View file

@ -1,41 +0,0 @@
class DeviseCreateGestionnaires < ActiveRecord::Migration
def change
create_table(:gestionnaires) do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
t.timestamps
end
add_index :gestionnaires, :email, unique: true
add_index :gestionnaires, :reset_password_token, unique: true
# add_index :gestionnaires, :confirmation_token, unique: true
# add_index :gestionnaires, :unlock_token, unique: true
end
end

View file

@ -1,5 +0,0 @@
class DropEvenementViesTable < ActiveRecord::Migration
def change
drop_table :evenement_vies
end
end

View file

@ -1,20 +0,0 @@
class RenameTableFormulaireToProcedure < ActiveRecord::Migration
def change
remove_column :formulaires, :demarche_id
remove_column :formulaires, :cigle_ministere
remove_column :formulaires, :evenement_vie_id
remove_column :formulaires, :publics
remove_column :formulaires, :lien_fiche_signaletique
remove_column :formulaires, :lien_notice
remove_column :formulaires, :categorie
remove_column :formulaires, :mail_pj
remove_column :formulaires, :email_contact
rename_column :formulaires, :nom, :libelle
rename_column :formulaires, :objet, :description
rename_column :formulaires, :ministere, :organisation
rename_column :formulaires, :use_admi_facile, :test
rename_table :formulaires, :procedures
end
end

View file

@ -1,5 +0,0 @@
class RenamePieceJointeToPieceJustificatives < ActiveRecord::Migration
def change
rename_table :pieces_jointes, :pieces_justificatives
end
end

View file

@ -1,16 +0,0 @@
class RenameTypesPieceJointeToTypesDePieceJustificative < ActiveRecord::Migration
def change
remove_column :types_piece_jointe, :CERFA
remove_column :types_piece_jointe, :nature
remove_column :types_piece_jointe, :libelle_complet
remove_column :types_piece_jointe, :etablissement
remove_column :types_piece_jointe, :demarche
remove_column :types_piece_jointe, :administration_emetrice
rename_column :types_piece_jointe, :formulaire_id, :procedure_id
rename_table :types_piece_jointe, :types_de_piece_justificative
rename_column :pieces_justificatives, :type_piece_jointe_id, :type_de_piece_justificative_id
end
end

View file

@ -1,5 +0,0 @@
class RenameFormulaireIdToProcedureId < ActiveRecord::Migration
def change
rename_column :dossiers, :formulaire_id, :procedure_id
end
end

View file

@ -1,5 +0,0 @@
class DeleteTableUsers < ActiveRecord::Migration
def change
drop_table :users
end
end

View file

@ -1,5 +0,0 @@
class DropTablePros < ActiveRecord::Migration
def change
drop_table :pros
end
end

View file

@ -1,6 +0,0 @@
class AddTimeStampToDossier < ActiveRecord::Migration
def change
add_column :dossiers, :created_at, :datetime, default: Time.zone.now
add_column :dossiers, :updated_at, :datetime, default: Time.zone.now
end
end

View file

@ -1,5 +0,0 @@
class DefaultAPIEntrepriseAtFalseToTypeDePieceJustificative < ActiveRecord::Migration
def change
change_column :types_de_piece_justificative, :api_entreprise, :boolean, :default => false
end
end

View file

@ -1,8 +0,0 @@
class ChangeAttributsToDossier < ActiveRecord::Migration
def change
remove_column :dossiers, :lien_plus_infos
remove_column :dossiers, :mail_contact
rename_column :dossiers, :ref_dossier, :ref_dossier_carto
end
end

View file

@ -1,6 +0,0 @@
class AddStateToDossier < ActiveRecord::Migration
def change
remove_column :dossiers, :dossier_termine
add_column :dossiers, :state, :string
end
end

View file

@ -1,41 +0,0 @@
class CreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
t.timestamps
end
add_index :users, :email, unique: true
add_index :users, :reset_password_token, unique: true
# add_index :users, :confirmation_token, unique: true
# add_index :users, :unlock_token, unique: true
end
end

View file

@ -1,6 +0,0 @@
class AddUserToDossier < ActiveRecord::Migration
def change
add_reference :dossiers, :user, index: true
add_foreign_key :dossiers, :users
end
end

View file

@ -1,5 +0,0 @@
class AddUseAPICartoToProcedure < ActiveRecord::Migration
def change
add_column :procedures, :use_api_carto, :boolean, :default => false
end
end

View file

@ -1,5 +0,0 @@
class AddSiretToUser < ActiveRecord::Migration
def change
add_column :users, :siret, :string
end
end

View file

@ -1,5 +0,0 @@
class AddLoginWithFranceConnectToUser < ActiveRecord::Migration
def change
add_column :users, :login_with_france_connect, :boolean, :default => false
end
end

View file

@ -1,5 +0,0 @@
class RenameLoginWithFranceConnectToLogedInWithFranceConnect < ActiveRecord::Migration
def change
rename_column :users, :login_with_france_connect, :loged_in_with_france_connect
end
end

View file

@ -1,41 +0,0 @@
class DeviseCreateAdministrateurs < ActiveRecord::Migration
def change
create_table(:administrateurs) do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
t.timestamps
end
add_index :administrateurs, :email, unique: true
add_index :administrateurs, :reset_password_token, unique: true
# add_index :administrateurs, :confirmation_token, unique: true
# add_index :administrateurs, :unlock_token, unique: true
end
end

View file

@ -1,11 +0,0 @@
class CreateTypesDeChamps < ActiveRecord::Migration
def change
create_table :types_de_champs do |t|
t.string :libelle
t.string :type
t.integer :order_place
t.belongs_to :procedure
end
end
end

View file

@ -1,6 +0,0 @@
class ChangeAttributsToTypeDeChamps < ActiveRecord::Migration
def change
rename_column :types_de_champs, :type, :type_champs
add_column :types_de_champs, :description, :text
end
end

View file

@ -1,5 +0,0 @@
class ChangeStateProposedToSubmitted < ActiveRecord::Migration
def change
Dossier.where(state: 'proposed').update_all(state: 'submitted')
end
end

View file

@ -1,5 +0,0 @@
class ChangeStatereplyToReplied < ActiveRecord::Migration
def change
Dossier.where(state: 'reply').update_all(state: 'replied')
end
end

View file

@ -1,5 +0,0 @@
class ChangeStateConfirmedToValidated < ActiveRecord::Migration
def change
Dossier.where(state: 'confirmed').update_all(state: 'validated')
end
end

View file

@ -1,5 +0,0 @@
class ChangeStateDepositedToSubmitValidate < ActiveRecord::Migration
def change
Dossier.where(state: 'deposited').update_all(state: 'submit_validated')
end
end

View file

@ -1,5 +0,0 @@
class ChangeStateProcessedToClosed < ActiveRecord::Migration
def change
Dossier.where(state: 'processed').update_all(state: 'closed')
end
end

View file

@ -1,5 +0,0 @@
class ChangeStateSubmittedToInitiated < ActiveRecord::Migration
def change
Dossier.where(state: 'submitted').update_all(state: 'initiated')
end
end

View file

@ -1,5 +0,0 @@
class ChangeStateSubmitValidatedToSubmitted < ActiveRecord::Migration
def change
Dossier.where(state: 'submit_validated').update_all(state: 'submitted')
end
end

View file

@ -1,11 +0,0 @@
class DeleteAttributsToDossier < ActiveRecord::Migration
def change
remove_column :dossiers, :montant_projet
remove_column :dossiers, :montant_aide_demande
remove_column :dossiers, :date_previsionnelle
remove_column :dossiers, :position_lat
remove_column :dossiers, :position_lon
remove_column :dossiers, :ref_dossier_carto
end
end

View file

@ -1,9 +0,0 @@
class CreateChamps < ActiveRecord::Migration
def change
create_table :champs do |t|
t.string :value
end
add_reference :champs, :type_de_champs, references: :types_de_champs
add_reference :champs, :dossier, references: :dossiers
end
end

View file

@ -1,5 +0,0 @@
class RenameTypeDeChampsToTypeDeChamp < ActiveRecord::Migration
def change
rename_table :types_de_champs, :types_de_champ
end
end

View file

@ -1,5 +0,0 @@
class RenameTypeDeChampsIdToTypeDeChampIdOnChamp < ActiveRecord::Migration
def change
rename_column :champs, :type_de_champs_id, :type_de_champ_id
end
end

View file

@ -1,5 +0,0 @@
class CreateReferenceAdmninistrateurToProcedure < ActiveRecord::Migration
def change
add_reference :procedures, :administrateur, references: :procedures
end
end

View file

@ -1,5 +0,0 @@
class CreateReferenceAdmninistrateurToGestionnaire < ActiveRecord::Migration
def change
add_reference :gestionnaires, :administrateur, references: :gestionnaires
end
end

View file

@ -1,5 +0,0 @@
class AddJsonLatLngsToDossier < ActiveRecord::Migration
def change
add_column :dossiers, :json_latlngs, :text
end
end

View file

@ -1,11 +0,0 @@
class CreateExerciceTable < ActiveRecord::Migration
def change
create_table :exercices do |t|
t.string :ca
t.datetime :dateFinExercice
t.integer :date_fin_exercice_timestamp
end
add_reference :exercices, :etablissement, references: :etablissements
end
end

View file

@ -1,5 +0,0 @@
class RenameTypeChampsIntoTypeChamp < ActiveRecord::Migration
def change
rename_column :types_de_champ, :type_champs, :type_champ
end
end

View file

@ -1,12 +0,0 @@
class CreateQuartierPrioritaire < ActiveRecord::Migration
def change
create_table :quartier_prioritaires do |t|
t.string :code
t.string :nom
t.string :commune
t.text :geometry
end
add_reference :quartier_prioritaires, :dossier, references: :dossiers
end
end

View file

@ -1,5 +0,0 @@
class AddArchivedToProcedure < ActiveRecord::Migration
def change
add_column :procedures, :archived, :boolean, default: false
end
end

View file

@ -1,5 +0,0 @@
class AddArchivedToDossier < ActiveRecord::Migration
def change
add_column :dossiers, :archived, :boolean, default: false
end
end

View file

@ -1,9 +0,0 @@
class CreateModuleAPICarto < ActiveRecord::Migration
def change
create_table :module_api_cartos do |t|
t.string :name
end
add_reference :module_api_cartos, :procedure, references: :procedures
end
end

Some files were not shown because too many files have changed in this diff Show more