From 2b6df62dd74906b51a06d971841db5af5d256aae Mon Sep 17 00:00:00 2001 From: Amaia Castro Date: Wed, 4 Jan 2017 11:27:47 +0100 Subject: [PATCH] Refactor process phases pages --- .../legislation/processes_controller.rb | 36 ++++++++++++++++++- .../processes/_phase_allegations.html.erb | 9 ----- .../_phase_draft_publication.html.erb | 9 ----- .../_phase_final_version_publication.html.erb | 5 --- .../processes/_phase_not_open.html.erb | 13 ------- .../{phase.html.erb => phase_empty.html.erb} | 6 +--- .../processes/phase_not_open.html.erb | 25 +++++++++++++ app/views/legislation/processes/show.html.erb | 6 +--- config/locales/en.yml | 8 ++--- config/locales/es.yml | 8 ++--- spec/features/legislation/processes_spec.rb | 6 ++-- 11 files changed, 69 insertions(+), 62 deletions(-) delete mode 100644 app/views/legislation/processes/_phase_allegations.html.erb delete mode 100644 app/views/legislation/processes/_phase_draft_publication.html.erb delete mode 100644 app/views/legislation/processes/_phase_final_version_publication.html.erb delete mode 100644 app/views/legislation/processes/_phase_not_open.html.erb rename app/views/legislation/processes/{phase.html.erb => phase_empty.html.erb} (60%) create mode 100644 app/views/legislation/processes/phase_not_open.html.erb diff --git a/app/controllers/legislation/processes_controller.rb b/app/controllers/legislation/processes_controller.rb index 05b7fbeae..1b51cec07 100644 --- a/app/controllers/legislation/processes_controller.rb +++ b/app/controllers/legislation/processes_controller.rb @@ -8,18 +8,53 @@ class Legislation::ProcessesController < Legislation::BaseController end def show + if @process.show_phase?(:debate) + render :show + else + render :phase_not_open + end end def draft_publication phase :draft_publication + + if @process.show_phase?(@phase) + if draft_version = @process.draft_versions.published.last + redirect_to legislation_process_draft_version_path(@process, draft_version) + else + render :phase_empty + end + else + render :phase_not_open + end end def allegations phase :allegations + + if @process.show_phase?(@phase) + if draft_version = @process.draft_versions.published.last + redirect_to legislation_process_draft_version_path(@process, draft_version) + else + render :phase_empty + end + else + render :phase_not_open + end end def final_version_publication phase :final_version_publication + + if @process.show_phase?(@phase) + if final_version = @process.final_draft_version + redirect_to legislation_process_draft_version_path(@process, final_version) + else + render :phase_empty + end + else + render :phase_not_open + end end private @@ -27,6 +62,5 @@ class Legislation::ProcessesController < Legislation::BaseController def phase(phase) @process = ::Legislation::Process.find(params[:process_id]) @phase = phase - render :phase end end diff --git a/app/views/legislation/processes/_phase_allegations.html.erb b/app/views/legislation/processes/_phase_allegations.html.erb deleted file mode 100644 index 0087b9ca5..000000000 --- a/app/views/legislation/processes/_phase_allegations.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -<% if process.draft_versions.any? %> - -<% else %> -

<%= t('.empty') %>

-<% end %> diff --git a/app/views/legislation/processes/_phase_draft_publication.html.erb b/app/views/legislation/processes/_phase_draft_publication.html.erb deleted file mode 100644 index 0087b9ca5..000000000 --- a/app/views/legislation/processes/_phase_draft_publication.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -<% if process.draft_versions.any? %> - -<% else %> -

<%= t('.empty') %>

-<% end %> diff --git a/app/views/legislation/processes/_phase_final_version_publication.html.erb b/app/views/legislation/processes/_phase_final_version_publication.html.erb deleted file mode 100644 index 52fba50d5..000000000 --- a/app/views/legislation/processes/_phase_final_version_publication.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<% if process.final_draft_version %> -

<%= legislation_process_draft_version_path(process.final_draft_version) %>

-<% else %> -

<%= t('.empty') %>

