Merge pull request #5194 from betagouv/heure-de-paris

Usager : affichage de la date limite des démarches dans la description et les emails
This commit is contained in:
Pierre de La Morinerie 2020-05-28 15:34:25 +02:00 committed by GitHub
commit cd234791cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 92 additions and 4 deletions

View file

@ -37,6 +37,29 @@ $procedure-description-line-height: 22px;
}
}
.procedure-auto-archive {
cursor: pointer;
margin-bottom: 32px;
p {
padding-top: 8px;
font-size: 16px;
}
summary {
font-size: 20px;
&:-webkit-details-marker {
display: none;
}
}
}
.procedure-auto-archive-title {
border-bottom: 1px dotted $blue;
}
.procedure-description {
font-size: 16px;

View file

@ -38,5 +38,15 @@ module ProcedureHelper
}
end
private
def procedure_auto_archive_date(procedure)
I18n.l(procedure.auto_archive_on - 1.day, format: '%-d %B %Y')
end
def procedure_auto_archive_time(procedure)
"à 23 h 59 (heure de " + Rails.application.config.time_zone + ")"
end
def procedure_auto_archive_datetime(procedure)
procedure_auto_archive_date(procedure) + ' ' + procedure_auto_archive_time(procedure)
end
end

View file

@ -2,6 +2,7 @@
class DossierMailer < ApplicationMailer
helper ServiceHelper
helper MailerHelper
helper ProcedureHelper
layout 'mailers/layout'

View file

@ -10,7 +10,7 @@
&nbsp;» est commencé mais n'est pas encore déposé.
%p
Si vous souhaitez que ce dossier soit pris en compte, il vous faut le déposer avant le
#{l(@dossier.procedure.auto_archive_on - 1.day, format: '%-d %B %Y')} à 23h59, date de cloture de la démarche.
#{procedure_auto_archive_datetime(@dossier.procedure)}, date limite de dépôt des dossiers.
%p
Pour cela, affichez le dossier avec le bouton ci-dessous, vérifiez votre dossier puis
cliquez sur le bouton

View file

@ -16,6 +16,10 @@
= round_button('Afficher votre dossier', dossier_url(@dossier), :primary)
- if @dossier.procedure.auto_archive_on
%p
Vous pouvez déposer votre dossier jusqu'au #{procedure_auto_archive_datetime(@dossier.procedure)}.
= render 'layouts/mailers/signature'
- content_for :footer do

View file

@ -115,7 +115,7 @@
Le
- value = @procedure.auto_archive_on ? @procedure.auto_archive_on - 1.day : nil
= f.date_field :auto_archive_on, id: 'auto_archive_on', value: value
à 23 h 59
#{procedure_auto_archive_time(@procedure)}.
= f.label :declarative_with_state do
Démarche déclarative

View file

@ -7,6 +7,15 @@
= image_tag("flag_of_europe.svg", id: 'euro_flag', class: (!procedure.euro_flag ? "hidden" : ""))
%h1.procedure-title
= procedure.libelle
- if procedure.auto_archive_on
%details.procedure-auto-archive
%summary
%span.icon.clock
%span.procedure-auto-archive-title Date limite : #{procedure_auto_archive_date(procedure)}
%p Vous pouvez déposer vos dossiers jusqu'au #{procedure_auto_archive_datetime(procedure)}.
.procedure-description
.procedure-description-body.read-more-enabled.read-more-collapsed
= h string_to_html(procedure.description)

View file

@ -86,6 +86,10 @@ FactoryBot.define do
end
end
trait :with_auto_archive do
auto_archive_on { Time.zone.today + 20 }
end
trait :with_type_de_champ do
transient do
types_de_champ_count { 1 }

View file

@ -0,0 +1,10 @@
RSpec.describe ProcedureHelper, type: :helper do
let(:auto_archive_date) { Time.zone.local(2020, 8, 2, 12, 00) }
let(:procedure) { build(:procedure, auto_archive_on: auto_archive_date) }
subject { procedure_auto_archive_datetime(procedure) }
it "displays the day before the auto archive date (to account for the '23h59' ending time)" do
expect(subject).to have_text("1 août 2020 à 23 h 59 (heure de Paris)")
end
end

View file

@ -12,7 +12,7 @@ RSpec.describe DossierMailer, type: :mailer do
end
describe '.notify_new_draft' do
let(:dossier) { create(:dossier, procedure: build(:simple_procedure)) }
let(:dossier) { create(:dossier, procedure: build(:simple_procedure, :with_auto_archive)) }
subject { described_class.notify_new_draft(dossier) }
@ -20,6 +20,8 @@ RSpec.describe DossierMailer, type: :mailer do
it { expect(subject.subject).to include(dossier.procedure.libelle) }
it { expect(subject.body).to include(dossier.procedure.libelle) }
it { expect(subject.body).to include(dossier_url(dossier)) }
it { expect(subject.body).to include("Vous pouvez déposer votre dossier jusqu'au") }
it { expect(subject.body).to include("heure de") }
it_behaves_like 'a dossier notification'
end

View file

@ -0,0 +1,25 @@
describe 'shared/_procedure_description.html.haml', type: :view do
let(:procedure) { create(:procedure, :published, :with_service) }
subject { render partial: 'shared/procedure_description', locals: { procedure: procedure } }
it 'renders the view' do
subject
expect(rendered).to have_selector('.procedure-logos')
expect(rendered).to have_text(procedure.libelle)
expect(rendered).to have_text(procedure.description)
end
it 'does not show empty date limite' do
subject
expect(rendered).not_to have_text('Date limite')
end
context 'when the procedure has an auto_archive date' do
let(:procedure) { create(:procedure, :published, :with_service, :with_auto_archive) }
it 'shows the auto_archive_on' do
subject
expect(rendered).to have_text('Date limite')
end
end
end