diff --git a/app/controllers/legislation/processes_controller.rb b/app/controllers/legislation/processes_controller.rb index a444f151e..af1ab147a 100644 --- a/app/controllers/legislation/processes_controller.rb +++ b/app/controllers/legislation/processes_controller.rb @@ -1,7 +1,10 @@ class Legislation::ProcessesController < Legislation::BaseController + has_filters %w{open next past}, only: :index load_and_authorize_resource def index + @current_filter ||= 'open' + @processes = ::Legislation::Process.send(@current_filter).page(params[:page]) end def show diff --git a/app/helpers/legislation_helper.rb b/app/helpers/legislation_helper.rb new file mode 100644 index 000000000..790e21a5b --- /dev/null +++ b/app/helpers/legislation_helper.rb @@ -0,0 +1,5 @@ +module LegislationHelper + def format_date(date) + l(date, format: "%d %b %Y") + end +end diff --git a/app/views/legislation/processes/_process.html.erb b/app/views/legislation/processes/_process.html.erb new file mode 100644 index 000000000..2053cac31 --- /dev/null +++ b/app/views/legislation/processes/_process.html.erb @@ -0,0 +1,41 @@ +
+
+
+
+

<%= link_to process.title, process %>

+

<%= process.description %>

+
+
+ +
+ <%= link_to process, class: "button button-legislation big expanded", title: t('.see_latest_comments_title') do %> +   <%= t('.see_latest_comments') %> + <% end %> +
+
+ +
+
+

<%= t('legislation.processes.common.key_dates') %>

+
+
+ +
+
+
<%= t('legislation.processes.common.debate_dates') %>
+

<%= format_date(process.debate_start_date) %> - <%= format_date(process.debate_end_date) %>

+
+
+
<%= t('legislation.processes.common.draft_publication_date') %>
+

<%= format_date(process.draft_publication_date) %>

+
+
+
<%= t('legislation.processes.common.allegations_dates') %>
+

<%= format_date(process.allegations_start_date) %> - <%= format_date(process.allegations_end_date) %>

+
+
+
<%= t('legislation.processes.common.final_publication_date') %>
+

<%= format_date(process.final_publication_date) %>

+
+
+
diff --git a/app/views/legislation/processes/index.html.erb b/app/views/legislation/processes/index.html.erb index fd9517c12..e145896a7 100644 --- a/app/views/legislation/processes/index.html.erb +++ b/app/views/legislation/processes/index.html.erb @@ -1,5 +1,22 @@ -
- <% @processes.each do |process| %> - <%= link_to process.title, process %>
- <% end %> +
+
+
+

+ <%= t('.hightlighted_processes') %> +

+
+
+
+ +
+
+ <%= render 'shared/filter_subnav', i18n_namespace: "legislation.processes.index" %> +
+ +
+
+ <%= render @processes %> + <%= paginate @processes %> +
+
diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index b4476329a..f1e75a86e 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -141,6 +141,7 @@ ignore_unused: - 'notifications.index.comments_on*' - 'notifications.index.replies_to*' - 'notifications.index.proposal_notification*' + - 'legislation.processes.index.filter*' - 'helpers.page_entries_info.*' # kaminari - 'views.pagination.*' # kaminari - 'shared.suggest.*' diff --git a/config/locales/en.yml b/config/locales/en.yml index 21d40f62f..bbf939da4 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -227,6 +227,22 @@ en: see_text: See text show: see_changes: See changes + processes: + common: + key_dates: "Key dates:" + debate_dates: Debate + draft_publication_date: Draft publication + allegations_dates: Allegations + final_publication_date: Final result publication + index: + hightlighted_processes: HIGHLIGHTED PROCESSES + filters: + open: Open processes + next: Next + past: Past + process: + see_latest_comments: See latest comments + see_latest_comments_title: Comment on this process locale: English notifications: index: diff --git a/config/locales/es.yml b/config/locales/es.yml index 226765184..4409b7ca0 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -227,6 +227,22 @@ es: see_text: Ver texto show: see_changes: Ver cambios + processes: + common: + key_dates: "Fechas clave:" + debate_dates: Debate previo + draft_publication_date: Publicación borrador + allegations_dates: Alegaciones + final_publication_date: Publicación resultados + index: + hightlighted_processes: PROCESOS DESTACADOS + filters: + open: Procesos activos + next: Próximamente + past: Terminados + process: + see_latest_comments: Ver últimas aportaciones + see_latest_comments_title: Aportar a este proceso locale: Español notifications: index: diff --git a/config/routes.rb b/config/routes.rb index 07200f76c..1f075f5b6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -88,8 +88,8 @@ Rails.application.routes.draw do namespace :legislation do resources :processes, only: [:index, :show] do resources :draft_versions, only: [:show] do - resources :annotations get :changes + resources :annotations end end end diff --git a/spec/factories.rb b/spec/factories.rb index b15676cce..5dd66b930 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -349,14 +349,36 @@ FactoryGirl.define do description "Description of the process" target "Who will affected by this law?" how_to_participate "You can participate by answering some questions" - start_date "2016-11-16" - end_date "2016-11-16" - debate_start_date "2016-11-16" - debate_end_date "2016-11-16" - draft_publication_date "2016-11-16" - allegations_start_date "2016-11-16" - allegations_end_date "2016-11-16" - final_publication_date "2016-11-16" + start_date Date.current - 5.days + end_date Date.current + 5.days + debate_start_date Date.current - 5.days + debate_end_date Date.current - 2.days + draft_publication_date Date.current - 1.day + allegations_start_date Date.current + allegations_end_date Date.current + 3.days + final_publication_date Date.current + 5.days + + trait :next do + start_date Date.current + 2.days + end_date Date.current + 8.days + debate_start_date Date.current + 2.days + debate_end_date Date.current + 4.days + draft_publication_date Date.current + 5.day + allegations_start_date Date.current + 5.days + allegations_end_date Date.current + 7.days + final_publication_date Date.current + 8.days + end + + trait :past do + start_date Date.current - 12.days + end_date Date.current - 2.days + debate_start_date Date.current - 12.days + debate_end_date Date.current - 9.days + draft_publication_date Date.current - 8.day + allegations_start_date Date.current - 8.days + allegations_end_date Date.current - 4.days + final_publication_date Date.current - 2.days + end end factory :legislation_draft_version, class: 'Legislation::DraftVersion' do diff --git a/spec/features/legislation/processes_spec.rb b/spec/features/legislation/processes_spec.rb new file mode 100644 index 000000000..2d3d0bdb8 --- /dev/null +++ b/spec/features/legislation/processes_spec.rb @@ -0,0 +1,38 @@ +require 'rails_helper' + +feature 'Legislation' do + + context 'processes#index' do + + scenario 'Processes can be listed' do + processes = create_list(:legislation_process, 3) + + visit legislation_processes_path + + processes.each do |process| + expect(page).to have_link(process.title) + end + end + + scenario 'Filtering processes' do + create(:legislation_process, title: "Process open") + create(:legislation_process, :next, title: "Process next") + create(:legislation_process, :past, title: "Process past") + + visit legislation_processes_path + expect(page).to have_content('Process open') + expect(page).to_not have_content('Process next') + expect(page).to_not have_content('Process past') + + visit legislation_processes_path(filter: 'next') + expect(page).to_not have_content('Process open') + expect(page).to have_content('Process next') + expect(page).to_not have_content('Process past') + + visit legislation_processes_path(filter: 'past') + expect(page).to_not have_content('Process open') + expect(page).to_not have_content('Process next') + expect(page).to have_content('Process past') + end + end +end