From 817b5806badab3adbc14836fa4ececfdeb87b8dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baz=C3=A1n?= Date: Mon, 14 Sep 2015 21:40:03 +0200 Subject: [PATCH] adds video_url to proposals --- app/controllers/proposals_controller.rb | 2 +- app/views/proposals/_form.html.erb | 14 +++++++------- app/views/proposals/show.html.erb | 6 +++++- config/locales/en.yml | 4 ++-- config/locales/es.yml | 4 ++-- .../20150914191003_add_video_url_to_proposal.rb | 5 +++++ db/schema.rb | 3 ++- spec/features/proposals_spec.rb | 2 ++ 8 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 db/migrate/20150914191003_add_video_url_to_proposal.rb diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index ab20e76e3..f55604c1f 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -75,7 +75,7 @@ class ProposalsController < ApplicationController private def proposal_params - params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :responsible_name, :tag_list, :terms_of_service, :captcha, :captcha_key) + params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service, :captcha, :captcha_key) end def load_featured_tags diff --git a/app/views/proposals/_form.html.erb b/app/views/proposals/_form.html.erb index 1b2dcf77a..1d98a05d6 100644 --- a/app/views/proposals/_form.html.erb +++ b/app/views/proposals/_form.html.erb @@ -27,13 +27,13 @@ <%= f.cktext_area :description, maxlength: Proposal.description_max_length, ckeditor: { language: I18n.locale }, label: false %> - - - + +
+ <%= f.label :video_url, t("proposals.form.proposal_video_url") %> + <%= t("proposals.form.proposal_video_url_note") %> + <%= f.text_field :video_url, placeholder: t("proposals.form.proposal_video_url"), label: false %> +
+
<%= f.label :external_url, t("proposals.form.proposal_external_url") %> <%= f.text_field :external_url, placeholder: t("proposals.form.proposal_external_url"), label: false %> diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb index b2fc4cee2..c85f3d2d9 100644 --- a/app/views/proposals/show.html.erb +++ b/app/views/proposals/show.html.erb @@ -65,7 +65,11 @@ <%= safe_html_with_links @proposal.description %> <% if @proposal.external_url.present? %> -
<%= link_to(@proposal.external_url) %>
+
<%= text_with_links @proposal.external_url %>
+ <% end %> + + <% if @proposal.video_url.present? %> +
<%= text_with_links @proposal.video_url %>
<% end %>

<%= @proposal.question %>

diff --git a/config/locales/en.yml b/config/locales/en.yml index fee411166..dd0a9c4da 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -178,8 +178,8 @@ en: proposal_question_example_html: "Debe ser resumida en una pregunta cuya respuesta sea Sí o No. Ej. '¿Está usted de acuerdo en peatonalizar la calle Mayor?'" proposal_text: Initial text for proposal proposal_external_url: Link to additional documentation - proposal_external_video_url: "Enlace a vídeo externo" - proposal_external_video_url_note: "Puedes añadir un enlace a YouTube o Vimeo" + proposal_video_url: "Enlace a vídeo externo" + proposal_video_url_note: "Puedes añadir un enlace a YouTube o Vimeo" proposal_summary: "Proposal summary" proposal_summary_note: "200 chars. maximum" proposal_responsible_name: "First and last name of the person making this proposal" diff --git a/config/locales/es.yml b/config/locales/es.yml index bcffa07c7..f3c2a2f5e 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -180,8 +180,8 @@ es: proposal_summary_note: "(máximo 200 caracteres)" proposal_text: Texto desarrollado de la propuesta proposal_external_url: Enlace a documentación adicional - proposal_external_video_url: "Enlace a vídeo externo" - proposal_external_video_url_note: "Puedes añadir un enlace a YouTube o Vimeo" + proposal_video_url: "Enlace a vídeo externo" + proposal_video_url_note: "Puedes añadir un enlace a YouTube o Vimeo" proposal_responsible_name: "Nombre y apellidos de la persona que hace esta propuesta" proposal_responsible_name_note: "(individualmente o como representante de un colectivo; no se mostrará públicamente)" tags_label: Temas diff --git a/db/migrate/20150914191003_add_video_url_to_proposal.rb b/db/migrate/20150914191003_add_video_url_to_proposal.rb new file mode 100644 index 000000000..298038e97 --- /dev/null +++ b/db/migrate/20150914191003_add_video_url_to_proposal.rb @@ -0,0 +1,5 @@ +class AddVideoUrlToProposal < ActiveRecord::Migration + def change + add_column :proposals, :video_url, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 597933285..0bfa35d54 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: 20150914184018) do +ActiveRecord::Schema.define(version: 20150914191003) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -211,6 +211,7 @@ ActiveRecord::Schema.define(version: 20150914184018) do t.datetime "updated_at", null: false t.string "responsible_name", limit: 60 t.text "summary" + t.string "video_url" end add_index "proposals", ["author_id", "hidden_at"], name: "index_proposals_on_author_id_and_hidden_at", using: :btree diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 0ba626547..a968cc9ea 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -63,6 +63,7 @@ feature 'Proposals' do fill_in 'proposal_summary', with: 'In summary, what we want is...' fill_in 'proposal_description', with: 'This is very important because...' fill_in 'proposal_external_url', with: 'http://rescue.org/refugees' + fill_in 'proposal_video_url', with: 'http://youtube.com' fill_in 'proposal_responsible_name', with: 'Isabel Garcia' fill_in 'proposal_captcha', with: correct_captcha_text check 'proposal_terms_of_service' @@ -75,6 +76,7 @@ feature 'Proposals' do expect(page).to have_content 'In summary, what we want is...' expect(page).to have_content 'This is very important because...' expect(page).to have_content 'http://rescue.org/refugees' + expect(page).to have_content 'http://youtube.com' expect(page).to have_content author.name expect(page).to have_content I18n.l(Proposal.last.created_at.to_date) end