Merge pull request #3188 from consul/processes-homepage-phase

[Backport] Legislation process homepage phase
This commit is contained in:
Alberto
2019-01-17 12:13:59 +01:00
committed by GitHub
7 changed files with 77 additions and 24 deletions

View File

@@ -18,8 +18,8 @@ class Legislation::Process < ActiveRecord::Base
translates :homepage, touch: true
include Globalizable
PHASES_AND_PUBLICATIONS = %i[draft_phase debate_phase allegations_phase proposals_phase
draft_publication result_publication].freeze
PHASES_AND_PUBLICATIONS = %i[homepage_phase draft_phase debate_phase allegations_phase
proposals_phase draft_publication result_publication].freeze
has_many :draft_versions, -> { order(:id) }, class_name: 'Legislation::DraftVersion',
foreign_key: 'legislation_process_id',
@@ -54,6 +54,10 @@ class Legislation::Process < ActiveRecord::Base
draft_end_date IS NOT NULL and (draft_start_date > ? or
draft_end_date < ?))", Date.current, Date.current) }
def homepage_phase
Legislation::Process::Phase.new(start_date, end_date, homepage_enabled)
end
def draft_phase
Legislation::Process::Phase.new(draft_start_date, draft_end_date, draft_phase_enabled)
end

View File

@@ -34,6 +34,30 @@
url: legislation_process_url(@process),
description: @process.title
} %>
<% if process.draft_publication.enabled? %>
<div class="sidebar-divider"></div>
<p class="sidebar-title">
<%= t("legislation.processes.shared.draft_publication_date") %>
</p>
<p>
<%= link_to draft_publication_legislation_process_path(@process) do %>
<strong><%= format_date(process.draft_publication_date) %></strong>
<% end %>
</p>
<% end %>
<% if process.result_publication.enabled? %>
<div class="sidebar-divider"></div>
<p class="sidebar-title">
<%= t("legislation.processes.shared.result_publication_date") %>
</p>
<p>
<%= link_to result_publication_legislation_process_path(@process) do %>
<strong><%= format_date(process.result_publication_date) %></strong>
<% end %>
</p>
<% end %>
</aside>
</div>
</div>

View File

@@ -6,6 +6,15 @@
<% end %>
<ul class="key-dates">
<% if process.homepage_enabled? && process.homepage.present? %>
<li <%= 'class=is-active' if phase.to_sym == :homepage %>>
<%= link_to legislation_process_path(process) do %>
<h4><%= t("legislation.processes.shared.homepage") %></h4>
<br>
<% end %>
</li>
<% end %>
<% if process.debate_phase.enabled? %>
<li <%= 'class=is-active' if phase.to_sym == :debate_phase %>>
<%= link_to debate_legislation_process_path(process) do %>
@@ -24,15 +33,6 @@
</li>
<% end %>
<% if process.draft_publication.enabled? %>
<li <%= 'class=is-active' if phase.to_sym == :draft_publication %>>
<%= link_to draft_publication_legislation_process_path(process) do %>
<h4><%= t("legislation.processes.shared.draft_publication_date") %></h4>
<span><%= format_date(process.draft_publication_date) %></span>
<% end %>
</li>
<% end %>
<% if process.allegations_phase.enabled? %>
<li <%= 'class=is-active' if phase.to_sym == :allegations_phase %>>
<%= link_to allegations_legislation_process_path(process) do %>
@@ -42,15 +42,6 @@
</li>
<% end %>
<% if process.result_publication.enabled? %>
<li <%= 'class=is-active' if phase.to_sym == :result_publication %>>
<%= link_to result_publication_legislation_process_path(process) do %>
<h4><%= t("legislation.processes.shared.result_publication_date") %></h4>
<span><%= format_date(process.result_publication_date) %></span>
<% end %>
</li>
<% end %>
<% if process.milestones.any? %>
<li class="milestones <%= "is-active" if phase == :milestones %>">
<%= link_to milestones_legislation_process_path(process) do %>

View File

@@ -4,9 +4,9 @@
<%= render 'documents/additional_documents', documents: @process.documents %>
<%= render 'key_dates', process: @process, phase: :debate_phase %>
<%= render 'key_dates', process: @process, phase: :homepage %>
<div class="row">
<div class="row margin-top">
<div class="small-12 medium-9 column">
<%= AdminWYSIWYGSanitizer.new.sanitize(@process.homepage) %>
</div>

View File

@@ -83,6 +83,7 @@ en:
see_latest_comments_title: Comment on this process
shared:
key_dates: Participation phases
homepage: Homepage
debate_dates: Debate
draft_publication_date: Draft publication
allegations_dates: Comments

View File

@@ -83,6 +83,7 @@ es:
see_latest_comments_title: Aportar a este proceso
shared:
key_dates: Fases de participación
homepage: Inicio
debate_dates: Debate previo
draft_publication_date: Publicación borrador
allegations_dates: Comentarios

View File

@@ -152,8 +152,7 @@ feature 'Legislation' do
scenario 'show view has document present on all phases' do
process = create(:legislation_process)
document = create(:document, documentable: process)
phases = ["Debate", "Proposals", "Draft publication",
"Comments", "Final result publication"]
phases = ["Debate", "Proposals", "Comments"]
visit legislation_process_path(process)
@@ -166,6 +165,31 @@ feature 'Legislation' do
end
end
scenario 'show draft publication and final result publication dates' do
process = create(:legislation_process, draft_publication_date: Date.new(2019, 01, 10),
result_publication_date: Date.new(2019, 01, 20))
visit legislation_process_path(process)
within("aside") do
expect(page).to have_content("Draft publication")
expect(page).to have_content("10 Jan 2019")
expect(page).to have_content("Final result publication")
expect(page).to have_content("20 Jan 2019")
end
end
scenario 'do not show draft publication and final result publication dates if are empty' do
process = create(:legislation_process, :empty)
visit legislation_process_path(process)
within("aside") do
expect(page).not_to have_content("Draft publication")
expect(page).not_to have_content("Final result publication")
end
end
scenario 'show additional info button' do
process = create(:legislation_process, additional_info: "Text for additional info of the process")
@@ -201,6 +225,10 @@ feature 'Legislation' do
visit legislation_process_path(process)
within(".key-dates") do
expect(page).to have_content("Homepage")
end
expect(page).to have_content("This is the process homepage")
expect(page).not_to have_content("Participate in the debate")
end
@@ -213,6 +241,10 @@ feature 'Legislation' do
visit legislation_process_path(process)
within(".key-dates") do
expect(page).not_to have_content("Homepage")
end
expect(page).to have_content("This phase is not open yet")
expect(page).not_to have_content("This is the process homepage")
end