Merge pull request #17 from PopulateTools/5-legislation-processes-home-page
Legislation processes home page
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
class Legislation::ProcessesController < Legislation::BaseController
|
class Legislation::ProcessesController < Legislation::BaseController
|
||||||
|
has_filters %w{open next past}, only: :index
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@current_filter ||= 'open'
|
||||||
|
@processes = ::Legislation::Process.send(@current_filter).page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|||||||
5
app/helpers/legislation_helper.rb
Normal file
5
app/helpers/legislation_helper.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
module LegislationHelper
|
||||||
|
def format_date(date)
|
||||||
|
l(date, format: "%d %b %Y")
|
||||||
|
end
|
||||||
|
end
|
||||||
41
app/views/legislation/processes/_process.html.erb
Normal file
41
app/views/legislation/processes/_process.html.erb
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<div id="<%= dom_id(process) %>" class="legislation clear">
|
||||||
|
<div class="column row legislation-text">
|
||||||
|
<div class="small-12 medium-8 column">
|
||||||
|
<div class="legislation-text">
|
||||||
|
<h3><%= link_to process.title, process %></h3>
|
||||||
|
<p><%= process.description %></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="small-12 medium-4 column">
|
||||||
|
<%= link_to process, class: "button button-legislation big expanded", title: t('.see_latest_comments_title') do %>
|
||||||
|
<span class="icon-comments"></span> <%= t('.see_latest_comments') %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="column row">
|
||||||
|
<div class="small-12 column legislation-calendar-info">
|
||||||
|
<p><%= t('legislation.processes.common.key_dates') %></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="column row small-collapse medium-uncollapse legislation-calendar">
|
||||||
|
<div class="small-6 medium-3 column">
|
||||||
|
<h5><%= t('legislation.processes.common.debate_dates') %></h5>
|
||||||
|
<p><%= format_date(process.debate_start_date) %> - <%= format_date(process.debate_end_date) %></p>
|
||||||
|
</div>
|
||||||
|
<div class="small-6 medium-3 column">
|
||||||
|
<h5><%= t('legislation.processes.common.draft_publication_date') %></h5>
|
||||||
|
<p><%= format_date(process.draft_publication_date) %></p>
|
||||||
|
</div>
|
||||||
|
<div class="small-6 medium-3 column">
|
||||||
|
<h5><%= t('legislation.processes.common.allegations_dates') %></h5>
|
||||||
|
<p><%= format_date(process.allegations_start_date) %> - <%= format_date(process.allegations_end_date) %></p>
|
||||||
|
</div>
|
||||||
|
<div class="small-6 medium-3 column">
|
||||||
|
<h5><%= t('legislation.processes.common.final_publication_date') %></h5>
|
||||||
|
<p><%= format_date(process.final_publication_date) %></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,5 +1,22 @@
|
|||||||
<div class="row">
|
<div class="legislation-hero no-margin-top brand-heading">
|
||||||
<% @processes.each do |process| %>
|
<div class="row">
|
||||||
<%= link_to process.title, process %><br/>
|
<div class="small-12 medium-12 column padding">
|
||||||
<% end %>
|
<h4>
|
||||||
|
<%= t('.hightlighted_processes') %>
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="legislation-categories small-12 medium-3 column">
|
||||||
|
<%= render 'shared/filter_subnav', i18n_namespace: "legislation.processes.index" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="legislation" class="legislation-list small-12 medium-9 column">
|
||||||
|
<div id="legislation-list">
|
||||||
|
<%= render @processes %>
|
||||||
|
<%= paginate @processes %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ ignore_unused:
|
|||||||
- 'notifications.index.comments_on*'
|
- 'notifications.index.comments_on*'
|
||||||
- 'notifications.index.replies_to*'
|
- 'notifications.index.replies_to*'
|
||||||
- 'notifications.index.proposal_notification*'
|
- 'notifications.index.proposal_notification*'
|
||||||
|
- 'legislation.processes.index.filter*'
|
||||||
- 'helpers.page_entries_info.*' # kaminari
|
- 'helpers.page_entries_info.*' # kaminari
|
||||||
- 'views.pagination.*' # kaminari
|
- 'views.pagination.*' # kaminari
|
||||||
- 'shared.suggest.*'
|
- 'shared.suggest.*'
|
||||||
|
|||||||
@@ -227,6 +227,22 @@ en:
|
|||||||
see_text: See text
|
see_text: See text
|
||||||
show:
|
show:
|
||||||
see_changes: See changes
|
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
|
locale: English
|
||||||
notifications:
|
notifications:
|
||||||
index:
|
index:
|
||||||
|
|||||||
@@ -227,6 +227,22 @@ es:
|
|||||||
see_text: Ver texto
|
see_text: Ver texto
|
||||||
show:
|
show:
|
||||||
see_changes: Ver cambios
|
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
|
locale: Español
|
||||||
notifications:
|
notifications:
|
||||||
index:
|
index:
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ Rails.application.routes.draw do
|
|||||||
namespace :legislation do
|
namespace :legislation do
|
||||||
resources :processes, only: [:index, :show] do
|
resources :processes, only: [:index, :show] do
|
||||||
resources :draft_versions, only: [:show] do
|
resources :draft_versions, only: [:show] do
|
||||||
resources :annotations
|
|
||||||
get :changes
|
get :changes
|
||||||
|
resources :annotations
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -349,14 +349,36 @@ FactoryGirl.define do
|
|||||||
description "Description of the process"
|
description "Description of the process"
|
||||||
target "Who will affected by this law?"
|
target "Who will affected by this law?"
|
||||||
how_to_participate "You can participate by answering some questions"
|
how_to_participate "You can participate by answering some questions"
|
||||||
start_date "2016-11-16"
|
start_date Date.current - 5.days
|
||||||
end_date "2016-11-16"
|
end_date Date.current + 5.days
|
||||||
debate_start_date "2016-11-16"
|
debate_start_date Date.current - 5.days
|
||||||
debate_end_date "2016-11-16"
|
debate_end_date Date.current - 2.days
|
||||||
draft_publication_date "2016-11-16"
|
draft_publication_date Date.current - 1.day
|
||||||
allegations_start_date "2016-11-16"
|
allegations_start_date Date.current
|
||||||
allegations_end_date "2016-11-16"
|
allegations_end_date Date.current + 3.days
|
||||||
final_publication_date "2016-11-16"
|
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
|
end
|
||||||
|
|
||||||
factory :legislation_draft_version, class: 'Legislation::DraftVersion' do
|
factory :legislation_draft_version, class: 'Legislation::DraftVersion' do
|
||||||
|
|||||||
38
spec/features/legislation/processes_spec.rb
Normal file
38
spec/features/legislation/processes_spec.rb
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user