From 0c5063add9daec0402d2abcfb5aa18085da5685a Mon Sep 17 00:00:00 2001 From: Fernando Blat Date: Thu, 5 Jan 2017 09:36:08 +0100 Subject: [PATCH 01/16] Show message when there aren't processes --- app/views/legislation/processes/index.html.erb | 8 ++++++-- config/locales/en.yml | 3 +++ config/locales/es.yml | 3 +++ spec/features/legislation/processes_spec.rb | 11 +++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/views/legislation/processes/index.html.erb b/app/views/legislation/processes/index.html.erb index 1400f7854..1d2e6caa3 100644 --- a/app/views/legislation/processes/index.html.erb +++ b/app/views/legislation/processes/index.html.erb @@ -19,8 +19,12 @@
- <%= render @processes %> - <%= paginate @processes %> + <% if @processes.any? %> + <%= render @processes %> + <%= paginate @processes %> + <% else %> + <%= t(".no_#{@current_filter}_processes") %> + <% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 0e1a2c829..f192a441c 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -254,6 +254,9 @@ en: open: Open processes next: Next past: Past + no_open_processes: There aren't open processes + no_next_processes: There aren't planned processes + no_past_processes: There aren't past processes phase_not_open: not_open: This phase is not open yet phase_empty: diff --git a/config/locales/es.yml b/config/locales/es.yml index 3459f3494..eabc14e48 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -254,6 +254,9 @@ es: open: Procesos activos next: Próximamente past: Terminados + no_open_processes: No hay procesos activos + no_next_processes: No hay procesos planeados + no_past_processes: No hay procesos terminados phase_not_open: not_open: Esta fase del proceso todavía no está abierta phase_empty: diff --git a/spec/features/legislation/processes_spec.rb b/spec/features/legislation/processes_spec.rb index 8ae51c559..66356dff8 100644 --- a/spec/features/legislation/processes_spec.rb +++ b/spec/features/legislation/processes_spec.rb @@ -4,6 +4,17 @@ feature 'Legislation' do context 'processes home page' do + scenario 'Processes can be listed' do + visit legislation_processes_path + expect(page).to have_text "There aren't open processes" + + visit legislation_processes_path(filter: 'next') + expect(page).to have_text "There aren't planned processes" + + visit legislation_processes_path(filter: 'past') + expect(page).to have_text "There aren't past processes" + end + scenario 'Processes can be listed' do processes = create_list(:legislation_process, 3) From fba4c79d2abf6c9a0f02d95e88441240ea46e6bc Mon Sep 17 00:00:00 2001 From: Fernando Blat Date: Thu, 5 Jan 2017 09:43:40 +0100 Subject: [PATCH 02/16] Show the first paragraph of the description --- app/helpers/text_helper.rb | 9 +++++++++ .../legislation/processes/_process.html.erb | 2 +- spec/helpers/text_helper_spec.rb | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 app/helpers/text_helper.rb create mode 100644 spec/helpers/text_helper_spec.rb diff --git a/app/helpers/text_helper.rb b/app/helpers/text_helper.rb new file mode 100644 index 000000000..dda3ba721 --- /dev/null +++ b/app/helpers/text_helper.rb @@ -0,0 +1,9 @@ +module TextHelper + def first_paragraph(text) + if text.blank? + "" + else + text.strip.split("\n").first + end + end +end diff --git a/app/views/legislation/processes/_process.html.erb b/app/views/legislation/processes/_process.html.erb index 9eac89a7b..a5780f792 100644 --- a/app/views/legislation/processes/_process.html.erb +++ b/app/views/legislation/processes/_process.html.erb @@ -3,7 +3,7 @@

<%= link_to process.title, process %>

-

<%= process.description %>

