Merge branch 'dev'
This commit is contained in:
commit
584309cdbe
8 changed files with 87 additions and 70 deletions
|
@ -32,7 +32,7 @@ class Users::CarteController < UsersController
|
||||||
@dossier = current_user_dossier
|
@dossier = current_user_dossier
|
||||||
@data = {}
|
@data = {}
|
||||||
|
|
||||||
geo_json = JSON.parse(params.required(:selection))
|
geo_json = JSON.parse(params.fetch(:selection, '[]'))
|
||||||
|
|
||||||
if geo_json.first == ["error", "TooManyPolygons"]
|
if geo_json.first == ["error", "TooManyPolygons"]
|
||||||
@error = true
|
@error = true
|
||||||
|
|
|
@ -126,7 +126,7 @@ class Gestionnaire < ApplicationRecord
|
||||||
procedure.dossiers.not_archived
|
procedure.dossiers.not_archived
|
||||||
else
|
else
|
||||||
procedure.dossiers.en_cours
|
procedure.dossiers.en_cours
|
||||||
end.followed_by(self)
|
end
|
||||||
|
|
||||||
dossiers_id_with_notifications(dossiers)
|
dossiers_id_with_notifications(dossiers)
|
||||||
end
|
end
|
||||||
|
@ -139,35 +139,14 @@ class Gestionnaire < ApplicationRecord
|
||||||
Dossier.not_archived
|
Dossier.not_archived
|
||||||
else
|
else
|
||||||
Dossier.en_cours
|
Dossier.en_cours
|
||||||
end.followed_by(self)
|
end
|
||||||
|
|
||||||
Dossier.where(id: dossiers_id_with_notifications(dossiers)).group(:procedure_id).count
|
Dossier.where(id: dossiers_id_with_notifications(dossiers)).group(:procedure_id).count
|
||||||
end
|
end
|
||||||
|
|
||||||
def mark_tab_as_seen(dossier, tab)
|
|
||||||
attributes = {}
|
|
||||||
attributes["#{tab}_seen_at"] = DateTime.now
|
|
||||||
Follow.where(gestionnaire: self, dossier: dossier).update_all(attributes)
|
|
||||||
end
|
|
||||||
|
|
||||||
def invite!
|
|
||||||
reset_password_token = set_reset_password_token
|
|
||||||
|
|
||||||
GestionnaireMailer.invite_gestionnaire(self, reset_password_token).deliver_later
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def annotations_hash(demande, annotations_privees, avis, messagerie)
|
|
||||||
{
|
|
||||||
demande: demande,
|
|
||||||
annotations_privees: annotations_privees,
|
|
||||||
avis: avis,
|
|
||||||
messagerie: messagerie
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def dossiers_id_with_notifications(dossiers)
|
def dossiers_id_with_notifications(dossiers)
|
||||||
|
dossiers = dossiers.followed_by(self)
|
||||||
|
|
||||||
updated_demandes = dossiers
|
updated_demandes = dossiers
|
||||||
.joins(:champs)
|
.joins(:champs)
|
||||||
.where('champs.updated_at > follows.demande_seen_at')
|
.where('champs.updated_at > follows.demande_seen_at')
|
||||||
|
@ -198,4 +177,27 @@ class Gestionnaire < ApplicationRecord
|
||||||
updated_messagerie
|
updated_messagerie
|
||||||
].flat_map { |query| query.distinct.ids }.uniq
|
].flat_map { |query| query.distinct.ids }.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mark_tab_as_seen(dossier, tab)
|
||||||
|
attributes = {}
|
||||||
|
attributes["#{tab}_seen_at"] = DateTime.now
|
||||||
|
Follow.where(gestionnaire: self, dossier: dossier).update_all(attributes)
|
||||||
|
end
|
||||||
|
|
||||||
|
def invite!
|
||||||
|
reset_password_token = set_reset_password_token
|
||||||
|
|
||||||
|
GestionnaireMailer.invite_gestionnaire(self, reset_password_token).deliver_later
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def annotations_hash(demande, annotations_privees, avis, messagerie)
|
||||||
|
{
|
||||||
|
demande: demande,
|
||||||
|
annotations_privees: annotations_privees,
|
||||||
|
avis: avis,
|
||||||
|
messagerie: messagerie
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -78,7 +78,7 @@ class ProcedurePresentation < ApplicationRecord
|
||||||
|
|
||||||
case table
|
case table
|
||||||
when 'notifications'
|
when 'notifications'
|
||||||
dossiers_id_with_notification = gestionnaire.notifications_for_procedure(procedure)
|
dossiers_id_with_notification = gestionnaire.dossiers_id_with_notifications(dossiers)
|
||||||
if order == 'desc'
|
if order == 'desc'
|
||||||
return dossiers_id_with_notification +
|
return dossiers_id_with_notification +
|
||||||
(dossiers.order('dossiers.updated_at desc').ids - dossiers_id_with_notification)
|
(dossiers.order('dossiers.updated_at desc').ids - dossiers_id_with_notification)
|
||||||
|
|
|
@ -39,11 +39,13 @@
|
||||||
|
|
||||||
- if Flipflop.web_hook?
|
- if Flipflop.web_hook?
|
||||||
.form-group
|
.form-group
|
||||||
%h4 Lien de rappel HTTP
|
%h4 Lien de rappel HTTP (webhook)
|
||||||
= f.text_field :web_hook_url, class: 'form-control', placeholder: 'https://callback.exemple.fr/'
|
= f.text_field :web_hook_url, class: 'form-control', placeholder: 'https://callback.exemple.fr/'
|
||||||
%p.help-block
|
%p.help-block
|
||||||
%i.fa.fa-info-circle
|
%i.fa.fa-info-circle
|
||||||
Un lien de rappel HTTP (aussi appelé webhook) est utilisé pour notifier un service tiers du changement de l'état d’un dossier sur demarches-simplifiees.fr. À chaque changement d’état d'un dossier, notre site va effectuer une requête sur le lien renseigné avec en paramètres : le nouvel état du dossier, l’identifiant de la démarche, l'identifiant dossier et la date du changement. Vous pourrez alors utiliser notre API pour récupérer les nouvelles informations du dossier concerné.
|
Vous pouvez définir un lien de rappel HTTP (aussi appelé webhook) pour notifier un service tiers du changement de l'état d’un dossier de cette démarche sur demarches-simplifiees.fr.
|
||||||
|
= link_to("Consulter la documentation du webhook", WEBHOOK_DOC_URL, target: "_blank")
|
||||||
|
\.
|
||||||
|
|
||||||
.form-group
|
.form-group
|
||||||
%h4 Cadre juridique *
|
%h4 Cadre juridique *
|
||||||
|
@ -51,7 +53,9 @@
|
||||||
%ul
|
%ul
|
||||||
%li Texte de loi (loi, décret, circulaire, arrêté,…)
|
%li Texte de loi (loi, décret, circulaire, arrêté,…)
|
||||||
%li Texte juridique (statuts, délibération, décision du conseil d'administration…)
|
%li Texte juridique (statuts, délibération, décision du conseil d'administration…)
|
||||||
%li <a href="https://doc.demarches-simplifiees.fr/tutoriels/tutoriel-administrateur#cadre-juridique" target="_blank">En savoir plus</a>
|
%li
|
||||||
|
= link_to("En savoir plus", CADRE_JURIDIQUE_URL, target: "_blank")
|
||||||
|
|
||||||
%p.help-block
|
%p.help-block
|
||||||
%i.fa.fa-info-circle
|
%i.fa.fa-info-circle
|
||||||
Vous pouvez saisir un lien vers ce texte ou importer celui-ci directement.
|
Vous pouvez saisir un lien vers ce texte ou importer celui-ci directement.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'mina/bundler'
|
require 'mina/bundler'
|
||||||
require 'mina/rails'
|
|
||||||
require 'mina/git'
|
require 'mina/git'
|
||||||
|
require 'mina/rails'
|
||||||
require 'mina/rbenv'
|
require 'mina/rbenv'
|
||||||
|
|
||||||
# Basic settings:
|
# Basic settings:
|
||||||
|
@ -12,42 +12,35 @@ require 'mina/rbenv'
|
||||||
# Advanced settings:
|
# Advanced settings:
|
||||||
# forward_agent - SSH forward_agent
|
# forward_agent - SSH forward_agent
|
||||||
# user - Username in the server to SSH to
|
# user - Username in the server to SSH to
|
||||||
|
# shared_dirs - Manually create these paths in shared/ on your server.
|
||||||
set :domain, ENV.fetch('domain')
|
|
||||||
set :repository, 'https://github.com/betagouv/tps.git'
|
|
||||||
deploy_to = '/var/www/ds'
|
|
||||||
set :deploy_to, deploy_to
|
|
||||||
set :user, 'ds'
|
|
||||||
set :branch, ENV.fetch('branch')
|
|
||||||
|
|
||||||
# Manually create these paths in shared/ (eg: shared/config/database.yml) in your server.
|
|
||||||
# They will be linked in the 'deploy:link_shared_paths' step.
|
# They will be linked in the 'deploy:link_shared_paths' step.
|
||||||
set :shared_dirs, [
|
|
||||||
|
deploy_to = '/var/www/ds'
|
||||||
|
shared_dirs = [
|
||||||
'log',
|
'log',
|
||||||
'sockets',
|
'sockets',
|
||||||
'tmp/pids',
|
'tmp/cache',
|
||||||
'tmp/cache'
|
'tmp/pids'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
set :domain, ENV.fetch('domain')
|
||||||
|
set :deploy_to, deploy_to
|
||||||
|
set :repository, 'https://github.com/betagouv/tps.git'
|
||||||
|
set :branch, ENV.fetch('branch')
|
||||||
|
set :forward_agent, true
|
||||||
|
set :user, 'ds'
|
||||||
|
set :shared_dirs, shared_dirs
|
||||||
set :rbenv_path, "/home/ds/.rbenv/bin/rbenv"
|
set :rbenv_path, "/home/ds/.rbenv/bin/rbenv"
|
||||||
set :forward_agent, true # SSH forward_agent.
|
|
||||||
|
|
||||||
puts "Deploy to #{ENV.fetch('domain')}, branch: #{ENV.fetch('branch')}"
|
puts "Deploy to #{ENV.fetch('domain')}, branch: #{ENV.fetch('branch')}"
|
||||||
|
|
||||||
# This task is the environment that is loaded for most commands, such as
|
# This task is the environment that is loaded for most commands, such as
|
||||||
# `mina deploy` or `mina rake`.
|
# `mina deploy` or `mina rake`.
|
||||||
task :setup do
|
task :setup do
|
||||||
command %[mkdir -p "#{deploy_to}/shared/log"]
|
shared_dirs.each do |dir|
|
||||||
command %[chmod g+rx,u+rwx "#{deploy_to}/shared/log"]
|
command %[mkdir -p "#{deploy_to}/shared/#{dir}"]
|
||||||
|
command %[chmod g+rx,u+rwx "#{deploy_to}/shared/#{dir}"]
|
||||||
command %[mkdir -p "#{deploy_to}/shared/tmp/pids"]
|
end
|
||||||
command %[chmod g+rx,u+rwx "#{deploy_to}/shared/tmp/pids"]
|
|
||||||
|
|
||||||
command %[mkdir -p "#{deploy_to}/shared/tmp/cache"]
|
|
||||||
command %[chmod g+rx,u+rwx "#{deploy_to}/shared/tmp/cache"]
|
|
||||||
|
|
||||||
command %[mkdir -p "#{deploy_to}/shared/sockets"]
|
|
||||||
command %[chmod g+rx,u+rwx "#{deploy_to}/shared/sockets"]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :yarn do
|
namespace :yarn do
|
||||||
|
@ -76,6 +69,12 @@ namespace :service do
|
||||||
command %{
|
command %{
|
||||||
echo "-----> Restarting puma service"
|
echo "-----> Restarting puma service"
|
||||||
#{echo_cmd %[sudo systemctl restart puma]}
|
#{echo_cmd %[sudo systemctl restart puma]}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Reload nginx"
|
||||||
|
task :reload_nginx do
|
||||||
|
command %{
|
||||||
echo "-----> Reloading nginx service"
|
echo "-----> Reloading nginx service"
|
||||||
#{echo_cmd %[sudo systemctl reload nginx]}
|
#{echo_cmd %[sudo systemctl reload nginx]}
|
||||||
}
|
}
|
||||||
|
@ -94,11 +93,12 @@ desc "Deploys the current version to the server."
|
||||||
task :deploy do
|
task :deploy do
|
||||||
command 'export PATH=$PATH:/home/ds/.rbenv/bin:/home/ds/.rbenv/shims'
|
command 'export PATH=$PATH:/home/ds/.rbenv/bin:/home/ds/.rbenv/shims'
|
||||||
command 'source /home/ds/.profile'
|
command 'source /home/ds/.profile'
|
||||||
|
|
||||||
deploy do
|
deploy do
|
||||||
# Put things that will set up an empty directory into a fully set-up
|
# Put things that will set up an empty directory into a fully set-up
|
||||||
# instance of your project.
|
# instance of your project.
|
||||||
invoke :'git:clone'
|
|
||||||
|
|
||||||
|
invoke :'git:clone'
|
||||||
invoke :'deploy:link_shared_paths'
|
invoke :'deploy:link_shared_paths'
|
||||||
invoke :'bundle:install'
|
invoke :'bundle:install'
|
||||||
invoke :'yarn:install'
|
invoke :'yarn:install'
|
||||||
|
@ -108,6 +108,7 @@ task :deploy do
|
||||||
|
|
||||||
on :launch do
|
on :launch do
|
||||||
invoke :'service:restart_puma'
|
invoke :'service:restart_puma'
|
||||||
|
invoke :'service:reload_nginx'
|
||||||
invoke :'service:restart_delayed_job'
|
invoke :'service:restart_delayed_job'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,11 +12,13 @@ FOG_BASE_URL = "https://storage.apientreprise.fr"
|
||||||
|
|
||||||
# External services URLs
|
# External services URLs
|
||||||
DOC_URL = "https://doc.demarches-simplifiees.fr"
|
DOC_URL = "https://doc.demarches-simplifiees.fr"
|
||||||
ADMINISTRATEUR_TUTORIAL_URL = "https://doc.demarches-simplifiees.fr/tutoriels/tutoriel-administrateur"
|
ADMINISTRATEUR_TUTORIAL_URL = [DOC_URL, "tutoriels", "tutoriel-administrateur"].join("/")
|
||||||
INSTRUCTEUR_TUTORIAL_URL = "https://doc.demarches-simplifiees.fr/tutoriels/tutoriel-accompagnateur"
|
INSTRUCTEUR_TUTORIAL_URL = [DOC_URL, "tutoriels", "tutoriel-accompagnateur"].join("/")
|
||||||
WEBINAIRE_URL = "https://doc.demarches-simplifiees.fr/pour-aller-plus-loin/webinaires"
|
CADRE_JURIDIQUE_URL = [ADMINISTRATEUR_TUTORIAL_URL, "cadre-juridique"].join("#")
|
||||||
|
WEBINAIRE_URL = [DOC_URL, "pour-aller-plus-loin", "webinaires"].join("/")
|
||||||
LISTE_DES_DEMARCHES_URL = [DOC_URL, "listes-des-demarches"].join("/")
|
LISTE_DES_DEMARCHES_URL = [DOC_URL, "listes-des-demarches"].join("/")
|
||||||
CGU_URL = [DOC_URL, "cgu"].join("/")
|
CGU_URL = [DOC_URL, "cgu"].join("/")
|
||||||
MENTIONS_LEGALES_URL = [CGU_URL, "4-mentions-legales"].join("#")
|
MENTIONS_LEGALES_URL = [CGU_URL, "4-mentions-legales"].join("#")
|
||||||
API_DOC_URL = [DOC_URL, "pour-aller-plus-loin", "api"].join("/")
|
API_DOC_URL = [DOC_URL, "pour-aller-plus-loin", "api"].join("/")
|
||||||
|
WEBHOOK_DOC_URL = [DOC_URL, "pour-aller-plus-loin", "webhook"].join("/")
|
||||||
FAQ_URL = "https://faq.demarches-simplifiees.fr"
|
FAQ_URL = "https://faq.demarches-simplifiees.fr"
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
def domains_from_env(env)
|
def domains_for_stage(stage)
|
||||||
case env
|
case stage
|
||||||
when 'dev'
|
when 'dev'
|
||||||
['web1.dev', 'web2.dev']
|
['web1.dev', 'web2.dev']
|
||||||
when 'prod'
|
when 'prod'
|
||||||
['web1', 'web2']
|
['web1', 'web2']
|
||||||
else
|
else
|
||||||
raise "STAGE #{env} is unknown. It must be either dev or prod"
|
raise "STAGE #{stage} is unknown. It must be either dev or prod."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
task :setup do
|
||||||
|
domains = domains_for_stage(ENV.fetch('STAGE'))
|
||||||
|
|
||||||
|
domains.each do |domain|
|
||||||
|
sh "mina setup domain=#{domain} force_asset_precompile=true"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task :deploy do
|
task :deploy do
|
||||||
domains = domains_from_env(ENV.fetch('STAGE'))
|
domains = domains_for_stage(ENV.fetch('STAGE'))
|
||||||
branch = ENV.fetch('BRANCH')
|
branch = ENV.fetch('BRANCH')
|
||||||
|
|
||||||
domains.each do |domain|
|
domains.each do |domain|
|
||||||
sh "mina deploy domain=#{domain} branch=#{branch} force_asset_precompile=true"
|
sh "mina deploy domain=#{domain} branch=#{branch} force_asset_precompile=true"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task :setup do
|
|
||||||
domains = domains_from_env(ENV['STAGE'])
|
|
||||||
|
|
||||||
domains.each do |domain|
|
|
||||||
sh "mina setup domain=#{domain} force_asset_precompile=true"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
@ -238,6 +238,7 @@ describe ProcedurePresentation do
|
||||||
before do
|
before do
|
||||||
notified_dossier.champs.first.touch(time: DateTime.new(2018, 9, 20))
|
notified_dossier.champs.first.touch(time: DateTime.new(2018, 9, 20))
|
||||||
create(:follow, gestionnaire: gestionnaire, dossier: notified_dossier, demande_seen_at: DateTime.new(2018, 9, 10))
|
create(:follow, gestionnaire: gestionnaire, dossier: notified_dossier, demande_seen_at: DateTime.new(2018, 9, 10))
|
||||||
|
notified_dossier.touch(time: DateTime.new(2018, 9, 20))
|
||||||
recent_dossier.touch(time: DateTime.new(2018, 9, 25))
|
recent_dossier.touch(time: DateTime.new(2018, 9, 25))
|
||||||
older_dossier.touch(time: DateTime.new(2018, 5, 13))
|
older_dossier.touch(time: DateTime.new(2018, 5, 13))
|
||||||
end
|
end
|
||||||
|
@ -253,6 +254,13 @@ describe ProcedurePresentation do
|
||||||
|
|
||||||
it { is_expected.to eq([notified_dossier, recent_dossier, older_dossier].map(&:id)) }
|
it { is_expected.to eq([notified_dossier, recent_dossier, older_dossier].map(&:id)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with a dossier terminé' do
|
||||||
|
let!(:notified_dossier) { create(:dossier, :accepte, procedure: procedure) }
|
||||||
|
let(:order) { 'desc' }
|
||||||
|
|
||||||
|
it { is_expected.to eq([notified_dossier, recent_dossier, older_dossier].map(&:id)) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for self table' do
|
context 'for self table' do
|
||||||
|
|
Loading…
Reference in a new issue