Merge pull request #6522 from betagouv/main

This commit is contained in:
Pierre de La Morinerie 2021-10-05 12:30:27 +02:00 committed by GitHub
commit 7dc5f5ee59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 1461 additions and 1389 deletions

View file

@ -34,7 +34,7 @@ jobs:
${{ runner.os }}-yarn-
- name: Install packages
run: |
yarn install --pure-lockfile
yarn install --frozen-lockfile
- name: Run linters
run: |
@ -91,7 +91,7 @@ jobs:
${{ runner.os }}-yarn-
- name: Install packages
run: |
yarn install --pure-lockfile
yarn install --frozen-lockfile
- name: Setup test database
env:

9
.gitignore vendored
View file

@ -24,19 +24,14 @@ storage/
/public/packs
/public/packs-test
/node_modules
/yarn-error.log
yarn-debug.log*
.yarn-integrity
/.vscode
/.idea
/public/assets
/public/packs
/public/packs-test
/node_modules
vendor/*
/yarn-error.log
yarn-debug.log*
.yarn-integrity
/docs
# Local Netlify folder
.netlify

View file

@ -1,6 +1,7 @@
source 'https://rubygems.org'
gem 'aasm'
gem 'acsv'
gem 'active_link_to' # Automatically set a class on active links
gem 'active_model_serializers'
gem 'activestorage-openstack'

View file

@ -20,6 +20,7 @@ GEM
specs:
aasm (5.1.1)
concurrent-ruby (~> 1.0)
acsv (0.0.1)
actioncable (6.1.4.1)
actionpack (= 6.1.4.1)
activesupport (= 6.1.4.1)
@ -508,7 +509,7 @@ GEM
rack (>= 2.1.0)
rack-protection (2.1.0)
rack
rack-proxy (0.6.5)
rack-proxy (0.7.0)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
@ -663,7 +664,7 @@ GEM
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
semantic_range (2.3.1)
semantic_range (3.0.0)
sentry-delayed_job (4.4.0)
sentry-ruby-core (~> 4.4.0.pre.beta)
sentry-rails (4.4.0)
@ -760,7 +761,7 @@ GEM
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webpacker (5.2.1)
webpacker (5.4.3)
activesupport (>= 5.2)
rack-proxy (>= 0.6.1)
railties (>= 5.2)
@ -779,6 +780,7 @@ PLATFORMS
DEPENDENCIES
aasm
acsv
active_link_to
active_model_serializers
active_storage_validations

View file

@ -12,6 +12,11 @@
font-size: 18px;
font-weight: bold;
margin-bottom: $default-padding;
.highlighted {
font-size: 16px;
font-weight: normal;
}
}
.tab-list,

View file

@ -215,13 +215,13 @@ module NewAdministrateur
else
file = group_csv_file.read
base_encoding = CharlockHolmes::EncodingDetector.detect(file)
groupes_emails = CSV.new(file.encode("UTF-8", base_encoding[:encoding], invalid: :replace, replace: ""), headers: true, header_converters: :downcase)
groupes_emails = ACSV::CSV.new(file.encode("UTF-8", base_encoding[:encoding], invalid: :replace, replace: ""), headers: true, header_converters: :downcase)
.map { |r| r.to_h.slice('groupe', 'email') }
groupes_emails_has_keys = groupes_emails.first.has_key?("groupe") && groupes_emails.first.has_key?("email")
if groupes_emails_has_keys.blank?
flash[:alert] = "Importation impossible, veuillez importer un csv #{view_context.link_to('suivant ce modèle', "/import-groupe-test.csv")}"
flash[:alert] = "Importation impossible, veuillez importer un csv #{view_context.link_to('suivant ce modèle', "/csv/#{I18n.locale}/import-groupe-test.csv")}"
else
add_instructeurs_and_get_errors = InstructeursImportService.import(procedure, groupes_emails)

View file

@ -70,7 +70,7 @@ module Users
@dossier = dossier
if @dossier.individual.update(individual_params)
@dossier.update!(autorisation_donnees: true)
@dossier.update!(autorisation_donnees: true, identity_updated_at: Time.zone.now)
flash.notice = t('.identity_saved')
redirect_to brouillon_dossier_path(@dossier)

View file

@ -12,7 +12,10 @@ module Users
end
def destroy
transfer = DossierTransfer.find_by!(id: params[:id], dossiers: { user: current_user })
transfer = DossierTransfer
.joins(:dossiers)
.find_by!(id: params[:id], dossiers: { user: current_user })
transfer.destroy
redirect_to dossiers_path
end

View file

@ -1,6 +1,8 @@
class ExportJob < ApplicationJob
queue_as :exports
discard_on ActiveRecord::RecordNotFound
def perform(export)
export.compute
end

View file

@ -15,6 +15,7 @@
# en_instruction_at :datetime
# groupe_instructeur_updated_at :datetime
# hidden_at :datetime
# identity_updated_at :datetime
# last_avis_updated_at :datetime
# last_champ_private_updated_at :datetime
# last_champ_updated_at :datetime
@ -363,6 +364,7 @@ class Dossier < ApplicationRecord
scope :with_notifications, -> do
joins(:follows)
.where('last_champ_updated_at > follows.demande_seen_at' \
' OR identity_updated_at > follows.demande_seen_at' \
' OR groupe_instructeur_updated_at > follows.demande_seen_at' \
' OR last_champ_private_updated_at > follows.annotations_privees_seen_at' \
' OR last_avis_updated_at > follows.avis_seen_at' \

View file

@ -113,8 +113,10 @@ class Instructeur < ApplicationRecord
.find_by(instructeur: self, dossier: dossier)
if follow.present?
demande = follow.dossier.champs.updated_since?(follow.demande_seen_at).any? || follow.dossier.groupe_instructeur_updated_at&.>(follow.demande_seen_at)
demande = false if demande.nil?
demande = follow.dossier.champs.updated_since?(follow.demande_seen_at).any? ||
follow.dossier.groupe_instructeur_updated_at&.>(follow.demande_seen_at) ||
dossier.identity_updated_at&.>(follow.demande_seen_at) ||
false
annotations_privees = follow.dossier.champs_private.updated_since?(follow.annotations_privees_seen_at).any?

View file

@ -24,7 +24,7 @@
= label_tag "Importer par fichier CSV"
%p.notice Le fichier csv doit comporter 2 colonnes (Groupe, Email) et être séparé par des virgules. L'import n'écrase pas les groupes et les instructeurs existants.
%p.notice Le poids du fichier doit être inférieur à #{number_to_human_size(csv_max_size)}
%p.mt-2.mb-2= link_to "Télécharger l'exemple de fichier CSV", "/import-groupe-test.csv"
%p.mt-2.mb-2= link_to "Télécharger l'exemple de fichier CSV", "/csv/#{I18n.locale}/import-groupe-test.csv"
= file_field_tag :group_csv_file, required: true, accept: 'text/csv', size: "1"
= submit_tag "Importer le fichier", class: 'button primary send', data: { disable_with: "Envoi..." }

View file

@ -4,7 +4,7 @@
metadatas: ["Créée le #{@procedure.created_at.strftime('%d/%m/%Y')} - n° #{@procedure.id}", "#{@procedure.close? ? "Close le #{@procedure.closed_at.strftime('%d/%m/%Y')}" : @procedure.locked? ? "Publiée - #{procedure_lien(@procedure)}" : "Brouillon"}"] }
.container.procedure-admin-container
= link_to apercu_admin_procedure_path(@procedure), class: 'button', id: "preview-procedure" do
= link_to apercu_admin_procedure_path(@procedure), target: "_blank", rel: "noopener", class: 'button', id: "preview-procedure" do
%span.icon.preview
Prévisualiser

View file

@ -3,7 +3,14 @@
.card
= render partial: "shared/dossiers/infos_generales", locals: { dossier: dossier }
.tab-title= t('views.shared.dossiers.demande.requester_identity')
.tab-title
= t('views.shared.dossiers.demande.requester_identity')
- if dossier.identity_updated_at.present? && demande_seen_at&.<(dossier.identity_updated_at)
%span.highlighted
modifié le
= try_format_datetime(dossier.identity_updated_at)
.card
- if dossier.france_connect_information.present?
= render partial: "shared/dossiers/france_connect_informations", locals: { user_information: dossier.france_connect_information }

View file

@ -1,9 +1,9 @@
module.exports = function(api) {
var validEnv = ['development', 'test', 'production'];
var currentEnv = api.env();
var isDevelopmentEnv = api.env('development');
var isProductionEnv = api.env('production');
var isTestEnv = api.env('test');
var validEnv = ['development', 'test', 'production']
var currentEnv = api.env()
var isDevelopmentEnv = api.env('development')
var isProductionEnv = api.env('production')
var isTestEnv = api.env('test')
if (!validEnv.includes(currentEnv)) {
throw new Error(
@ -12,13 +12,13 @@ module.exports = function(api) {
'"test", and "production". Instead, received: ' +
JSON.stringify(currentEnv) +
'.'
);
)
}
return {
presets: [
isTestEnv && [
require('@babel/preset-env').default,
'@babel/preset-env',
{
targets: {
node: 'current'
@ -26,7 +26,7 @@ module.exports = function(api) {
}
],
(isProductionEnv || isDevelopmentEnv) && [
require('@babel/preset-env').default,
'@babel/preset-env',
{
forceAllTransforms: true,
useBuiltIns: 'usage',
@ -36,7 +36,7 @@ module.exports = function(api) {
}
],
[
require('@babel/preset-react').default,
'@babel/preset-react',
{
development: isDevelopmentEnv || isTestEnv,
useBuiltIns: true
@ -44,41 +44,53 @@ module.exports = function(api) {
]
].filter(Boolean),
plugins: [
require('babel-plugin-macros'),
require('@babel/plugin-syntax-dynamic-import').default,
isTestEnv && require('babel-plugin-dynamic-import-node'),
require('@babel/plugin-transform-destructuring').default,
'babel-plugin-macros',
'@babel/plugin-syntax-dynamic-import',
isTestEnv && 'babel-plugin-dynamic-import-node',
'@babel/plugin-transform-destructuring',
[
require('@babel/plugin-proposal-class-properties').default,
'@babel/plugin-proposal-class-properties',
{
loose: true
}
],
[
require('@babel/plugin-proposal-object-rest-spread').default,
'@babel/plugin-proposal-object-rest-spread',
{
useBuiltIns: true
}
],
[
require('@babel/plugin-transform-runtime').default,
'@babel/plugin-proposal-private-methods',
{
loose: true
}
],
[
'@babel/plugin-proposal-private-property-in-object',
{
loose: true
}
],
[
'@babel/plugin-transform-runtime',
{
helpers: false,
regenerator: true
}
],
[
require('@babel/plugin-transform-regenerator').default,
'@babel/plugin-transform-regenerator',
{
async: false
}
],
isProductionEnv && [
require('babel-plugin-transform-react-remove-prop-types').default,
'babel-plugin-transform-react-remove-prop-types',
{
removeImport: true
}
]
].filter(Boolean)
};
};
}
}

View file

@ -1,15 +1,18 @@
#!/usr/bin/env ruby
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
ENV["NODE_ENV"] ||= ENV["NODE_ENV"] || "development"
ENV["NODE_ENV"] ||= "development"
require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require "rubygems"
require "bundler/setup"
require "webpacker"
require "webpacker/webpack_runner"
Webpacker::WebpackRunner.run(ARGV)
APP_ROOT = File.expand_path("..", __dir__)
Dir.chdir(APP_ROOT) do
Webpacker::WebpackRunner.run(ARGV)
end

View file

@ -1,15 +1,18 @@
#!/usr/bin/env ruby
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
ENV["NODE_ENV"] ||= ENV["NODE_ENV"] || "development"
ENV["NODE_ENV"] ||= "development"
require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require "rubygems"
require "bundler/setup"
require "webpacker"
require "webpacker/dev_server_runner"
Webpacker::DevServerRunner.run(ARGV)
APP_ROOT = File.expand_path("..", __dir__)
Dir.chdir(APP_ROOT) do
Webpacker::DevServerRunner.run(ARGV)
end

View file

@ -6,12 +6,11 @@ default: &default
public_root_path: public
public_output_path: packs
cache_path: tmp/cache/webpacker
check_yarn_integrity: false
webpack_compile_output: false
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
resolved_paths: []
additional_paths: []
# Reload manifest.json on all requests so we reload latest compiled packs
cache_manifest: false
@ -53,9 +52,6 @@ development:
<<: *default
compile: true
# Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
check_yarn_integrity: true
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
https: false
@ -70,6 +66,7 @@ development:
disable_host_check: true
use_local_ip: false
quiet: false
pretty: false
headers:
'Access-Control-Allow-Origin': '*'
watch_options:

View file

@ -0,0 +1,5 @@
class AddIdentityUpdatedAtToDossier < ActiveRecord::Migration[6.1]
def change
add_column :dossiers, :identity_updated_at, :datetime
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_09_23_083416) do
ActiveRecord::Schema.define(version: 2021_10_01_143403) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -316,6 +316,7 @@ ActiveRecord::Schema.define(version: 2021_09_23_083416) do
t.index "to_tsvector('french'::regconfig, (search_terms || private_search_terms))", name: "index_dossiers_on_search_terms_private_search_terms", using: :gin
t.index "to_tsvector('french'::regconfig, search_terms)", name: "index_dossiers_on_search_terms", using: :gin
t.bigint "dossier_transfer_id"
t.datetime "identity_updated_at"
t.index ["archived"], name: "index_dossiers_on_archived"
t.index ["dossier_transfer_id"], name: "index_dossiers_on_dossier_transfer_id"
t.index ["groupe_instructeur_id"], name: "index_dossiers_on_groupe_instructeur_id"

View file

@ -8,7 +8,7 @@
"@rails/actiontext": "^6.1.4-1",
"@rails/activestorage": "^6.1.4-1",
"@rails/ujs": "^6.1.4-1",
"@rails/webpacker": "5.1.1",
"@rails/webpacker": "5.4.3",
"@reach/combobox": "^0.13.0",
"@reach/slider": "^0.15.0",
"@reach/visually-hidden": "^0.15.2",
@ -39,6 +39,8 @@
"react_ujs": "^2.6.1",
"trix": "^1.2.3",
"use-debounce": "^5.2.0",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12",
"whatwg-fetch": "^3.0.0"
},
"devDependencies": {
@ -52,7 +54,7 @@
"netlify-cli": "^2.61.2",
"prettier": "^2.3.2",
"webpack-bundle-analyzer": "^3.7.0",
"webpack-dev-server": "^3.11.0"
"webpack-dev-server": "^3"
},
"scripts": {
"lint:js": "eslint --ext .js,.jsx,.ts,.tsx ./app/javascript ./config/webpack",

View file

@ -9,4 +9,4 @@ module.exports = {
stage: 3
})
]
};
}

View file

@ -0,0 +1,5 @@
Email;Groupe
camilia@gouv.fr;Nord
kara@gouv.fr;Finistère
simon@gouv.fr;Isère
pauline@gouv.fr;Bouches-du-Rhône
1 Email Groupe
2 camilia@gouv.fr Nord
3 kara@gouv.fr Finistère
4 simon@gouv.fr Isère
5 pauline@gouv.fr Bouches-du-Rhône

View file

@ -418,7 +418,7 @@ describe NewAdministrateur::GroupeInstructeursController, type: :controller do
before { subject }
it { expect(flash.alert).to be_present }
it { expect(flash.alert).to eq("Importation impossible, veuillez importer un csv <a href=\"/import-groupe-test.csv\">suivant ce modèle</a>") }
it { expect(flash.alert).to eq("Importation impossible, veuillez importer un csv <a href=\"/csv/#{I18n.locale}/import-groupe-test.csv\">suivant ce modèle</a>") }
end
end

View file

@ -151,12 +151,15 @@ describe Users::DossiersController, type: :controller do
describe 'update_identite' do
let(:procedure) { create(:procedure, :for_individual) }
let(:dossier) { create(:dossier, user: user, procedure: procedure) }
let(:now) { Time.zone.parse('01/01/2100') }
subject { post :update_identite, params: { id: dossier.id, individual: individual_params } }
before do
sign_in(user)
subject
Timecop.freeze(now) do
subject
end
end
context 'with correct individual and dossier params' do
@ -164,6 +167,7 @@ describe Users::DossiersController, type: :controller do
it do
expect(response).to redirect_to(brouillon_dossier_path(dossier))
expect(dossier.reload.identity_updated_at).to eq(now)
end
end

View file

@ -0,0 +1,16 @@
describe Users::TransfersController, type: :controller do
let(:user) { create(:user) }
let(:dossier) { create(:dossier, user: user) }
before { sign_in(user) }
describe 'DELETE destroy' do
let(:dossier_transfert) { DossierTransfer.initiate(user.email, [dossier]) }
before do
delete :destroy, params: { id: dossier_transfert.id }
end
it { expect { dossier_transfert.reload }.to raise_error(ActiveRecord::RecordNotFound) }
end
end

View file

@ -77,10 +77,11 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
click_on Procedure.last.libelle
find('#preview-procedure').click
expect(page).to have_current_path(apercu_admin_procedure_path(Procedure.last))
expect(page).to have_field('libelle de champ')
preview_window = window_opened_by { find('#preview-procedure').click }
within_window(preview_window) do
expect(page).to have_current_path(apercu_admin_procedure_path(Procedure.last))
expect(page).to have_field('libelle de champ')
end
end
scenario 'After adding champ and file, make publication' do

View file

@ -16,6 +16,7 @@ feature 'The user' do
fill_in('date', with: '12-12-2012')
select_date_and_time(Time.zone.parse('06/01/2030 7h05'), form_id_for_datetime('datetime'))
fill_in('number', with: '42')
find_field('checkbox').scroll_to(:center)
check('checkbox')
choose('Madame')
fill_in('email', with: 'loulou@yopmail.com')

View file

@ -221,6 +221,12 @@ describe Instructeur, type: :model do
it { is_expected.to match({ demande: true, annotations_privees: false, avis: false, messagerie: false }) }
end
context 'when there is a modification on identity' do
before { dossier.update(identity_updated_at: Time.zone.now) }
it { is_expected.to match({ demande: true, annotations_privees: false, avis: false, messagerie: false }) }
end
context 'when there is a modification on groupe instructeur' do
let(:groupe_instructeur) { create(:groupe_instructeur, instructeurs: [instructeur], procedure: dossier.procedure) }
before { dossier.assign_to_groupe_instructeur(groupe_instructeur) }
@ -257,9 +263,9 @@ describe Instructeur, type: :model do
describe '#notifications_for_groupe_instructeurs' do
# one procedure, one group, 2 instructeurs
let(:procedure) { create(:simple_procedure, :routee, :with_type_de_champ_private) }
let(:procedure) { create(:simple_procedure, :routee, :with_type_de_champ_private, :for_individual) }
let(:gi_p1) { procedure.groupe_instructeurs.last }
let!(:dossier) { create(:dossier, :followed, groupe_instructeur: gi_p1, state: Dossier.states.fetch(:en_construction)) }
let!(:dossier) { create(:dossier, :with_individual, :followed, groupe_instructeur: gi_p1, state: Dossier.states.fetch(:en_construction)) }
let(:instructeur) { dossier.follows.first.instructeur }
let!(:instructeur_2) { create(:instructeur, groupe_instructeurs: [gi_p1]) }
@ -339,6 +345,17 @@ describe Instructeur, type: :model do
it { is_expected.to match([dossier.id]) }
end
context 'the identity' do
context 'when there is a modification on the identity' do
before do
dossier.update!(identity_updated_at: Time.zone.now)
follow.update_attribute('demande_seen_at', seen_at_instructeur)
end
it { is_expected.to match([dossier.id]) }
end
end
context 'the messagerie' do
context 'when there is a new commentaire' do
before do

2636
yarn.lock

File diff suppressed because it is too large Load diff