+ <%= simple_format(first_paragraph(process.description)) %>
diff --git a/spec/helpers/text_helper_spec.rb b/spec/helpers/text_helper_spec.rb new file mode 100644 index 000000000..cc9300b7f --- /dev/null +++ b/spec/helpers/text_helper_spec.rb @@ -0,0 +1,17 @@ +require 'rails_helper' + +describe TextHelper do + + describe "#first_paragraph" do + it "should return the first paragraph of a text" do + text = "\n\nThis is the first paragraph\n\nThis is the second paragraph\n" + expect(first_paragraph(text)).to eq("This is the first paragraph") + end + + it "should return blank if the text is blank" do + expect(first_paragraph("")).to eq("") + expect(first_paragraph(nil)).to eq("") + end + end + +end From 814cf9df564c9b5f8075c8fe2da04bcb3bd298f4 Mon Sep 17 00:00:00 2001 From: Fernando Blat Date: Thu, 5 Jan 2017 10:22:40 +0100 Subject: [PATCH 03/16] Show creation date and status in admin list --- app/models/legislation/process.rb | 12 +++++++ .../legislation/processes/index.html.erb | 4 +++ config/locales/admin.en.yml | 5 +++ config/locales/admin.es.yml | 5 +++ spec/models/legislation/process_spec.rb | 35 ++++++++++--------- 5 files changed, 44 insertions(+), 17 deletions(-) diff --git a/app/models/legislation/process.rb b/app/models/legislation/process.rb index 4a50b4b0a..0a264203c 100644 --- a/app/models/legislation/process.rb +++ b/app/models/legislation/process.rb @@ -59,6 +59,18 @@ class Legislation::Process < ActiveRecord::Base questions.map(&:comments_count).sum end + def status + today = Date.current + + if today < start_date + :planned + elsif end_date < today + :closed + else + :open + end + end + private def valid_date_ranges diff --git a/app/views/admin/legislation/processes/index.html.erb b/app/views/admin/legislation/processes/index.html.erb index 7d4bd2996..a4a0a7f3e 100644 --- a/app/views/admin/legislation/processes/index.html.erb +++ b/app/views/admin/legislation/processes/index.html.erb @@ -20,6 +20,8 @@ <%= t("admin.legislation.processes.process.title") %> + <%= t("admin.legislation.processes.process.status") %> + <%= t("admin.legislation.processes.process.creation_date") %> <%= t("admin.legislation.processes.process.comments") %> @@ -30,6 +32,8 @@ <%= link_to process.title, edit_admin_legislation_process_path(process) %> + <%= t("admin.legislation.processes.process.status_#{process.status}") %> + <%= I18n.l process.created_at.to_date %> <%= process.total_comments %> <%= link_to t("admin.legislation.processes.index.delete"), admin_legislation_process_path(process), diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index a0896d6c4..efef17210 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -113,6 +113,11 @@ en: process: title: Process comments: Comments + status: Status + creation_date: Creation date + status_open: Open + status_closed: Closed + status_planned: Planned subnav: info: Information draft_texts: Text diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 94676c9f0..92503fa68 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -111,6 +111,11 @@ es: process: title: Proceso comments: Comentarios + status: Estado + creation_date: Fecha creación + status_open: Abierto + status_closed: Cerrado + status_planned: Próximamente subnav: info: Información draft_texts: Texto diff --git a/spec/models/legislation/process_spec.rb b/spec/models/legislation/process_spec.rb index 4fbfeb587..fd83d8989 100644 --- a/spec/models/legislation/process_spec.rb +++ b/spec/models/legislation/process_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe Legislation::Process, type: :model do - let(:legislation_process) { build(:legislation_process) } + let(:process) { create(:legislation_process) } it "should be valid" do - expect(legislation_process).to be_valid + expect(process).to be_valid end describe "date ranges validations" do @@ -76,8 +76,6 @@ RSpec.describe Legislation::Process, type: :model do describe "#open_phase?" do it "checks debate phase" do - process = create(:legislation_process) - # future process.update_attributes(debate_start_date: Date.current + 2.days, debate_end_date: Date.current + 3.days) expect(process.open_phase?(:debate)).to be false @@ -96,7 +94,6 @@ RSpec.describe Legislation::Process, type: :model do end it "checks allegations phase" do - process = create(:legislation_process) # future process.update_attributes(allegations_start_date: Date.current + 2.days, allegations_end_date: Date.current + 3.days) @@ -116,8 +113,6 @@ RSpec.describe Legislation::Process, type: :model do end it "checks draft publication phase" do - process = create(:legislation_process) - # future process.update_attributes(draft_publication_date: Date.current + 2.days) expect(process.open_phase?(:draft_publication)).to be false @@ -132,8 +127,6 @@ RSpec.describe Legislation::Process, type: :model do end it "checks final version publication phase" do - process = create(:legislation_process) - # future process.update_attributes(final_publication_date: Date.current + 2.days) expect(process.open_phase?(:final_version_publication)).to be false @@ -150,8 +143,6 @@ RSpec.describe Legislation::Process, type: :model do describe "#show_phase?" do it "checks debate phase" do - process = create(:legislation_process) - # future process.update_attributes(debate_start_date: Date.current + 2.days, debate_end_date: Date.current + 3.days) expect(process.show_phase?(:debate)).to be false @@ -170,8 +161,6 @@ RSpec.describe Legislation::Process, type: :model do end it "checks allegations phase" do - process = create(:legislation_process) - # future process.update_attributes(allegations_start_date: Date.current + 2.days, allegations_end_date: Date.current + 3.days) expect(process.show_phase?(:allegations)).to be false @@ -190,8 +179,6 @@ RSpec.describe Legislation::Process, type: :model do end it "checks draft publication phase" do - process = create(:legislation_process) - # future process.update_attributes(draft_publication_date: Date.current + 2.days) expect(process.show_phase?(:draft_publication)).to be false @@ -206,8 +193,6 @@ RSpec.describe Legislation::Process, type: :model do end it "checks final version publication phase" do - process = create(:legislation_process) - # future process.update_attributes(final_publication_date: Date.current + 2.days) expect(process.show_phase?(:final_version_publication)).to be false @@ -221,4 +206,20 @@ RSpec.describe Legislation::Process, type: :model do expect(process.show_phase?(:final_version_publication)).to be true end end + + describe "#status" do + it "should detect planned phase" do + process.update_attributes(start_date: Date.current + 2.days) + expect(process.status).to eq(:planned) + end + + it "should detect closed phase" do + process.update_attributes(end_date: Date.current - 2.days) + expect(process.status).to eq(:closed) + end + + it "should detect open phase" do + expect(process.status).to eq(:open) + end + end end From 48764d757c7a8c95e08333a388c33f76f3ae3b00 Mon Sep 17 00:00:00 2001 From: Fernando Blat Date: Thu, 5 Jan 2017 10:29:21 +0100 Subject: [PATCH 04/16] Fix label markup --- app/views/admin/legislation/draft_versions/_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/legislation/draft_versions/_form.html.erb b/app/views/admin/legislation/draft_versions/_form.html.erb index be3c5067f..8e79c0a56 100644 --- a/app/views/admin/legislation/draft_versions/_form.html.erb +++ b/app/views/admin/legislation/draft_versions/_form.html.erb @@ -41,7 +41,7 @@
<% ::Legislation::DraftVersion::VALID_STATUSES.each do |status| %> <%= f.radio_button :status, status, label: false %> - <%= f.label t("admin.legislation.draft_versions.statuses.#{status}") %> + <%= f.label "status_#{status}", t("admin.legislation.draft_versions.statuses.#{status}") %> <%= t("admin.legislation.draft_versions.form.hints.status.#{status}") %>
<% end %> From 7100156b2849fdab5c733e8b08f81a24922fe345 Mon Sep 17 00:00:00 2001 From: Fernando Blat Date: Thu, 5 Jan 2017 10:55:53 +0100 Subject: [PATCH 05/16] Show full header when click on expand button --- app/assets/javascripts/legislation.js.coffee | 7 ++++++ .../draft_versions/_process_header.html.erb | 19 -------------- .../draft_versions/changes.html.erb | 2 +- .../legislation/draft_versions/show.html.erb | 2 +- .../legislation/processes/_header.html.erb | 25 +++++++++++++++++++ .../processes/_header_full.html.erb | 2 +- .../processes/phase_empty.html.erb | 2 +- .../processes/phase_not_open.html.erb | 2 +- app/views/legislation/processes/show.html.erb | 2 +- 9 files changed, 38 insertions(+), 25 deletions(-) delete mode 100644 app/views/legislation/draft_versions/_process_header.html.erb create mode 100644 app/views/legislation/processes/_header.html.erb diff --git a/app/assets/javascripts/legislation.js.coffee b/app/assets/javascripts/legislation.js.coffee index 8ed109482..26c0185c1 100644 --- a/app/assets/javascripts/legislation.js.coffee +++ b/app/assets/javascripts/legislation.js.coffee @@ -14,3 +14,10 @@ App.Legislation = $('form#draft_version_go_to_version select').on change: -> $('form#draft_version_go_to_version').submit() + + $('#js-toggle-legislation-process-header').on + click: -> + $('[data-target="legislation-header-small"]').toggle() + $('[data-target="legislation-header-full"]').toggle() + + diff --git a/app/views/legislation/draft_versions/_process_header.html.erb b/app/views/legislation/draft_versions/_process_header.html.erb deleted file mode 100644 index 3c0c94d3f..000000000 --- a/app/views/legislation/draft_versions/_process_header.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -
-
-
-

