diff --git a/app/controllers/admin/legislation/milestones_controller.rb b/app/controllers/admin/legislation/milestones_controller.rb
new file mode 100644
index 000000000..09d55f6ca
--- /dev/null
+++ b/app/controllers/admin/legislation/milestones_controller.rb
@@ -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
diff --git a/app/controllers/legislation/processes_controller.rb b/app/controllers/legislation/processes_controller.rb
index fd301fb07..53addd566 100644
--- a/app/controllers/legislation/processes_controller.rb
+++ b/app/controllers/legislation/processes_controller.rb
@@ -87,6 +87,10 @@ class Legislation::ProcessesController < Legislation::BaseController
end
end
+ def milestones
+ @phase = :milestones
+ end
+
def proposals
set_process
@phase = :proposals_phase
diff --git a/app/helpers/legislation_helper.rb b/app/helpers/legislation_helper.rb
index b2cd1399c..0fc045c16 100644
--- a/app/helpers/legislation_helper.rb
+++ b/app/helpers/legislation_helper.rb
@@ -32,7 +32,8 @@ module LegislationHelper
"info" => edit_admin_legislation_process_path(process),
"questions" => admin_legislation_process_questions_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
diff --git a/app/models/abilities/everyone.rb b/app/models/abilities/everyone.rb
index 18927cc80..ab5a095e0 100644
--- a/app/models/abilities/everyone.rb
+++ b/app/models/abilities/everyone.rb
@@ -24,7 +24,8 @@ module Abilities
can [:read, :print, :json_data], Budget::Investment
can [:read_results, :read_executions], Budget, phase: "finished"
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], Legislation::Question
can [:read, :map, :share], Legislation::Proposal
diff --git a/app/models/legislation/process.rb b/app/models/legislation/process.rb
index 4e506de1f..4cff200b5 100644
--- a/app/models/legislation/process.rb
+++ b/app/models/legislation/process.rb
@@ -1,6 +1,7 @@
class Legislation::Process < ActiveRecord::Base
include ActsAsParanoidAliases
include Taggable
+ include Milestoneable
include Documentable
documentable max_documents_allowed: 3,
max_file_size: 3.megabytes,
@@ -9,10 +10,11 @@ class Legislation::Process < ActiveRecord::Base
acts_as_paranoid column: :hidden_at
acts_as_taggable_on :customs
- translates :title, touch: true
- translates :summary, touch: true
- translates :description, touch: true
- translates :additional_info, touch: true
+ translates :title, touch: true
+ translates :summary, touch: true
+ translates :description, touch: true
+ translates :additional_info, touch: true
+ translates :milestones_summary, touch: true
include Globalizable
PHASES_AND_PUBLICATIONS = %i(draft_phase debate_phase allegations_phase proposals_phase draft_publication result_publication).freeze
diff --git a/app/views/admin/legislation/milestones/_summary_form.html.erb b/app/views/admin/legislation/milestones/_summary_form.html.erb
new file mode 100644
index 000000000..0adb00ecc
--- /dev/null
+++ b/app/views/admin/legislation/milestones/_summary_form.html.erb
@@ -0,0 +1,11 @@
+<%= render "admin/shared/globalize_locales", resource: @process %>
+
+<%= translatable_form_for [:admin, @process] do |f| %>
+ <%= f.translatable_fields do |translations_form| %>
+
+ <%= translations_form.cktext_area :milestones_summary, ckeditor: { language: I18n.locale } %>
+
+ <% end %>
+
+ <%= f.submit class: "button success" %>
+<% end %>
diff --git a/app/views/admin/legislation/milestones/index.html.erb b/app/views/admin/legislation/milestones/index.html.erb
new file mode 100644
index 000000000..456b6154a
--- /dev/null
+++ b/app/views/admin/legislation/milestones/index.html.erb
@@ -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") %>
+
+<%= @process.title %>
+
+<%= render "admin/legislation/processes/subnav", process: @process, active: "milestones" %>
+<%= render "summary_form", process: @process %>
+<%= render "admin/milestones/milestones", milestoneable: @process %>
diff --git a/app/views/legislation/processes/_key_dates.html.erb b/app/views/legislation/processes/_key_dates.html.erb
index 0ada8de08..6fbea5053 100644
--- a/app/views/legislation/processes/_key_dates.html.erb
+++ b/app/views/legislation/processes/_key_dates.html.erb
@@ -49,6 +49,15 @@
<% end %>
<% end %>
+
+ <% if process.milestones.any? %>
+ ">
+ <%= link_to milestones_legislation_process_path(process) do %>
+ <%= t("legislation.processes.shared.milestones_date") %>
+ <%= format_date(process.milestones.order_by_publication_date.last.publication_date) %>
+ <% end %>
+
+ <% end %>
diff --git a/app/views/legislation/processes/milestones.html.erb b/app/views/legislation/processes/milestones.html.erb
new file mode 100644
index 000000000..8ea3b6c9b
--- /dev/null
+++ b/app/views/legislation/processes/milestones.html.erb
@@ -0,0 +1,15 @@
+<% provide(:title) { @process.title } %>
+
+<%= render "legislation/processes/header", process: @process, header: :full %>
+
+<%= render "key_dates", process: @process, phase: @phase %>
+
+
+
+ <%= WYSIWYGSanitizer.new.sanitize(@process.milestones_summary) %>
+
+
+
+
+ <%= render "milestones/milestones_content", milestoneable: @process %>
+
diff --git a/app/views/milestones/_milestones.html.erb b/app/views/milestones/_milestones.html.erb
index 7ec843077..0992d1a2e 100644
--- a/app/views/milestones/_milestones.html.erb
+++ b/app/views/milestones/_milestones.html.erb
@@ -1,18 +1,3 @@
-
-
- <% if milestoneable.milestones.blank? %>
-
- <%= t("milestones.index.no_milestones") %>
-
- <% end %>
-
-
- <% milestoneable.milestones.order_by_publication_date.each do |milestone| %>
- <%= render "milestones/milestone", milestone: milestone %>
- <% end %>
-
-
-
-
+ <%= render "milestones/milestones_content", milestoneable: milestoneable %>
diff --git a/app/views/milestones/_milestones_content.html.erb b/app/views/milestones/_milestones_content.html.erb
new file mode 100644
index 000000000..3e23f8a35
--- /dev/null
+++ b/app/views/milestones/_milestones_content.html.erb
@@ -0,0 +1,16 @@
+
+
+ <% if milestoneable.milestones.blank? %>
+
+ <%= t("milestones.index.no_milestones") %>
+
+ <% end %>
+
+
+ <% milestoneable.milestones.order_by_publication_date.each do |milestone| %>
+ <%= render "milestones/milestone", milestone: milestone %>
+ <% end %>
+
+
+
+
diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml
index 6f21668c1..43415ff91 100644
--- a/config/locales/en/activerecord.yml
+++ b/config/locales/en/activerecord.yml
@@ -239,6 +239,7 @@ en:
summary: Summary
description: Description
additional_info: Additional info
+ milestones_summary: Summary
legislation/draft_version:
title: Version title
body: Text
diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml
index cd99283ce..e5820b222 100644
--- a/config/locales/en/admin.yml
+++ b/config/locales/en/admin.yml
@@ -422,6 +422,7 @@ en:
draft_versions: Drafting
questions: Debate
proposals: Proposals
+ milestones: Following
proposals:
index:
title: Proposals
@@ -520,6 +521,9 @@ en:
comments_count: Comments count
question_option_fields:
remove_option: Remove option
+ milestones:
+ index:
+ title: Following
managers:
index:
title: Managers
diff --git a/config/locales/en/legislation.yml b/config/locales/en/legislation.yml
index bd3ed87c1..ed142fd49 100644
--- a/config/locales/en/legislation.yml
+++ b/config/locales/en/legislation.yml
@@ -87,6 +87,7 @@ en:
draft_publication_date: Draft publication
allegations_dates: Comments
result_publication_date: Final result publication
+ milestones_date: Following
proposals_dates: Proposals
questions:
comments:
diff --git a/config/locales/es/activerecord.yml b/config/locales/es/activerecord.yml
index bf4133daa..bbb0b358a 100644
--- a/config/locales/es/activerecord.yml
+++ b/config/locales/es/activerecord.yml
@@ -239,6 +239,7 @@ es:
summary: Resumen
description: En qué consiste
additional_info: Información adicional
+ milestones_summary: Seguimiento del proceso
legislation/draft_version:
title: Título de la version
body: Texto
diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml
index cc0d99b7e..6c37af551 100644
--- a/config/locales/es/admin.yml
+++ b/config/locales/es/admin.yml
@@ -419,6 +419,7 @@ es:
draft_versions: Redacción
questions: Debate
proposals: Propuestas
+ milestones: Seguimiento
proposals:
index:
title: Título
@@ -516,6 +517,9 @@ es:
comments_count: Número de comentarios
question_option_fields:
remove_option: Eliminar
+ milestones:
+ index:
+ title: Seguimiento
managers:
index:
title: Gestores
diff --git a/config/locales/es/legislation.yml b/config/locales/es/legislation.yml
index 03f4724fd..766089a43 100644
--- a/config/locales/es/legislation.yml
+++ b/config/locales/es/legislation.yml
@@ -87,6 +87,7 @@ es:
draft_publication_date: Publicación borrador
allegations_dates: Comentarios
result_publication_date: Publicación resultados
+ milestones_date: Seguimiento
proposals_dates: Propuestas
questions:
comments:
diff --git a/config/routes/admin.rb b/config/routes/admin.rb
index b37714f47..fac6e7d74 100644
--- a/config/routes/admin.rb
+++ b/config/routes/admin.rb
@@ -202,6 +202,7 @@ namespace :admin do
member { patch :toggle_selection }
end
resources :draft_versions
+ resources :milestones
end
end
diff --git a/config/routes/legislation.rb b/config/routes/legislation.rb
index a38dfcac5..d5054e2d4 100644
--- a/config/routes/legislation.rb
+++ b/config/routes/legislation.rb
@@ -6,6 +6,7 @@ namespace :legislation do
get :allegations
get :result_publication
get :proposals
+ get :milestones
end
resources :questions, only: [:show] do
diff --git a/db/migrate/20181121123512_add_milestones_summary_to_legislation_process_translation.rb b/db/migrate/20181121123512_add_milestones_summary_to_legislation_process_translation.rb
new file mode 100644
index 000000000..c93b5d3fa
--- /dev/null
+++ b/db/migrate/20181121123512_add_milestones_summary_to_legislation_process_translation.rb
@@ -0,0 +1,5 @@
+class AddMilestonesSummaryToLegislationProcessTranslation < ActiveRecord::Migration
+ def change
+ add_column :legislation_process_translations, :milestones_summary, :text
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index f89f9641d..c9b94c457 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# 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
enable_extension "plpgsql"
@@ -630,6 +630,7 @@ ActiveRecord::Schema.define(version: 20181109111037) do
t.text "summary"
t.text "description"
t.text "additional_info"
+ t.text "milestones_summary"
end
add_index "legislation_process_translations", ["legislation_process_id"], name: "index_199e5fed0aca73302243f6a1fca885ce10cdbb55", using: :btree
diff --git a/spec/features/admin/legislation/processes_spec.rb b/spec/features/admin/legislation/processes_spec.rb
index f9e575d3d..0599c40ce 100644
--- a/spec/features/admin/legislation/processes_spec.rb
+++ b/spec/features/admin/legislation/processes_spec.rb
@@ -12,6 +12,10 @@ feature 'Admin legislation processes' do
"edit_admin_legislation_process_path",
%w[title summary description additional_info]
+ it_behaves_like "admin_milestoneable",
+ :legislation_process,
+ "admin_legislation_process_milestones_path"
+
context "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)
expect(page).to have_field("Categories", with: "bicycles, recycling")
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
diff --git a/spec/features/legislation/processes_spec.rb b/spec/features/legislation/processes_spec.rb
index aa0b55f6e..d4a38d63d 100644
--- a/spec/features/legislation/processes_spec.rb
+++ b/spec/features/legislation/processes_spec.rb
@@ -292,5 +292,40 @@ feature 'Legislation' do
include_examples "not published permissions", :legislation_process_proposals_path
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