diff --git a/.gitignore b/.gitignore
index 308ee4352..b14ef0756 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,7 +23,6 @@
public/uploads
public/downloads
-bin/*
config/initializers/token.rb
config/initializers/super_admin.rb
doc/*.svg
diff --git a/app/assets/stylesheets/left_panel.scss b/app/assets/stylesheets/left_panel.scss
index 02658aab1..c594715a2 100644
--- a/app/assets/stylesheets/left_panel.scss
+++ b/app/assets/stylesheets/left_panel.scss
@@ -10,6 +10,14 @@
color: #FFFFFF;
overflow-y: scroll;
+ .link-to-dossiers {
+ padding: 15px 0 0 15px;
+
+ a {
+ color: #FFFFFF;
+ }
+ }
+
#first-block {
font-family: Arial;
font-size: 16px;
diff --git a/app/controllers/commentaires_controller.rb b/app/controllers/commentaires_controller.rb
index 920a64155..b22ada7eb 100644
--- a/app/controllers/commentaires_controller.rb
+++ b/app/controllers/commentaires_controller.rb
@@ -35,15 +35,12 @@ class CommentairesController < ApplicationController
end
@commentaire.body = params['texte_commentaire']
- saved = false
unless @commentaire.body.blank? && @commentaire.piece_justificative.nil?
- saved = @commentaire.save unless flash.alert
+ @commentaire.save unless flash.alert
else
flash.alert = "Veuillez rédiger un message ou ajouter une pièce jointe."
end
- notify_user_with_mail(@commentaire) if saved
-
if is_gestionnaire?
unless current_gestionnaire.follow? @commentaire.dossier
current_gestionnaire.toggle_follow_dossier @commentaire.dossier
@@ -63,10 +60,4 @@ class CommentairesController < ApplicationController
def is_gestionnaire?
false
end
-
- private
-
- def notify_user_with_mail(commentaire)
- NotificationMailer.new_answer(commentaire.dossier).deliver_now! unless current_user.try(:email) == commentaire.dossier.user.email
- end
end
diff --git a/app/decorators/entreprise_decorator.rb b/app/decorators/entreprise_decorator.rb
index 6db7236fe..155a76b0c 100644
--- a/app/decorators/entreprise_decorator.rb
+++ b/app/decorators/entreprise_decorator.rb
@@ -29,8 +29,4 @@ class EntrepriseDecorator < Draper::Decorator
def pretty_capital_social
h.number_to_currency(capital_social, delimiter: ' ', unit: '€', format: '%n %u')
end
-
- def pretty_date_creation
- Time.at(date_creation).strftime('%d-%m-%Y')
- end
end
diff --git a/app/facades/dossiers_list_facades.rb b/app/facades/dossiers_list_facades.rb
index 016d007d8..0a05a4148 100644
--- a/app/facades/dossiers_list_facades.rb
+++ b/app/facades/dossiers_list_facades.rb
@@ -18,7 +18,7 @@ class DossiersListFacades
end
def total_dossier_follow
- @current_devise_profil.dossiers_follow.count
+ @current_devise_profil.followed_dossiers.count
end
def total_new_dossier
@@ -30,7 +30,7 @@ class DossiersListFacades
end
def gestionnaire_procedures_name_and_id_list
- @current_devise_profil.procedures.order('libelle ASC').inject([]) { |acc, procedure| acc.push({id: procedure.id, libelle: procedure.libelle, unread_notifications: @current_devise_profil.dossier_with_notification_for(procedure)}) }
+ @current_devise_profil.procedures.order('libelle ASC').inject([]) { |acc, procedure| acc.push({id: procedure.id, libelle: procedure.libelle, unread_notifications: @current_devise_profil.dossiers_with_notifications_count_for_procedure(procedure)}) }
end
def unread_notifications
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
index 68533b7dd..8730c2d2e 100644
--- a/app/mailers/application_mailer.rb
+++ b/app/mailers/application_mailer.rb
@@ -1,4 +1,4 @@
class ApplicationMailer < ActionMailer::Base
- default from: "tps@apientreprise.fr"
+ default from: "'Téléprocédures Simplifiées' <#{I18n.t('dynamics.contact_email')}>"
layout 'mailer'
end
diff --git a/app/mailers/gestionnaire_mailer.rb b/app/mailers/gestionnaire_mailer.rb
index 74765352b..8acbe7237 100644
--- a/app/mailers/gestionnaire_mailer.rb
+++ b/app/mailers/gestionnaire_mailer.rb
@@ -18,7 +18,6 @@ class GestionnaireMailer < ApplicationMailer
def send_mail email, args, subject
vars_mailer email, args
- mail(from: "tps@apientreprise.fr", to: email,
- subject: subject)
+ mail(to: email, subject: subject)
end
end
diff --git a/app/mailers/invite_mailer.rb b/app/mailers/invite_mailer.rb
index c536d9d46..09b58f229 100644
--- a/app/mailers/invite_mailer.rb
+++ b/app/mailers/invite_mailer.rb
@@ -19,8 +19,7 @@ class InviteMailer < ApplicationMailer
end
def send_mail email, subject, reply_to
- mail(from: "tps@apientreprise.fr",
- to: email,
+ mail(to: email,
subject: subject,
reply_to: reply_to)
end
diff --git a/app/mailers/new_admin_mailer.rb b/app/mailers/new_admin_mailer.rb
index f7acb8e7e..6ec6e7092 100644
--- a/app/mailers/new_admin_mailer.rb
+++ b/app/mailers/new_admin_mailer.rb
@@ -4,7 +4,7 @@ class NewAdminMailer < ApplicationMailer
@admin = admin
@password = password
- mail(from: "tps@apientreprise.fr", to: 'tech@apientreprise.fr',
+ mail(to: 'tech@apientreprise.fr',
subject: "Création d'un compte Admin TPS")
end
end
diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb
index 1fa5265ea..d2ddbb195 100644
--- a/app/mailers/notification_mailer.rb
+++ b/app/mailers/notification_mailer.rb
@@ -1,14 +1,15 @@
class NotificationMailer < ApplicationMailer
- default from: 'tps@apientreprise.fr',
- to: Proc.new { @user.email }
+ default to: Proc.new { @user.email }
+
+ after_action :create_commentaire_for_notification, only: :send_notification
def send_notification dossier, mail_template
vars_mailer(dossier)
- obj = mail_template.object_for_dossier dossier
- body = mail_template.body_for_dossier dossier
+ @obj = mail_template.object_for_dossier dossier
+ @body = mail_template.body_for_dossier dossier
- mail(subject: obj) { |format| format.html { body } }
+ mail(subject: @obj) { |format| format.html { @body } }
end
def new_answer dossier
@@ -17,6 +18,14 @@ class NotificationMailer < ApplicationMailer
private
+ def create_commentaire_for_notification
+ Commentaire.create(
+ dossier: @dossier,
+ email: I18n.t("dynamics.contact_email"),
+ body: ["[#{@obj}]", @body].join("
")
+ )
+ end
+
def vars_mailer dossier
@dossier = dossier
@user = dossier.user
diff --git a/app/mailers/welcome_mailer.rb b/app/mailers/welcome_mailer.rb
index b3542aecd..4306ee974 100644
--- a/app/mailers/welcome_mailer.rb
+++ b/app/mailers/welcome_mailer.rb
@@ -3,7 +3,7 @@ class WelcomeMailer < ApplicationMailer
@user = user
- mail(from: "tps@apientreprise.fr", to: user.email,
+ mail(to: user.email,
subject: "Création de votre compte TPS")
end
end
diff --git a/app/models/commentaire.rb b/app/models/commentaire.rb
index 0e39e5eba..d62e87eac 100644
--- a/app/models/commentaire.rb
+++ b/app/models/commentaire.rb
@@ -4,7 +4,7 @@ class Commentaire < ActiveRecord::Base
belongs_to :piece_justificative
- after_save :internal_notification
+ after_create :notify
def header
"#{email}, " + I18n.l(created_at.localtime, format: '%d %b %Y %H:%M')
@@ -12,9 +12,32 @@ class Commentaire < ActiveRecord::Base
private
- def internal_notification
- if email == dossier.user.email || dossier.invites_user.pluck(:email).to_a.include?(email)
- NotificationService.new('commentaire', self.dossier.id).notify
+ def notify
+ dossier_user_email = dossier.user.email
+ invited_users_emails = dossier.invites_user.pluck(:email).to_a
+
+ case email
+ when I18n.t("dynamics.contact_email")
+ # The commentaire is a copy of an automated notification email
+ # we sent to a user, so do nothing
+ when dossier_user_email, *invited_users_emails
+ # A user or an inved user posted a commentaire,
+ # we need to notify the gestionnaires
+
+ notify_gestionnaires
+ else
+ # A gestionnaire posted a commentaire,
+ # we need to notify the user
+
+ notify_user
end
end
+
+ def notify_gestionnaires
+ NotificationService.new('commentaire', self.dossier.id).notify
+ end
+
+ def notify_user
+ NotificationMailer.new_answer(dossier).deliver_now!
+ end
end
diff --git a/app/models/concerns/mail_template_concern.rb b/app/models/concerns/mail_template_concern.rb
index f5a41a156..f64de99d8 100644
--- a/app/models/concerns/mail_template_concern.rb
+++ b/app/models/concerns/mail_template_concern.rb
@@ -85,7 +85,7 @@ module MailTemplateConcern
when :libelle_procedure
dossier.procedure.libelle
when :date_de_decision
- dossier.processed_at.present? ? dossier.processed_at.strftime("%d/%m/%Y") : ""
+ dossier.processed_at.present? ? dossier.processed_at.localtime.strftime("%d/%m/%Y") : ""
else
'--BALISE_NON_RECONNUE--'
end
diff --git a/app/models/dossier.rb b/app/models/dossier.rb
index ed875bceb..c6eee566f 100644
--- a/app/models/dossier.rb
+++ b/app/models/dossier.rb
@@ -289,7 +289,7 @@ class Dossier < ActiveRecord::Base
else
parts = [
"Dossier déposé le ",
- initiated_at.strftime("%d/%m/%Y"),
+ initiated_at.localtime.strftime("%d/%m/%Y"),
" sur la procédure ",
procedure.libelle,
" gérée par l'organisme ",
diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb
index d646d7177..b5e84bcdd 100644
--- a/app/models/gestionnaire.rb
+++ b/app/models/gestionnaire.rb
@@ -9,6 +9,7 @@ class Gestionnaire < ActiveRecord::Base
has_many :assign_to, dependent: :destroy
has_many :procedures, through: :assign_to
has_many :dossiers, -> { where.not(state: :draft) }, through: :procedures
+ has_many :followed_dossiers, through: :follows, source: :dossier
has_many :follows
has_many :preference_list_dossiers
@@ -17,10 +18,6 @@ class Gestionnaire < ActiveRecord::Base
include CredentialsSyncableConcern
- def dossiers_follow
- @dossiers_follow ||= dossiers.joins(:follows).where("follows.gestionnaire_id = #{id}")
- end
-
def procedure_filter
return nil unless assign_to.pluck(:procedure_id).include?(self[:procedure_filter])
@@ -75,10 +72,10 @@ class Gestionnaire < ActiveRecord::Base
end
def notifications_for procedure
- procedure_ids = dossiers_follow.pluck(:procedure_id)
+ procedure_ids = followed_dossiers.pluck(:procedure_id)
if procedure_ids.include?(procedure.id)
- return dossiers_follow.where(procedure_id: procedure.id)
+ return followed_dossiers.where(procedure_id: procedure.id)
.inject(0) do |acc, dossier|
acc += dossier.notifications.where(already_read: false).count
end
@@ -86,16 +83,9 @@ class Gestionnaire < ActiveRecord::Base
0
end
- def dossier_with_notification_for procedure
- procedure_ids = dossiers_follow.pluck(:procedure_id)
-
- if procedure_ids.include?(procedure.id)
- return dossiers_follow.where(procedure_id: procedure.id)
- .inject(0) do |acc, dossier|
- acc += ((dossier.notifications.where(already_read: false).count) > 0 ? 1 : 0)
- end
- end
- 0
+ def dossiers_with_notifications_count_for_procedure(procedure)
+ followed_dossiers_id = followed_dossiers.where(procedure: procedure).pluck(:id)
+ Notification.unread.where(dossier_id: followed_dossiers_id).select(:dossier_id).distinct(:dossier_id).count
end
def dossiers_with_notifications_count
diff --git a/app/services/dossiers_list_gestionnaire_service.rb b/app/services/dossiers_list_gestionnaire_service.rb
index a53c35b4c..63a91783c 100644
--- a/app/services/dossiers_list_gestionnaire_service.rb
+++ b/app/services/dossiers_list_gestionnaire_service.rb
@@ -25,7 +25,7 @@ class DossiersListGestionnaireService
end
def suivi
- @suivi ||= @current_devise_profil.dossiers_follow.merge(dossiers_to_display)
+ @suivi ||= @current_devise_profil.followed_dossiers.merge(dossiers_to_display)
end
def nouveaux
diff --git a/app/views/admin/procedures/_informations.html.haml b/app/views/admin/procedures/_informations.html.haml
index 253ee6729..cb2c4aa2e 100644
--- a/app/views/admin/procedures/_informations.html.haml
+++ b/app/views/admin/procedures/_informations.html.haml
@@ -84,7 +84,7 @@
%h4 Options avancées
%label{ for: :auto_archive_on } Archivage automatique le
- = f.text_field :auto_archive_on, id: 'auto_archive_on', value: @procedure.auto_archive_on.try{ |d| d.strftime("%d-%m-%Y") }, data: { provide: 'datepicker', 'date-language' => 'fr', 'date-format' => 'dd/mm/yyyy' }
+ = f.text_field :auto_archive_on, id: 'auto_archive_on', value: @procedure.auto_archive_on.try{ |d| d.localtime.strftime("%d-%m-%Y") }, data: { provide: 'datepicker', 'date-language' => 'fr', 'date-format' => 'dd/mm/yyyy' }
(à 00h00)
%p.help-block
%i.fa.fa-info-circle
diff --git a/app/views/administrations/_list.html.haml b/app/views/administrations/_list.html.haml
index 3af742c9c..171418756 100644
--- a/app/views/administrations/_list.html.haml
+++ b/app/views/administrations/_list.html.haml
@@ -15,7 +15,7 @@
- unless admin.last_sign_in_at.nil?
= time_ago_in_words(l(admin.last_sign_in_at, format: "%d/%m/%Y %H:%M UTC +02:00"))
(
- = admin.last_sign_in_at.to_date.strftime('%d/%m/%Y')
+ = admin.last_sign_in_at.to_date.localtime.strftime('%d/%m/%Y')
)
%td
= admin.procedures.where(published: true).count
diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb
index 1cc3186e0..80466e643 100644
--- a/app/views/devise/mailer/reset_password_instructions.html.erb
+++ b/app/views/devise/mailer/reset_password_instructions.html.erb
@@ -12,4 +12,4 @@
---
- L'équipe TPS - tps@apientreprise.fr
\ No newline at end of file
+ L'équipe Téléprocédures Simplifiées
diff --git a/app/views/dossiers/_infos_entreprise.html.haml b/app/views/dossiers/_infos_entreprise.html.haml
index 661634697..6594bffec 100644
--- a/app/views/dossiers/_infos_entreprise.html.haml
+++ b/app/views/dossiers/_infos_entreprise.html.haml
@@ -24,7 +24,7 @@
.col-xs-8.entreprise-info= @facade.etablissement.naf
.row
.col-xs-4.entreprise-label Date de création :
- .col-xs-8.entreprise-info= Time.at(@facade.entreprise.date_creation).strftime "%d-%m-%Y"
+ .col-xs-8.entreprise-info= Time.at(@facade.entreprise.date_creation).localtime.strftime "%d-%m-%Y"
.row
.col-xs-4.entreprise-label Effectif organisation :
.col-xs-8.entreprise-info= @facade.entreprise.effectif
diff --git a/app/views/dossiers/commentaires/_form.html.haml b/app/views/dossiers/commentaires/_form.html.haml
index e88551110..8360e1ba1 100644
--- a/app/views/dossiers/commentaires/_form.html.haml
+++ b/app/views/dossiers/commentaires/_form.html.haml
@@ -7,4 +7,4 @@
%h4.text-primary{ style: 'margin-top: 0px;' } Ajouter un fichier
= file_field_tag "piece_justificative[content]", accept: PieceJustificative.accept_format, style: 'float: left; margin-left: 20px;'
.col-md-6.text-right
- %input#save-message.form-control.btn.btn-danger{ type: 'submit', value: 'ENVOYER' }
+ = submit_tag 'Envoyer', id: 'save-message', class: 'form-control btn btn-danger', data: { disable_with: 'Envoi...' }
diff --git a/app/views/gestionnaire_mailer/new_assignement.text.erb b/app/views/gestionnaire_mailer/new_assignement.text.erb
index 414086802..694f454b8 100644
--- a/app/views/gestionnaire_mailer/new_assignement.text.erb
+++ b/app/views/gestionnaire_mailer/new_assignement.text.erb
@@ -8,4 +8,4 @@ Vous venez d'être assigné à un administrateur sur la plateforme TPS. Voici qu
Bonne journée,
---
-L'équipe TPS - tps@apientreprise.fr
\ No newline at end of file
+L'équipe Téléprocédures Simplifiées
diff --git a/app/views/gestionnaire_mailer/new_gestionnaire.text.erb b/app/views/gestionnaire_mailer/new_gestionnaire.text.erb
index c68a7ae98..f7472cb9e 100644
--- a/app/views/gestionnaire_mailer/new_gestionnaire.text.erb
+++ b/app/views/gestionnaire_mailer/new_gestionnaire.text.erb
@@ -9,4 +9,4 @@ Vous venez d'être nommé accompagnateur sur la plateforme TPS. Pour mémoire, v
Bonne journée,
---
-L'équipe TPS - tps@apientreprise.fr
\ No newline at end of file
+L'équipe Téléprocédures Simplifiées
diff --git a/app/views/invite_mailer/invite_guest.text.erb b/app/views/invite_mailer/invite_guest.text.erb
index 1e5c87712..73894115d 100644
--- a/app/views/invite_mailer/invite_guest.text.erb
+++ b/app/views/invite_mailer/invite_guest.text.erb
@@ -9,4 +9,4 @@ Afin de répondre à cette invitation, merci de vous inscrit avec l'adresse emai
Bonne journée.
---
-L'équide TPS - tps@apientreprise.fr
\ No newline at end of file
+L'équipe Téléprocédures Simplifiées
diff --git a/app/views/invite_mailer/invite_user.text.erb b/app/views/invite_mailer/invite_user.text.erb
index 57827303c..53e98e30c 100644
--- a/app/views/invite_mailer/invite_user.text.erb
+++ b/app/views/invite_mailer/invite_user.text.erb
@@ -7,4 +7,4 @@ Pour le consulter, merci de suivre ce lien : <%= users_dossiers_invite_url(@invi
Bonne journée.
---
-L'équide TPS - tps@apientreprise.fr
\ No newline at end of file
+L'équipe Téléprocédures Simplifiées
diff --git a/app/views/layouts/_mailjet_newsletter.html.haml b/app/views/layouts/_mailjet_newsletter.html.haml
new file mode 100644
index 000000000..3bfea491e
--- /dev/null
+++ b/app/views/layouts/_mailjet_newsletter.html.haml
@@ -0,0 +1,2 @@
+%data.mj-w-data{ "data-apikey" => "1v5T", "data-base" => "http://app.mailjet.com", "data-height" => "328", "data-lang" => "fr_FR", "data-statics" => "statics", "data-token" => "11c89e7ddb46fbcdcb7f8fe5fdfca818", "data-w-id" => "39b", "data-width" => "640" }
+%script{ src: 'https://app.mailjet.com/statics/js/widget.modal.js' }
diff --git a/app/views/layouts/_new_footer.html.haml b/app/views/layouts/_new_footer.html.haml
index 806541020..4bcc09bc8 100644
--- a/app/views/layouts/_new_footer.html.haml
+++ b/app/views/layouts/_new_footer.html.haml
@@ -25,6 +25,8 @@
%li.footer-column
%ul.footer-links
+ %li.footer-link
+ %a{ href: '#', 'data-token' => '11c89e7ddb46fbcdcb7f8fe5fdfca818', onclick: 'mjOpenPopin(event, this)' } Newsletter
%li.footer-link
= link_to "Contact",
"mailto:#{t('dynamics.contact_email')}",
diff --git a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml
index 5d6e6c9d7..c1dfe2bd7 100644
--- a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml
+++ b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml
@@ -1,6 +1,6 @@
#first-block
.dossiers-en-cours
- .count= current_gestionnaire.dossiers_follow.count
+ .count= current_gestionnaire.followed_dossiers.count
.text SUIVIS
.nouveaux-dossiers
.count= current_gestionnaire.dossiers.nouveaux.count
@@ -28,7 +28,7 @@
- if total_new > 0
.badge.progress-bar-success{ title: 'Nouveaux dossiers' }
= total_new
- - unread_notif_count = procedure.notifications.unread.count
+ - unread_notif_count = current_gestionnaire.dossiers_with_notifications_count_for_procedure(procedure)
- if unread_notif_count > 0
.badge.progress-bar-warning{ title: 'Notifications' }
= unread_notif_count
@@ -40,5 +40,5 @@
= link_to backoffice_dossier_path(dossier.id) do
.notification
.dossier-index= "Dossier nº #{dossier.id}"
- .updated-at-index= dossier.first_unread_notification.created_at.strftime('%d/%m %H:%M')
+ .updated-at-index= dossier.first_unread_notification.created_at.localtime.strftime('%d/%m %H:%M')
.count= dossier.unreaded_notifications.count
diff --git a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml
index 8ffd1196e..ccc0aaa36 100644
--- a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml
+++ b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml
@@ -45,7 +45,7 @@
%i.fa.fa-bell-o
- @facade.last_notifications.each do |notification|
.notification
- .updated-at= notification.updated_at.strftime('%d/%m/%Y %H:%M')
+ .updated-at= notification.updated_at.localtime.strftime('%d/%m/%Y %H:%M')
= render partial: "layouts/left_panels/type_notif_fa", locals: { notification: notification }
- if ['champs'].include?(notification.type_notif)
- if notification.liste.size > 1
diff --git a/app/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.html.haml b/app/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.html.haml
index a32b48b77..1adb2c390 100644
--- a/app/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.html.haml
+++ b/app/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.html.haml
@@ -1,3 +1,6 @@
+.link-to-dossiers
+ = link_to 'retour aux dossiers', users_dossiers_path
+
#first-block
.en-cours
%h2 Récapitulatif
diff --git a/app/views/layouts/navbars/_navbar_backoffice_dossierscontroller_show.html.haml b/app/views/layouts/navbars/_navbar_backoffice_dossierscontroller_show.html.haml
index 194f5d82f..97027181d 100644
--- a/app/views/layouts/navbars/_navbar_backoffice_dossierscontroller_show.html.haml
+++ b/app/views/layouts/navbars/_navbar_backoffice_dossierscontroller_show.html.haml
@@ -1,6 +1,5 @@
.col-xs-7.main-info
- %span{ 'data-toggle' => :tooltip, "data-placement" => :bottom, title: @facade.dossier.procedure.libelle }
- = @facade.dossier.procedure.libelle
+ = @facade.dossier.procedure.libelle
.col-xs-3.options
.row
.col-xs-12
diff --git a/app/views/layouts/new_application.html.haml b/app/views/layouts/new_application.html.haml
index 5310f24cf..ba6539661 100644
--- a/app/views/layouts/new_application.html.haml
+++ b/app/views/layouts/new_application.html.haml
@@ -33,6 +33,7 @@
= render partial: "layouts/new_footer"
= render partial: "layouts/google_analytics"
+ = render partial: "layouts/mailjet_newsletter"
= javascript_include_tag "application", "data-turbolinks-track" => true
- if Rails.env == "test"
diff --git a/app/views/new_admin_mailer/new_admin_email.text.erb b/app/views/new_admin_mailer/new_admin_email.text.erb
index 8b4d474df..547713f13 100644
--- a/app/views/new_admin_mailer/new_admin_email.text.erb
+++ b/app/views/new_admin_mailer/new_admin_email.text.erb
@@ -6,4 +6,4 @@ Login : <%= @admin.email %>
Password : <%= @password %>
---
-L'équipe TPS - tps@apientreprise.fr
\ No newline at end of file
+L'équipe Téléprocédures Simplifiées
diff --git a/app/views/notification_mailer/new_answer.text.erb b/app/views/notification_mailer/new_answer.text.erb
index d6874bd6d..039d306de 100644
--- a/app/views/notification_mailer/new_answer.text.erb
+++ b/app/views/notification_mailer/new_answer.text.erb
@@ -11,4 +11,4 @@ Merci de ne pas répondre à ce mail. Postez directement vos questions dans votr
---
---
-L'équide TPS - tps@apientreprise.fr
\ No newline at end of file
+L'équipe Téléprocédures Simplifiées
diff --git a/app/views/welcome_mailer/welcome_email.text.erb b/app/views/welcome_mailer/welcome_email.text.erb
index 57984af05..90b547ce5 100644
--- a/app/views/welcome_mailer/welcome_email.text.erb
+++ b/app/views/welcome_mailer/welcome_email.text.erb
@@ -12,4 +12,4 @@ Oubli de mot de passe, pas de problème :
Bonne journée,
---
-L'équipe TPS - tps@apientreprise.fr
\ No newline at end of file
+L'équipe Téléprocédures Simplifiées
diff --git a/bin/bundle b/bin/bundle
new file mode 100755
index 000000000..66e9889e8
--- /dev/null
+++ b/bin/bundle
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+load Gem.bin_path('bundler', 'bundle')
diff --git a/bin/rails b/bin/rails
new file mode 100755
index 000000000..073966023
--- /dev/null
+++ b/bin/rails
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+APP_PATH = File.expand_path('../config/application', __dir__)
+require_relative '../config/boot'
+require 'rails/commands'
diff --git a/bin/rake b/bin/rake
new file mode 100755
index 000000000..17240489f
--- /dev/null
+++ b/bin/rake
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+require_relative '../config/boot'
+require 'rake'
+Rake.application.run
diff --git a/bin/setup b/bin/setup
new file mode 100755
index 000000000..e620b4dad
--- /dev/null
+++ b/bin/setup
@@ -0,0 +1,34 @@
+#!/usr/bin/env ruby
+require 'pathname'
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+ # This script is a starting point to setup your application.
+ # Add necessary setup steps to this file.
+
+ puts '== Installing dependencies =='
+ system! 'gem install bundler --conservative'
+ system('bundle check') || system!('bundle install')
+
+ # puts "\n== Copying sample files =="
+ # unless File.exist?('config/database.yml')
+ # cp 'config/database.yml.sample', 'config/database.yml'
+ # end
+
+ puts "\n== Preparing database =="
+ system! 'bin/rails db:setup'
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! 'bin/rails log:clear tmp:clear'
+
+ puts "\n== Restarting application server =="
+ system! 'bin/rails restart'
+end
diff --git a/bin/update b/bin/update
new file mode 100755
index 000000000..a8e4462f2
--- /dev/null
+++ b/bin/update
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+require 'pathname'
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+ # This script is a way to update your development environment automatically.
+ # Add necessary update steps to this file.
+
+ puts '== Installing dependencies =='
+ system! 'gem install bundler --conservative'
+ system('bundle check') || system!('bundle install')
+
+ puts "\n== Updating database =="
+ system! 'bin/rails db:migrate'
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! 'bin/rails log:clear tmp:clear'
+
+ puts "\n== Restarting application server =="
+ system! 'bin/rails restart'
+end
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
index 8d3886482..60f55f640 100644
--- a/config/initializers/devise.rb
+++ b/config/initializers/devise.rb
@@ -10,7 +10,7 @@ Devise.setup do |config|
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class
# with default "from" parameter.
- config.mailer_sender = 'tps@apientreprise.fr'
+ config.mailer_sender = "'Téléprocédures Simplifiées' <#{I18n.t('dynamics.contact_email')}>"
# Configure the class responsible to send e-mails.
# config.mailer = 'Devise::Mailer'
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index 912dd5bd5..f1da0acaa 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -213,6 +213,24 @@ fr:
- oct.
- nov.
- déc.
+ month_names:
+ -
+ - janvier
+ - février
+ - mars
+ - avril
+ - mai
+ - juin
+ - juillet
+ - août
+ - septembre
+ - octobre
+ - novembre
+ - décembre
+ order:
+ - :day
+ - :month
+ - :year
day_names:
- dimanche
- lundi
@@ -225,24 +243,6 @@ fr:
default: "%d/%m/%Y"
short: "%e %b"
long: "%e %B %Y"
- month_names:
- -
- - janvier
- - février
- - mars
- - avril
- - mai
- - juin
- - juillet
- - août
- - septembre
- - octobre
- - novembre
- - décembre
- order:
- - :day
- - :month
- - :year
datetime:
distance_in_words:
about_x_hours:
diff --git a/spec/controllers/users/dossiers/commentaires_controller_spec.rb b/spec/controllers/users/dossiers/commentaires_controller_spec.rb
index d56a18d9b..f83943979 100644
--- a/spec/controllers/users/dossiers/commentaires_controller_spec.rb
+++ b/spec/controllers/users/dossiers/commentaires_controller_spec.rb
@@ -45,27 +45,4 @@ describe Users::Dossiers::CommentairesController, type: :controller do
end
end
-
- describe '#notify_user_with_mail' do
- let(:commentaire){create(:commentaire)}
-
- context 'when usager is writing a commentaire on dossier' do
- before { sign_in commentaire.dossier.user }
-
- it {
- expect(NotificationMailer).to_not receive(:new_answer)
- subject.send(:notify_user_with_mail, commentaire)
- }
- end
-
- context 'when anybody else but usager is writing a commentaire' do
- before { sign_in create(:user, email: 'administrateur@test.fr') }
-
- it {
- expect(NotificationMailer).to receive(:new_answer).and_return(NotificationMailer)
- expect(NotificationMailer).to receive(:deliver_now!)
- subject.send(:notify_user_with_mail, commentaire)
- }
- end
- end
end
diff --git a/spec/decorators/commentaire_decorator_spec.rb b/spec/decorators/commentaire_decorator_spec.rb
index 5a6cc6231..06b821416 100644
--- a/spec/decorators/commentaire_decorator_spec.rb
+++ b/spec/decorators/commentaire_decorator_spec.rb
@@ -1,14 +1,15 @@
require 'spec_helper'
describe CommentaireDecorator do
- let(:commentaire) { Timecop.freeze(Time.utc(2008, 9, 1, 10, 5, 0)) {create :commentaire} }
+ let(:time) { Time.utc(2008, 9, 1, 10, 5, 0) }
+ let(:commentaire) { Timecop.freeze(time) { create :commentaire } }
let(:decorator) { commentaire.decorate }
describe 'created_at_fr' do
subject { decorator.created_at_fr }
context 'when created_at have a value' do
- it { is_expected.to eq '01/09/2008 - 10:05' }
+ it { is_expected.to eq time.localtime.strftime('%d/%m/%Y - %H:%M') }
end
end
end
diff --git a/spec/decorators/entreprise_decorator_spec.rb b/spec/decorators/entreprise_decorator_spec.rb
index a039179d4..e5f229486 100644
--- a/spec/decorators/entreprise_decorator_spec.rb
+++ b/spec/decorators/entreprise_decorator_spec.rb
@@ -50,10 +50,4 @@ describe EntrepriseDecorator do
expect(subject.pretty_capital_social).to eq('123 000,00 €')
end
end
-
- describe '#pretty_date_creation' do
- it 'pretty print date creation' do
- expect(subject.pretty_date_creation).to eq('28-01-2016')
- end
- end
end
diff --git a/spec/factories/invite_user.rb b/spec/factories/invite_user.rb
new file mode 100644
index 000000000..c4f7dcdbd
--- /dev/null
+++ b/spec/factories/invite_user.rb
@@ -0,0 +1,24 @@
+FactoryGirl.define do
+ factory :invite_user do
+ email 'plop@octo.com'
+
+ after(:build) do |invite, _evaluator|
+ if invite.dossier.nil?
+ invite.dossier = create(:dossier)
+ end
+
+ unless invite.user.nil?
+ invite.email = invite.user.email
+ end
+ end
+
+ trait :with_user do
+ after(:build) do |invite, _evaluator|
+ if invite.user.nil?
+ invite.user = create(:user)
+ invite.email = invite.user.email
+ end
+ end
+ end
+ end
+end
diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb
index 4c8f26fc1..e9a66e4a7 100644
--- a/spec/mailers/notification_mailer_spec.rb
+++ b/spec/mailers/notification_mailer_spec.rb
@@ -5,10 +5,23 @@ RSpec.describe NotificationMailer, type: :mailer do
let(:user) { create(:user) }
let(:dossier) { create(:dossier, user: user) }
let(:email) { instance_double('email', object_for_dossier: 'object', body_for_dossier: 'body') }
+ let (:notifications_count_before) { Notification.count }
subject { described_class.send_notification(dossier, email) }
it { expect(subject.subject).to eq(email.object_for_dossier) }
it { expect(subject.body).to eq(email.body_for_dossier) }
+
+ it "creates a commentaire, which is not notified" do
+ described_class.send_notification(dossier, email).deliver_now
+
+ commentaire = Commentaire.last
+ notifications_count_after = Notification.count
+
+ expect(commentaire.dossier).to eq(dossier)
+ expect(commentaire.email).to eq("contact@tps.apientreprise.fr")
+ expect(commentaire.body).to eq("[object]
body")
+ expect(notifications_count_before).to eq(notifications_count_after)
+ end
end
describe ".new_answer" do
diff --git a/spec/models/commentaire_spec.rb b/spec/models/commentaire_spec.rb
index efcf9bff1..8decaf4ae 100644
--- a/spec/models/commentaire_spec.rb
+++ b/spec/models/commentaire_spec.rb
@@ -8,4 +8,56 @@ describe Commentaire do
it { is_expected.to belong_to(:dossier) }
it { is_expected.to belong_to(:piece_justificative) }
+
+ describe "#notify" do
+ let(:procedure) { create(:procedure) }
+ let(:gestionnaire) { create(:gestionnaire) }
+ let(:assign_to) { create(:assign_to, gestionnaire: gestionnaire, procedure: procedure) }
+ let(:user) { create(:user) }
+ let(:dossier) { create(:dossier, procedure: procedure, user: user) }
+ let(:commentaire) { Commentaire.new(dossier: dossier) }
+
+ context "with a commentaire created by a user" do
+ it "calls notify_gestionnaires" do
+ expect(commentaire).to receive(:notify_gestionnaires)
+
+ commentaire.email = user.email
+ commentaire.save
+ end
+ end
+
+ context "with a commentaire created by an invited user" do
+ let(:user_invite) { create(:user) }
+
+ before do
+ FactoryGirl.create(:invite_user, email: "invite@tps.apientreprise.fr", dossier: dossier, user: user_invite)
+ end
+
+ it "calls notify_gestionnaires" do
+ expect(commentaire).to receive(:notify_gestionnaires)
+
+ commentaire.email = user_invite.email
+ commentaire.save
+ end
+ end
+
+ context "with a commentaire created by a gestionnaire" do
+ it "calls notify_user" do
+ expect(commentaire).to receive(:notify_user)
+
+ commentaire.email = gestionnaire.email
+ commentaire.save
+ end
+ end
+
+ context "with a commentaire automatically created (notification)" do
+ it "does not call notify_user or notify_gestionnaires" do
+ expect(commentaire).not_to receive(:notify_user)
+ expect(commentaire).not_to receive(:notify_gestionnaires)
+
+ commentaire.email = "contact@tps.apientreprise.fr"
+ commentaire.save
+ end
+ end
+ end
end
diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb
index a9c88fa92..8525b2e86 100644
--- a/spec/models/gestionnaire_spec.rb
+++ b/spec/models/gestionnaire_spec.rb
@@ -116,19 +116,6 @@ describe Gestionnaire, type: :model do
end
end
- describe '#dossiers_follow' do
- let!(:dossier) { create :dossier, procedure: procedure, state: :initiated }
-
- before do
- create :follow, dossier_id: dossier.id, gestionnaire_id: gestionnaire.id
- end
-
- subject { gestionnaire.dossiers_follow }
-
- it { expect(Follow.all.size).to eq 1 }
- it { expect(subject.first).to eq dossier }
- end
-
describe '#build_default_preferences_list_dossier' do
subject { gestionnaire.preference_list_dossiers }
@@ -288,6 +275,13 @@ describe Gestionnaire, type: :model do
it { is_expected.to eq(1) }
end
+ context 'when there is one notification read' do
+ let(:notification){ create(:notification, already_read: true) }
+ let!(:follow){ create(:follow, dossier: notification.dossier, gestionnaire: gestionnaire) }
+
+ it { is_expected.to eq(0) }
+ end
+
context 'when there are many notifications for one dossier' do
let(:notification){ create(:notification, already_read: false) }
let(:notification2){ create(:notification, already_read: false, dossier: notification.dossier) }
@@ -305,4 +299,52 @@ describe Gestionnaire, type: :model do
it { is_expected.to eq(2) }
end
end
+
+ describe '#dossiers_with_notifications_count_for_procedure' do
+ subject { gestionnaire.dossiers_with_notifications_count_for_procedure(procedure) }
+
+ context 'without notifications' do
+ it { is_expected.to eq(0) }
+ end
+
+ context 'with a followed dossier' do
+ let!(:dossier){create(:dossier, procedure: procedure, state: 'received')}
+ let!(:follow){ create(:follow, dossier: dossier, gestionnaire: gestionnaire) }
+
+ context 'with 1 notification' do
+ let!(:notification){ create(:notification, already_read: false, dossier: dossier) }
+
+ it { is_expected.to eq(1) }
+ end
+
+ context 'with 1 read notification' do
+ let!(:notification){ create(:notification, already_read: true, dossier: dossier) }
+
+ it { is_expected.to eq(0) }
+ end
+
+ context 'with 2 notifications' do
+ let!(:notification){ create(:notification, already_read: false, dossier: dossier) }
+ let!(:notification2){ create(:notification, already_read: false, dossier: dossier) }
+
+ it { is_expected.to eq(1) }
+ end
+
+ context 'with another dossier' do
+ let!(:dossier2){create(:dossier, procedure: procedure, state: 'received')}
+ let!(:follow2){ create(:follow, dossier: dossier2, gestionnaire: gestionnaire) }
+
+ context 'and some notifications' do
+ let!(:notification){ create(:notification, already_read: false, dossier: dossier) }
+ let!(:notification2){ create(:notification, already_read: false, dossier: dossier) }
+ let!(:notification3){ create(:notification, already_read: false, dossier: dossier) }
+
+ let!(:notification4){ create(:notification, already_read: false, dossier: dossier2) }
+ let!(:notification5){ create(:notification, already_read: false, dossier: dossier2) }
+
+ it { is_expected.to eq(2) }
+ end
+ end
+ end
+ end
end