Merge pull request #3100 from consul/backport-2743-add_milestones_to_legislation_processes
Add milestones to legislation processes
This commit is contained in:
18
app/controllers/admin/legislation/milestones_controller.rb
Normal file
18
app/controllers/admin/legislation/milestones_controller.rb
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
class Admin::Legislation::MilestonesController < Admin::MilestonesController
|
||||||
|
include FeatureFlags
|
||||||
|
feature_flag :legislation
|
||||||
|
|
||||||
|
def index
|
||||||
|
@process = milestoneable
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def milestoneable
|
||||||
|
::Legislation::Process.find(params[:process_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def milestoneable_path
|
||||||
|
admin_legislation_process_milestones_path(milestoneable)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -87,6 +87,10 @@ class Legislation::ProcessesController < Legislation::BaseController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def milestones
|
||||||
|
@phase = :milestones
|
||||||
|
end
|
||||||
|
|
||||||
def proposals
|
def proposals
|
||||||
set_process
|
set_process
|
||||||
@phase = :proposals_phase
|
@phase = :proposals_phase
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ module LegislationHelper
|
|||||||
"info" => edit_admin_legislation_process_path(process),
|
"info" => edit_admin_legislation_process_path(process),
|
||||||
"questions" => admin_legislation_process_questions_path(process),
|
"questions" => admin_legislation_process_questions_path(process),
|
||||||
"proposals" => admin_legislation_process_proposals_path(process),
|
"proposals" => admin_legislation_process_proposals_path(process),
|
||||||
"draft_versions" => admin_legislation_process_draft_versions_path(process)
|
"draft_versions" => admin_legislation_process_draft_versions_path(process),
|
||||||
|
"milestones" => admin_legislation_process_milestones_path(process)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ module Abilities
|
|||||||
can [:read, :print, :json_data], Budget::Investment
|
can [:read, :print, :json_data], Budget::Investment
|
||||||
can [:read_results, :read_executions], Budget, phase: "finished"
|
can [:read_results, :read_executions], Budget, phase: "finished"
|
||||||
can :new, DirectMessage
|
can :new, DirectMessage
|
||||||
can [:read, :debate, :draft_publication, :allegations, :result_publication, :proposals], Legislation::Process, published: true
|
can [:read, :debate, :draft_publication, :allegations, :result_publication,
|
||||||
|
:proposals, :milestones], Legislation::Process, published: true
|
||||||
can [:read, :changes, :go_to_version], Legislation::DraftVersion
|
can [:read, :changes, :go_to_version], Legislation::DraftVersion
|
||||||
can [:read], Legislation::Question
|
can [:read], Legislation::Question
|
||||||
can [:read, :map, :share], Legislation::Proposal
|
can [:read, :map, :share], Legislation::Proposal
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
class Legislation::Process < ActiveRecord::Base
|
class Legislation::Process < ActiveRecord::Base
|
||||||
include ActsAsParanoidAliases
|
include ActsAsParanoidAliases
|
||||||
include Taggable
|
include Taggable
|
||||||
|
include Milestoneable
|
||||||
include Documentable
|
include Documentable
|
||||||
documentable max_documents_allowed: 3,
|
documentable max_documents_allowed: 3,
|
||||||
max_file_size: 3.megabytes,
|
max_file_size: 3.megabytes,
|
||||||
@@ -9,10 +10,11 @@ class Legislation::Process < ActiveRecord::Base
|
|||||||
acts_as_paranoid column: :hidden_at
|
acts_as_paranoid column: :hidden_at
|
||||||
acts_as_taggable_on :customs
|
acts_as_taggable_on :customs
|
||||||
|
|
||||||
translates :title, touch: true
|
translates :title, touch: true
|
||||||
translates :summary, touch: true
|
translates :summary, touch: true
|
||||||
translates :description, touch: true
|
translates :description, touch: true
|
||||||
translates :additional_info, touch: true
|
translates :additional_info, touch: true
|
||||||
|
translates :milestones_summary, touch: true
|
||||||
include Globalizable
|
include Globalizable
|
||||||
|
|
||||||
PHASES_AND_PUBLICATIONS = %i(draft_phase debate_phase allegations_phase proposals_phase draft_publication result_publication).freeze
|
PHASES_AND_PUBLICATIONS = %i(draft_phase debate_phase allegations_phase proposals_phase draft_publication result_publication).freeze
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<%= render "admin/shared/globalize_locales", resource: @process %>
|
||||||
|
|
||||||
|
<%= translatable_form_for [:admin, @process] do |f| %>
|
||||||
|
<%= f.translatable_fields do |translations_form| %>
|
||||||
|
<div class="ckeditor">
|
||||||
|
<%= translations_form.cktext_area :milestones_summary, ckeditor: { language: I18n.locale } %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= f.submit class: "button success" %>
|
||||||
|
<% end %>
|
||||||
12
app/views/admin/legislation/milestones/index.html.erb
Normal file
12
app/views/admin/legislation/milestones/index.html.erb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<% provide :title do %>
|
||||||
|
<%= "#{t("admin.header.title")} - #{t("admin.menu.legislation")}" %> -
|
||||||
|
<%= "#{@process.title} - #{t("admin.legislation.milestones.index.title")}" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= back_link_to admin_legislation_processes_path, t("admin.legislation.processes.edit.back") %>
|
||||||
|
|
||||||
|
<h2><%= @process.title %></h2>
|
||||||
|
|
||||||
|
<%= render "admin/legislation/processes/subnav", process: @process, active: "milestones" %>
|
||||||
|
<%= render "summary_form", process: @process %>
|
||||||
|
<%= render "admin/milestones/milestones", milestoneable: @process %>
|
||||||
@@ -49,6 +49,15 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% if process.milestones.any? %>
|
||||||
|
<li class="milestones <%= "is-active" if phase == :milestones %>">
|
||||||
|
<%= link_to milestones_legislation_process_path(process) do %>
|
||||||
|
<h4><%= t("legislation.processes.shared.milestones_date") %></h4>
|
||||||
|
<p><%= format_date(process.milestones.order_by_publication_date.last.publication_date) %></p>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
15
app/views/legislation/processes/milestones.html.erb
Normal file
15
app/views/legislation/processes/milestones.html.erb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<% provide(:title) { @process.title } %>
|
||||||
|
|
||||||
|
<%= render "legislation/processes/header", process: @process, header: :full %>
|
||||||
|
|
||||||
|
<%= render "key_dates", process: @process, phase: @phase %>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="small-12 column">
|
||||||
|
<%= WYSIWYGSanitizer.new.sanitize(@process.milestones_summary) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="tab-milestones">
|
||||||
|
<%= render "milestones/milestones_content", milestoneable: @process %>
|
||||||
|
</div>
|
||||||
@@ -1,18 +1,3 @@
|
|||||||
<div class="tabs-panel tab-milestones" id="tab-milestones">
|
<div class="tabs-panel tab-milestones" id="tab-milestones">
|
||||||
<div class="row">
|
<%= render "milestones/milestones_content", milestoneable: milestoneable %>
|
||||||
<div class="small-12 column">
|
|
||||||
<% if milestoneable.milestones.blank? %>
|
|
||||||
<div class="callout primary text-center">
|
|
||||||
<%= t("milestones.index.no_milestones") %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<section class="timeline">
|
|
||||||
<ul class="no-bullet">
|
|
||||||
<% milestoneable.milestones.order_by_publication_date.each do |milestone| %>
|
|
||||||
<%= render "milestones/milestone", milestone: milestone %>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
16
app/views/milestones/_milestones_content.html.erb
Normal file
16
app/views/milestones/_milestones_content.html.erb
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="small-12 column">
|
||||||
|
<% if milestoneable.milestones.blank? %>
|
||||||
|
<div class="callout primary text-center">
|
||||||
|
<%= t("milestones.index.no_milestones") %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<section class="timeline">
|
||||||
|
<ul class="no-bullet">
|
||||||
|
<% milestoneable.milestones.order_by_publication_date.each do |milestone| %>
|
||||||
|
<%= render "milestones/milestone", milestone: milestone %>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -239,6 +239,7 @@ en:
|
|||||||
summary: Summary
|
summary: Summary
|
||||||
description: Description
|
description: Description
|
||||||
additional_info: Additional info
|
additional_info: Additional info
|
||||||
|
milestones_summary: Summary
|
||||||
legislation/draft_version:
|
legislation/draft_version:
|
||||||
title: Version title
|
title: Version title
|
||||||
body: Text
|
body: Text
|
||||||
|
|||||||
@@ -422,6 +422,7 @@ en:
|
|||||||
draft_versions: Drafting
|
draft_versions: Drafting
|
||||||
questions: Debate
|
questions: Debate
|
||||||
proposals: Proposals
|
proposals: Proposals
|
||||||
|
milestones: Following
|
||||||
proposals:
|
proposals:
|
||||||
index:
|
index:
|
||||||
title: Proposals
|
title: Proposals
|
||||||
@@ -520,6 +521,9 @@ en:
|
|||||||
comments_count: Comments count
|
comments_count: Comments count
|
||||||
question_option_fields:
|
question_option_fields:
|
||||||
remove_option: Remove option
|
remove_option: Remove option
|
||||||
|
milestones:
|
||||||
|
index:
|
||||||
|
title: Following
|
||||||
managers:
|
managers:
|
||||||
index:
|
index:
|
||||||
title: Managers
|
title: Managers
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ en:
|
|||||||
draft_publication_date: Draft publication
|
draft_publication_date: Draft publication
|
||||||
allegations_dates: Comments
|
allegations_dates: Comments
|
||||||
result_publication_date: Final result publication
|
result_publication_date: Final result publication
|
||||||
|
milestones_date: Following
|
||||||
proposals_dates: Proposals
|
proposals_dates: Proposals
|
||||||
questions:
|
questions:
|
||||||
comments:
|
comments:
|
||||||
|
|||||||
@@ -239,6 +239,7 @@ es:
|
|||||||
summary: Resumen
|
summary: Resumen
|
||||||
description: En qué consiste
|
description: En qué consiste
|
||||||
additional_info: Información adicional
|
additional_info: Información adicional
|
||||||
|
milestones_summary: Seguimiento del proceso
|
||||||
legislation/draft_version:
|
legislation/draft_version:
|
||||||
title: Título de la version
|
title: Título de la version
|
||||||
body: Texto
|
body: Texto
|
||||||
|
|||||||
@@ -419,6 +419,7 @@ es:
|
|||||||
draft_versions: Redacción
|
draft_versions: Redacción
|
||||||
questions: Debate
|
questions: Debate
|
||||||
proposals: Propuestas
|
proposals: Propuestas
|
||||||
|
milestones: Seguimiento
|
||||||
proposals:
|
proposals:
|
||||||
index:
|
index:
|
||||||
title: Título
|
title: Título
|
||||||
@@ -516,6 +517,9 @@ es:
|
|||||||
comments_count: Número de comentarios
|
comments_count: Número de comentarios
|
||||||
question_option_fields:
|
question_option_fields:
|
||||||
remove_option: Eliminar
|
remove_option: Eliminar
|
||||||
|
milestones:
|
||||||
|
index:
|
||||||
|
title: Seguimiento
|
||||||
managers:
|
managers:
|
||||||
index:
|
index:
|
||||||
title: Gestores
|
title: Gestores
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ es:
|
|||||||
draft_publication_date: Publicación borrador
|
draft_publication_date: Publicación borrador
|
||||||
allegations_dates: Comentarios
|
allegations_dates: Comentarios
|
||||||
result_publication_date: Publicación resultados
|
result_publication_date: Publicación resultados
|
||||||
|
milestones_date: Seguimiento
|
||||||
proposals_dates: Propuestas
|
proposals_dates: Propuestas
|
||||||
questions:
|
questions:
|
||||||
comments:
|
comments:
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ namespace :admin do
|
|||||||
member { patch :toggle_selection }
|
member { patch :toggle_selection }
|
||||||
end
|
end
|
||||||
resources :draft_versions
|
resources :draft_versions
|
||||||
|
resources :milestones
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace :legislation do
|
|||||||
get :allegations
|
get :allegations
|
||||||
get :result_publication
|
get :result_publication
|
||||||
get :proposals
|
get :proposals
|
||||||
|
get :milestones
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :questions, only: [:show] do
|
resources :questions, only: [:show] do
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class AddMilestonesSummaryToLegislationProcessTranslation < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :legislation_process_translations, :milestones_summary, :text
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20181109111037) do
|
ActiveRecord::Schema.define(version: 20181121123512) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -630,6 +630,7 @@ ActiveRecord::Schema.define(version: 20181109111037) do
|
|||||||
t.text "summary"
|
t.text "summary"
|
||||||
t.text "description"
|
t.text "description"
|
||||||
t.text "additional_info"
|
t.text "additional_info"
|
||||||
|
t.text "milestones_summary"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "legislation_process_translations", ["legislation_process_id"], name: "index_199e5fed0aca73302243f6a1fca885ce10cdbb55", using: :btree
|
add_index "legislation_process_translations", ["legislation_process_id"], name: "index_199e5fed0aca73302243f6a1fca885ce10cdbb55", using: :btree
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ feature 'Admin legislation processes' do
|
|||||||
"edit_admin_legislation_process_path",
|
"edit_admin_legislation_process_path",
|
||||||
%w[title summary description additional_info]
|
%w[title summary description additional_info]
|
||||||
|
|
||||||
|
it_behaves_like "admin_milestoneable",
|
||||||
|
:legislation_process,
|
||||||
|
"admin_legislation_process_milestones_path"
|
||||||
|
|
||||||
context "Feature flag" do
|
context "Feature flag" do
|
||||||
|
|
||||||
scenario 'Disabled with a feature flag' do
|
scenario 'Disabled with a feature flag' do
|
||||||
@@ -184,5 +188,22 @@ feature 'Admin legislation processes' do
|
|||||||
visit admin_legislation_process_proposals_path(process)
|
visit admin_legislation_process_proposals_path(process)
|
||||||
expect(page).to have_field("Categories", with: "bicycles, recycling")
|
expect(page).to have_field("Categories", with: "bicycles, recycling")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Edit milestones summary", :js do
|
||||||
|
visit admin_legislation_process_milestones_path(process)
|
||||||
|
|
||||||
|
within(".translatable-fields[data-locale='en']") do
|
||||||
|
fill_in_ckeditor find("textarea", visible: false)[:id],
|
||||||
|
with: "There is still a long journey ahead of us"
|
||||||
|
end
|
||||||
|
|
||||||
|
click_button "Update Process"
|
||||||
|
|
||||||
|
expect(page).to have_current_path admin_legislation_process_milestones_path(process)
|
||||||
|
|
||||||
|
visit milestones_legislation_process_path(process)
|
||||||
|
|
||||||
|
expect(page).to have_content "There is still a long journey ahead of us"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -292,5 +292,40 @@ feature 'Legislation' do
|
|||||||
|
|
||||||
include_examples "not published permissions", :legislation_process_proposals_path
|
include_examples "not published permissions", :legislation_process_proposals_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "Milestones" do
|
||||||
|
scenario "Without milestones" do
|
||||||
|
process = create(:legislation_process, :upcoming_proposals_phase)
|
||||||
|
|
||||||
|
visit legislation_process_path(process)
|
||||||
|
|
||||||
|
within(".legislation-process-list") do
|
||||||
|
expect(page).not_to have_css "li.milestones"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "With milestones" do
|
||||||
|
process = create(:legislation_process, :upcoming_proposals_phase)
|
||||||
|
create(:milestone,
|
||||||
|
milestoneable: process,
|
||||||
|
description: "Something important happened",
|
||||||
|
publication_date: Date.new(2018, 3, 22)
|
||||||
|
)
|
||||||
|
|
||||||
|
visit legislation_process_path(process)
|
||||||
|
|
||||||
|
within(".legislation-process-list li.milestones") do
|
||||||
|
click_link "Following 22 Mar 2018"
|
||||||
|
end
|
||||||
|
|
||||||
|
within(".legislation-process-list .is-active") do
|
||||||
|
expect(page).to have_link "Following 22 Mar 2018"
|
||||||
|
end
|
||||||
|
|
||||||
|
within(".tab-milestones") do
|
||||||
|
expect(page).to have_content "Something important happened"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user