-<% end %> diff --git a/app/views/legislation/processes/_phase_not_open.html.erb b/app/views/legislation/processes/_phase_not_open.html.erb deleted file mode 100644 index 354ff5440..000000000 --- a/app/views/legislation/processes/_phase_not_open.html.erb +++ /dev/null @@ -1,13 +0,0 @@ -
-
-

<%= t('.not_open') %>

-

Suscríbete al proceso para recibir un aviso en el momento en que se abra.

-
- -
- -
-
diff --git a/app/views/legislation/processes/phase.html.erb b/app/views/legislation/processes/phase_empty.html.erb similarity index 60% rename from app/views/legislation/processes/phase.html.erb rename to app/views/legislation/processes/phase_empty.html.erb index 04ee25523..427339b82 100644 --- a/app/views/legislation/processes/phase.html.erb +++ b/app/views/legislation/processes/phase_empty.html.erb @@ -7,11 +7,7 @@
- <% if @process.show_phase?(@phase) %> - <%= render "phase_#{@phase}", process: @process %> - <% else %> - <%= render 'legislation/processes/phase_not_open' %> - <% end %> +

<%= t(".empty") %>

diff --git a/app/views/legislation/processes/phase_not_open.html.erb b/app/views/legislation/processes/phase_not_open.html.erb new file mode 100644 index 000000000..6bd82c969 --- /dev/null +++ b/app/views/legislation/processes/phase_not_open.html.erb @@ -0,0 +1,25 @@ +<% provide :title do %><%= @process.title %><% end %> + +<%= render 'legislation/processes/header_full', process: @process %> + +
+ <%= render 'legislation/processes/key_dates', process: @process, phase: @phase %> + +
+
+
+
+

<%= t('.not_open') %>

+

Suscríbete al proceso para recibir un aviso en el momento en que se abra.

+
+ +
+ +
+
+
+
+
diff --git a/app/views/legislation/processes/show.html.erb b/app/views/legislation/processes/show.html.erb index 471410b58..b24f7668b 100644 --- a/app/views/legislation/processes/show.html.erb +++ b/app/views/legislation/processes/show.html.erb @@ -7,11 +7,7 @@
- <% if @process.show_phase?(:debate) %> - <%= render 'debate', process: @process %> - <% else %> - <%= render 'phase_not_open' %> - <% end %> + <%= render 'debate', process: @process %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 8fa1cf13f..0e1a2c829 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -256,12 +256,8 @@ en: past: Past phase_not_open: not_open: This phase is not open yet - phase_draft_publication: - empty: There are no drafts published - phase_allegations: - empty: There are no drafts published - phase_final_version_publication: - empty: Results have not been published yet + phase_empty: + empty: Nothing published yet process: see_latest_comments: See latest comments see_latest_comments_title: Comment on this process diff --git a/config/locales/es.yml b/config/locales/es.yml index a93d44d2e..3459f3494 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -256,12 +256,8 @@ es: past: Terminados phase_not_open: not_open: Esta fase del proceso todavía no está abierta - phase_draft_publication: - empty: No se ha publicado ningún borrador - phase_allegations: - empty: No se ha publicado ningún borrador - phase_final_version_publication: - empty: No se ha publicado el resultado todavía + phase_empty: + empty: No hay nada publicado todavía process: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso diff --git a/spec/features/legislation/processes_spec.rb b/spec/features/legislation/processes_spec.rb index 818717757..8ae51c559 100644 --- a/spec/features/legislation/processes_spec.rb +++ b/spec/features/legislation/processes_spec.rb @@ -69,7 +69,7 @@ feature 'Legislation' do visit legislation_process_draft_publication_path(process) - expect(page).to have_content("There are no drafts published") + expect(page).to have_content("Nothing published yet") end end @@ -87,7 +87,7 @@ feature 'Legislation' do visit legislation_process_allegations_path(process) - expect(page).to have_content("There are no drafts published") + expect(page).to have_content("Nothing published yet") end end @@ -105,7 +105,7 @@ feature 'Legislation' do visit legislation_process_final_version_publication_path(process) - expect(page).to have_content("Results have not been published yet") + expect(page).to have_content("Nothing published yet") end end end