<%= process.title %>

-
- -
- -
- - - -
-
diff --git a/app/views/legislation/draft_versions/changes.html.erb b/app/views/legislation/draft_versions/changes.html.erb index 0f2015cda..c158b9540 100644 --- a/app/views/legislation/draft_versions/changes.html.erb +++ b/app/views/legislation/draft_versions/changes.html.erb @@ -1,6 +1,6 @@ <% provide :title do %><%= "#{@draft_version.title} - #{t('.title')} - #{@process.title}" %><% end %> -<%= render 'process_header', process: @process %> +<%= render 'legislation/processes/header', process: @process, header: :small %>
<%= render 'legislation/processes/key_dates', process: @process, phase: :allegations %> diff --git a/app/views/legislation/draft_versions/show.html.erb b/app/views/legislation/draft_versions/show.html.erb index 8ab20eea9..a1a1c15a2 100644 --- a/app/views/legislation/draft_versions/show.html.erb +++ b/app/views/legislation/draft_versions/show.html.erb @@ -1,6 +1,6 @@ <% provide :title do %><%= "#{@draft_version.title} - #{@process.title}" %><% end %> -<%= render 'process_header', process: @process %> +<%= render 'legislation/processes/header', process: @process, header: :small %>
<%= render 'legislation/processes/key_dates', process: @process, phase: :allegations %> diff --git a/app/views/legislation/processes/_header.html.erb b/app/views/legislation/processes/_header.html.erb new file mode 100644 index 000000000..ecbd17dcd --- /dev/null +++ b/app/views/legislation/processes/_header.html.erb @@ -0,0 +1,25 @@ +<% if header == :small %> +
+
+
+

<%= process.title %>

+
+ +
+ +
+ + + +
+
+ + <%= render 'legislation/processes/header_full', process: @process, hidden: true %> +<% else %> + <%= render 'legislation/processes/header_full', process: @process, hidden: false %> +<% end %> diff --git a/app/views/legislation/processes/_header_full.html.erb b/app/views/legislation/processes/_header_full.html.erb index d631f8de5..e3f3420cf 100644 --- a/app/views/legislation/processes/_header_full.html.erb +++ b/app/views/legislation/processes/_header_full.html.erb @@ -1,4 +1,4 @@ -
+

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

diff --git a/app/views/legislation/processes/phase_empty.html.erb b/app/views/legislation/processes/phase_empty.html.erb index 427339b82..6fb588faf 100644 --- a/app/views/legislation/processes/phase_empty.html.erb +++ b/app/views/legislation/processes/phase_empty.html.erb @@ -1,6 +1,6 @@ <% provide :title do %><%= @process.title %><% end %> -<%= render 'legislation/processes/header_full', process: @process %> +<%= render 'legislation/processes/header', process: @process, header: :full %>
<%= render 'legislation/processes/key_dates', process: @process, phase: @phase %> diff --git a/app/views/legislation/processes/phase_not_open.html.erb b/app/views/legislation/processes/phase_not_open.html.erb index 6bd82c969..0b3b90f01 100644 --- a/app/views/legislation/processes/phase_not_open.html.erb +++ b/app/views/legislation/processes/phase_not_open.html.erb @@ -1,6 +1,6 @@ <% provide :title do %><%= @process.title %><% end %> -<%= render 'legislation/processes/header_full', process: @process %> +<%= render 'legislation/processes/header', process: @process, header: :full %>
<%= render 'legislation/processes/key_dates', process: @process, phase: @phase %> diff --git a/app/views/legislation/processes/show.html.erb b/app/views/legislation/processes/show.html.erb index b24f7668b..410068831 100644 --- a/app/views/legislation/processes/show.html.erb +++ b/app/views/legislation/processes/show.html.erb @@ -1,6 +1,6 @@ <% provide :title do %><%= @process.title %><% end %> -<%= render 'header_full', process: @process %> +<%= render 'legislation/processes/header', process: @process, header: :full %>
<%= render 'key_dates', process: @process, phase: :debate %> From ba0089ac44b6b1720d09c4f15212b8c6bcf1ce92 Mon Sep 17 00:00:00 2001 From: Fernando Blat Date: Thu, 5 Jan 2017 11:05:45 +0100 Subject: [PATCH 06/16] Truncate social networks text --- app/views/legislation/questions/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/legislation/questions/show.html.erb b/app/views/legislation/questions/show.html.erb index be8e90445..6401359c0 100644 --- a/app/views/legislation/questions/show.html.erb +++ b/app/views/legislation/questions/show.html.erb @@ -32,7 +32,7 @@

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

+<% elsif !@process.open_phase?(:debate) %> + <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 95cc42db4..a28c03910 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -295,6 +295,7 @@ en: unauthenticated: You must %{signin} or %{signup} to participate. verified_only: Only verified users can participate, %{verify_account}. verify_account: verify your account + debate_phase_not_open: Debate phase has finished and answers are not accepted anymore locale: English notifications: index: diff --git a/config/locales/es.yml b/config/locales/es.yml index 3a2cf0faa..9424c42f3 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -295,6 +295,7 @@ es: unauthenticated: Necesitas %{signin} o %{signup} para participar en el debate. verified_only: Solo los usuarios verificados pueden participar en el debate, %{verify_account}. verify_account: verifica tu cuenta + debate_phase_not_open: La fase de debate previo ya ha finalizado y en este momento no se aceptan respuestas locale: Español notifications: index: From dc3a917877fa3aeaa2cf5abd3ca51583911e66de Mon Sep 17 00:00:00 2001 From: Fernando Blat Date: Thu, 5 Jan 2017 16:46:53 +0100 Subject: [PATCH 13/16] Add missing translation --- app/views/legislation/processes/_header.html.erb | 3 +-- config/locales/en.yml | 2 ++ config/locales/es.yml | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/legislation/processes/_header.html.erb b/app/views/legislation/processes/_header.html.erb index ecbd17dcd..c73c732af 100644 --- a/app/views/legislation/processes/_header.html.erb +++ b/app/views/legislation/processes/_header.html.erb @@ -11,9 +11,8 @@
- diff --git a/config/locales/en.yml b/config/locales/en.yml index a28c03910..fdc7e4e0e 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -239,6 +239,8 @@ en: text_body: Text text_comments: Comments processes: + header: + view_process_information: View process information debate: empty_questions: There aren't any questions participate: Participate in the debate diff --git a/config/locales/es.yml b/config/locales/es.yml index 9424c42f3..f9ec8596b 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -239,6 +239,8 @@ es: text_body: Texto text_comments: Comentarios processes: + header: + view_process_information: Ver información del proceso debate: empty_questions: No hay preguntas participate: Realiza tus aportaciones al debate previo participando en los siguientes temas. From 13c49c1f75542098eacd5606a060e85bdbda116d Mon Sep 17 00:00:00 2001 From: Fernando Blat Date: Thu, 5 Jan 2017 16:49:18 +0100 Subject: [PATCH 14/16] Format text with markdown --- app/views/legislation/processes/_process.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/legislation/processes/_process.html.erb b/app/views/legislation/processes/_process.html.erb index a5780f792..87c10cc4c 100644 --- a/app/views/legislation/processes/_process.html.erb +++ b/app/views/legislation/processes/_process.html.erb @@ -3,7 +3,7 @@

<%= link_to process.title, process %>

- <%= simple_format(first_paragraph(process.description)) %> + <%= markdown(first_paragraph(process.description)) %>
From 1fbb10ff34974267da7c89792435a4f40bc9f946 Mon Sep 17 00:00:00 2001 From: Fernando Blat Date: Thu, 5 Jan 2017 17:03:08 +0100 Subject: [PATCH 15/16] Include link to resource in the flash message --- .../admin/legislation/draft_versions_controller.rb | 4 ++-- .../admin/legislation/processes_controller.rb | 4 ++-- .../admin/legislation/questions_controller.rb | 4 ++-- app/views/layouts/_flash.html.erb | 2 +- config/locales/admin.en.yml | 12 ++++++------ config/locales/admin.es.yml | 12 ++++++------ 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/controllers/admin/legislation/draft_versions_controller.rb b/app/controllers/admin/legislation/draft_versions_controller.rb index 6eabf7e79..0d84addbf 100644 --- a/app/controllers/admin/legislation/draft_versions_controller.rb +++ b/app/controllers/admin/legislation/draft_versions_controller.rb @@ -8,7 +8,7 @@ class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseCont def create if @draft_version.save - redirect_to admin_legislation_process_draft_versions_path, notice: t('admin.legislation.draft_versions.create.notice') + redirect_to admin_legislation_process_draft_versions_path, notice: t('admin.legislation.draft_versions.create.notice', link: legislation_process_draft_version_path(@process, @draft_version).html_safe) else flash.now[:error] = t('admin.legislation.draft_versions.create.error') render :new @@ -17,7 +17,7 @@ class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseCont def update if @draft_version.update(draft_version_params) - redirect_to edit_admin_legislation_process_draft_version_path(@process, @draft_version), notice: t('admin.legislation.draft_versions.update.notice') + redirect_to edit_admin_legislation_process_draft_version_path(@process, @draft_version), notice: t('admin.legislation.draft_versions.update.notice', link: legislation_process_draft_version_path(@process, @draft_version).html_safe) else flash.now[:error] = t('admin.legislation.draft_versions.update.error') render :edit diff --git a/app/controllers/admin/legislation/processes_controller.rb b/app/controllers/admin/legislation/processes_controller.rb index 46aa0944b..8cc678151 100644 --- a/app/controllers/admin/legislation/processes_controller.rb +++ b/app/controllers/admin/legislation/processes_controller.rb @@ -9,7 +9,7 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll def create if @process.save - redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.create.notice') + redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.create.notice', link: legislation_process_path(@process).html_safe) else flash.now[:error] = t('admin.legislation.processes.create.error') render :new @@ -18,7 +18,7 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll def update if @process.update(process_params) - redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.update.notice') + redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.update.notice', link: legislation_process_path(@process).html_safe) else flash.now[:error] = t('admin.legislation.processes.update.error') render :edit diff --git a/app/controllers/admin/legislation/questions_controller.rb b/app/controllers/admin/legislation/questions_controller.rb index 1c9c4e2ec..c8335e6df 100644 --- a/app/controllers/admin/legislation/questions_controller.rb +++ b/app/controllers/admin/legislation/questions_controller.rb @@ -13,7 +13,7 @@ class Admin::Legislation::QuestionsController < Admin::Legislation::BaseControll def create @question.author = current_user if @question.save - redirect_to admin_legislation_process_questions_path, notice: t('admin.legislation.questions.create.notice') + redirect_to admin_legislation_process_questions_path, notice: t('admin.legislation.questions.create.notice', link: legislation_process_question_path(@process, @question).html_safe) else flash.now[:error] = t('admin.legislation.questions.create.error') render :new @@ -22,7 +22,7 @@ class Admin::Legislation::QuestionsController < Admin::Legislation::BaseControll def update if @question.update(question_params) - redirect_to edit_admin_legislation_process_question_path(@process, @question), notice: t('admin.legislation.questions.update.notice') + redirect_to edit_admin_legislation_process_question_path(@process, @question), notice: t('admin.legislation.questions.update.notice', link: legislation_process_question_path(@process, @question).html_safe) else flash.now[:error] = t('admin.legislation.questions.update.error') render :edit diff --git a/app/views/layouts/_flash.html.erb b/app/views/layouts/_flash.html.erb index 9f55b449a..5be4a3186 100644 --- a/app/views/layouts/_flash.html.erb +++ b/app/views/layouts/_flash.html.erb @@ -5,7 +5,7 @@
- <%= flash_message %> + <%= flash_message.html_safe %>
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 30eba7c98..6362828bd 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -85,10 +85,10 @@ en: legislation: processes: create: - notice: Process created successfully + notice: 'Process created successfully. Click to visit' error: Process couldn't be created update: - notice: Process updated successfully + notice: 'Process updated successfully. Click to visit' error: Process couldn't be updated destroy: notice: Process deleted successfully @@ -132,10 +132,10 @@ en: questions: Debate draft_versions: create: - notice: Draft created successfully + notice: 'Draft created successfully. Click to visit' error: Draft couldn't be created update: - notice: Draft updated successfully + notice: 'Draft updated successfully. Click to visit' error: Draft couldn't be updated destroy: notice: Draft deleted successfully @@ -174,10 +174,10 @@ en: status: Status questions: create: - notice: Question created successfully + notice: 'Question created successfully. Click to visit' error: Question couldn't be created update: - notice: Question updated successfully + notice: 'Question updated successfully. Click to visit' error: Question couldn't be updated destroy: notice: Question deleted successfully diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 8e7b4dc8e..1b5bf4ffe 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -83,10 +83,10 @@ es: legislation: processes: create: - notice: Proceso creado correctamente + notice: 'Proceso creado correctamente. Haz click para verlo' error: No se ha podido crear el proceso update: - notice: Proceso actualizado correctamente + notice: 'Proceso actualizado correctamente. Haz click para verlo' error: No se ha podido actualizar el proceso destroy: notice: Proceso eliminado correctamente @@ -130,10 +130,10 @@ es: questions: Debate draft_versions: create: - notice: Borrador creado correctamente + notice: 'Borrador creado correctamente. Haz click para verlo' error: No se ha podido crear el borrador update: - notice: Borrador actualizado correctamente + notice: 'Borrador actualizado correctamente. Haz click para verlo' error: No se ha podido actualizar el borrador destroy: notice: Borrador eliminado correctamente @@ -172,10 +172,10 @@ es: status: Estado questions: create: - notice: Pregunta creada correctamente + notice: 'Pregunta creada correctamente. Haz click para verla' error: No se ha podido crear la pregunta update: - notice: Pregunta actualizada correctamente + notice: 'Pregunta actualizada correctamente. Haz click para verla' error: No se ha podido actualizar la pregunta destroy: notice: Pregunta eliminada correctamente From a5421597a4d62816207c08d9bf52524d5b695a15 Mon Sep 17 00:00:00 2001 From: Fernando Blat Date: Thu, 5 Jan 2017 17:12:42 +0100 Subject: [PATCH 16/16] Safe call to flash text --- app/views/layouts/_flash.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_flash.html.erb b/app/views/layouts/_flash.html.erb index 5be4a3186..a0f129224 100644 --- a/app/views/layouts/_flash.html.erb +++ b/app/views/layouts/_flash.html.erb @@ -5,7 +5,7 @@
- <%= flash_message.html_safe %> + <%= flash_message.try(:html_safe) %>