From 0995480b73fb26340129520a94dc3b1015e4ee37 Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 14 Mar 2019 14:06:02 +0100 Subject: [PATCH] Remove question and external_url fields from proposals --- app/controllers/management/proposals_controller.rb | 6 +++--- app/controllers/proposals_controller.rb | 4 ++-- app/models/proposal.rb | 1 - app/views/admin/hidden_proposals/index.html.erb | 4 ---- app/views/documents/_additional_documents.html.erb | 2 +- app/views/proposals/_form.html.erb | 5 ----- app/views/proposals/_info.html.erb | 14 -------------- config/api.yml | 1 - config/locales/en/documents.yml | 1 + config/locales/en/general.yml | 4 ---- config/locales/es/documents.yml | 1 + config/locales/es/general.yml | 4 ---- db/dev_seeds/proposals.rb | 8 -------- ...ove_question_and_external_url_from_proposals.rb | 6 ++++++ db/schema.rb | 4 ---- spec/factories/proposals.rb | 2 -- spec/features/admin/hidden_proposals_spec.rb | 2 -- spec/features/management/proposals_spec.rb | 2 -- spec/features/proposals_spec.rb | 13 ++----------- spec/features/tags/proposals_spec.rb | 2 -- spec/models/proposal_spec.rb | 12 ++---------- spec/support/common_actions/proposals.rb | 4 ++-- 22 files changed, 20 insertions(+), 82 deletions(-) create mode 100644 db/migrate/20190307165132_remove_question_and_external_url_from_proposals.rb diff --git a/app/controllers/management/proposals_controller.rb b/app/controllers/management/proposals_controller.rb index 2c497299a..f24e94303 100644 --- a/app/controllers/management/proposals_controller.rb +++ b/app/controllers/management/proposals_controller.rb @@ -52,9 +52,9 @@ class Management::ProposalsController < Management::BaseController end def proposal_params - params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, - :video_url, :responsible_name, :tag_list, :terms_of_service, - :geozone_id, :skip_map, + params.require(:proposal).permit(:title, :summary, :description, :video_url, + :responsible_name, :tag_list, :terms_of_service, :geozone_id, + :skip_map, map_location_attributes: [:latitude, :longitude, :zoom]) end diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 4372ecc63..5cc9b7e10 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -96,8 +96,8 @@ class ProposalsController < ApplicationController private def proposal_params - params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, - :video_url, :responsible_name, :tag_list, :terms_of_service, + params.require(:proposal).permit(:title, :summary, :description, :video_url, + :responsible_name, :tag_list, :terms_of_service, :geozone_id, :skip_map, image_attributes: image_attributes, documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy], diff --git a/app/models/proposal.rb b/app/models/proposal.rb index dd72d5173..ff5479ad8 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -117,7 +117,6 @@ class Proposal < ApplicationRecord def searchable_values { title => "A", - question => "B", author.username => "B", tag_list.join(" ") => "B", geozone.try(:name) => "B", diff --git a/app/views/admin/hidden_proposals/index.html.erb b/app/views/admin/hidden_proposals/index.html.erb index c0af9bc59..4e23b8c5b 100644 --- a/app/views/admin/hidden_proposals/index.html.erb +++ b/app/views/admin/hidden_proposals/index.html.erb @@ -22,13 +22,9 @@

<%= proposal.summary %>

<%= proposal.description %> - <% if proposal.external_url.present? %> -

<%= text_with_links proposal.external_url %>

- <% end %> <% if proposal.video_url.present? %>

<%= text_with_links proposal.video_url %>

<% end %> -

<%= proposal.question %>

diff --git a/app/views/documents/_additional_documents.html.erb b/app/views/documents/_additional_documents.html.erb index dc73f33f4..b4b23a1a0 100644 --- a/app/views/documents/_additional_documents.html.erb +++ b/app/views/documents/_additional_documents.html.erb @@ -4,7 +4,7 @@
diff --git a/app/views/proposals/_form.html.erb b/app/views/proposals/_form.html.erb index 9cf4044a7..102c785e1 100644 --- a/app/views/proposals/_form.html.erb +++ b/app/views/proposals/_form.html.erb @@ -41,11 +41,6 @@ aria: {describedby: "video-url-help-text"} %>
-
- <%= f.label :external_url, t("proposals.form.proposal_external_url") %> - <%= f.text_field :external_url, placeholder: t("proposals.form.proposal_external_url"), label: false %> -
- <% if feature?(:allow_images) %>
<%= render "images/nested_image", imageable: @proposal, f: f %> diff --git a/app/views/proposals/_info.html.erb b/app/views/proposals/_info.html.erb index 79e1316e6..da1eb3435 100644 --- a/app/views/proposals/_info.html.erb +++ b/app/views/proposals/_info.html.erb @@ -42,16 +42,6 @@
<% end %> -<% if @proposal.external_url.present? %> - -<% end %> - <% if @proposal.video_url.present? %> <% end %> -<% if @proposal.question.present? %> -

<%= @proposal.question %>

-<% end %> - <% if @proposal.retired? %>

diff --git a/config/api.yml b/config/api.yml index 0c668eac2..20dd8c7a7 100644 --- a/config/api.yml +++ b/config/api.yml @@ -27,7 +27,6 @@ Proposal: id: integer title: string description: string - external_url: string cached_votes_up: integer comments_count: integer hot_score: integer diff --git a/config/locales/en/documents.yml b/config/locales/en/documents.yml index 7471deb84..8aa127a9f 100644 --- a/config/locales/en/documents.yml +++ b/config/locales/en/documents.yml @@ -2,6 +2,7 @@ en: documents: title: Documents max_documents_allowed_reached_html: You have reached the maximum number of documents allowed! You have to delete one before you can upload another. + additional: Additional documentation form: title: Documents title_placeholder: Add a descriptive title for the document diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 5773c1c95..8eedc17e9 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -338,9 +338,6 @@ en: other: Other form: geozone: Scope of operation - proposal_external_url: Link to additional documentation - proposal_question: Proposal question - proposal_question_example_html: "Must be summarised in one question with a Yes or No answer" proposal_responsible_name: Full name of the person submitting the proposal proposal_responsible_name_note: "(individually or as representative of a collective; will not be displayed publically)" proposal_summary: Proposal summary @@ -462,7 +459,6 @@ en: share: Share no_notifications: "This proposal has no notifications." embed_video_title: "Video on %{proposal}" - title_external_url: "Additional documentation" title_video_url: "External video" author: Author draft: Proposal in draft. Cannot yet get supports, nor does it appear in the list of proposals. diff --git a/config/locales/es/documents.yml b/config/locales/es/documents.yml index 4e9f9f1f5..777b36576 100644 --- a/config/locales/es/documents.yml +++ b/config/locales/es/documents.yml @@ -2,6 +2,7 @@ es: documents: title: Documentos max_documents_allowed_reached_html: "¡Has alcanzado el número máximo de documentos permitidos! Tienes que eliminar uno antes de poder subir otro." + additional: Documentación adicional form: title: Documentos title_placeholder: Añade un título descriptivo para el documento diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 76125ee5a..6bf6057d1 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -338,9 +338,6 @@ es: other: Otra form: geozone: Ámbito de actuación - proposal_external_url: Enlace a documentación adicional - proposal_question: Pregunta de la propuesta - proposal_question_example_html: "Debe ser resumida en una pregunta cuya respuesta sea Sí o No" 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)" proposal_summary: Resumen de la propuesta @@ -462,7 +459,6 @@ es: share: Compartir no_notifications: "Esta propuesta no tiene notificaciones." embed_video_title: "Vídeo en %{proposal}" - title_external_url: "Documentación adicional" title_video_url: "Vídeo externo" author: Autor draft: Propuesta en borrador. Todavía no puede recoger apoyos, ni aparece en la lista de propuestas. diff --git a/db/dev_seeds/proposals.rb b/db/dev_seeds/proposals.rb index 53d5bacc3..d961bd7df 100644 --- a/db/dev_seeds/proposals.rb +++ b/db/dev_seeds/proposals.rb @@ -28,10 +28,8 @@ section "Creating Proposals" do description = "

#{Faker::Lorem.paragraphs.join("

")}

" proposal = Proposal.create!(author: author, title: Faker::Lorem.sentence(3).truncate(60), - question: Faker::Lorem.sentence(3) + "?", summary: Faker::Lorem.sentence(3), responsible_name: Faker::Name.name, - external_url: Faker::Internet.url, description: description, created_at: rand((Time.current - 1.week)..Time.current), tag_list: tags.sample(3).join(","), @@ -51,10 +49,8 @@ section "Creating Archived Proposals" do months_to_archive_proposals = Setting["months_to_archive_proposals"] proposal = Proposal.create!(author: author, title: Faker::Lorem.sentence(3).truncate(60), - question: Faker::Lorem.sentence(3) + "?", summary: Faker::Lorem.sentence(3), responsible_name: Faker::Name.name, - external_url: Faker::Internet.url, description: description, tag_list: tags.sample(3).join(","), geozone: Geozone.all.sample, @@ -73,10 +69,8 @@ section "Creating Successful Proposals" do description = "

#{Faker::Lorem.paragraphs.join("

")}

" proposal = Proposal.create!(author: author, title: Faker::Lorem.sentence(3).truncate(60), - question: Faker::Lorem.sentence(3) + "?", summary: Faker::Lorem.sentence(3), responsible_name: Faker::Name.name, - external_url: Faker::Internet.url, description: description, created_at: rand((Time.current - 1.week)..Time.current), tag_list: tags.sample(3).join(","), @@ -94,10 +88,8 @@ section "Creating Successful Proposals" do description = "

#{Faker::Lorem.paragraphs.join("

")}

" proposal = Proposal.create!(author: author, title: Faker::Lorem.sentence(4).truncate(60), - question: Faker::Lorem.sentence(6) + "?", summary: Faker::Lorem.sentence(3), responsible_name: Faker::Name.name, - external_url: Faker::Internet.url, description: description, created_at: rand((Time.current - 1.week)..Time.current), tag_list: tags.sample(3).join(","), diff --git a/db/migrate/20190307165132_remove_question_and_external_url_from_proposals.rb b/db/migrate/20190307165132_remove_question_and_external_url_from_proposals.rb new file mode 100644 index 000000000..42c6dbbbd --- /dev/null +++ b/db/migrate/20190307165132_remove_question_and_external_url_from_proposals.rb @@ -0,0 +1,6 @@ +class RemoveQuestionAndExternalUrlFromProposals < ActiveRecord::Migration + def change + remove_column :proposals, :question, :string + remove_column :proposals, :external_url, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 780a0cea6..a49ab75a7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -728,7 +728,6 @@ ActiveRecord::Schema.define(version: 20190411090023) do t.string "title", limit: 80 t.text "description" t.string "question" - t.string "external_url" t.integer "author_id" t.datetime "hidden_at" t.integer "flags_count", default: 0 @@ -1172,8 +1171,6 @@ ActiveRecord::Schema.define(version: 20190411090023) do create_table "proposals", force: :cascade do |t| t.string "title", limit: 80 t.text "description" - t.string "question" - t.string "external_url" t.integer "author_id" t.datetime "hidden_at" t.integer "flags_count", default: 0 @@ -1203,7 +1200,6 @@ ActiveRecord::Schema.define(version: 20190411090023) do t.index ["geozone_id"], name: "index_proposals_on_geozone_id", using: :btree t.index ["hidden_at"], name: "index_proposals_on_hidden_at", using: :btree t.index ["hot_score"], name: "index_proposals_on_hot_score", using: :btree - t.index ["question"], name: "index_proposals_on_question", using: :btree t.index ["summary"], name: "index_proposals_on_summary", using: :btree t.index ["title"], name: "index_proposals_on_title", using: :btree t.index ["tsv"], name: "index_proposals_on_tsv", using: :gin diff --git a/spec/factories/proposals.rb b/spec/factories/proposals.rb index 1b0327559..0821eb168 100644 --- a/spec/factories/proposals.rb +++ b/spec/factories/proposals.rb @@ -3,8 +3,6 @@ FactoryBot.define do sequence(:title) { |n| "Proposal #{n} title" } sequence(:summary) { |n| "In summary, what we want is... #{n}" } description "Proposal description" - question "Proposal question" - external_url "http://external_documention.es" video_url "https://youtu.be/nhuNb0XtRhQ" responsible_name "John Snow" terms_of_service "1" diff --git a/spec/features/admin/hidden_proposals_spec.rb b/spec/features/admin/hidden_proposals_spec.rb index eb8c69b59..724b8ffea 100644 --- a/spec/features/admin/hidden_proposals_spec.rb +++ b/spec/features/admin/hidden_proposals_spec.rb @@ -22,8 +22,6 @@ feature "Admin hidden proposals" do expect(page).to have_content(proposal.title) expect(page).to have_content(proposal.summary) expect(page).to have_content(proposal.description) - expect(page).to have_content(proposal.question) - expect(page).to have_content(proposal.external_url) expect(page).to have_content(proposal.video_url) end diff --git a/spec/features/management/proposals_spec.rb b/spec/features/management/proposals_spec.rb index 03519d02d..4475fbdd6 100644 --- a/spec/features/management/proposals_spec.rb +++ b/spec/features/management/proposals_spec.rb @@ -25,7 +25,6 @@ feature "Proposals" do fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" 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: "https://www.youtube.com/watch?v=yRYFKcMa_Ek" check "proposal_terms_of_service" @@ -37,7 +36,6 @@ feature "Proposals" do expect(page).to have_content "¿Would you like to give assistance to war refugees?" 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 "https://www.youtube.com/watch?v=yRYFKcMa_Ek" expect(page).to have_content user.name expect(page).to have_content I18n.l(Proposal.last.created_at.to_date) diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index a54884e4d..8203c9421 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -127,7 +127,6 @@ feature "Proposals" do expect(page).to have_content proposal.code expect(page).to have_content "Proposal question" expect(page).to have_content "Proposal description" - expect(page).to have_content "http://external_documention.es" expect(page).to have_content proposal.author.name expect(page).to have_content I18n.l(proposal.created_at.to_date) expect(page).to have_selector(avatar(proposal.author.name)) @@ -222,7 +221,6 @@ feature "Proposals" do fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" 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: "https://www.youtube.com/watch?v=yPQfcG-eimk" fill_in "proposal_responsible_name", with: "Isabel Garcia" fill_in "proposal_tag_list", with: "Refugees, Solidarity" @@ -243,7 +241,6 @@ feature "Proposals" do expect(page).to have_content "¿Would you like to give assistance to war refugees?" 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 "https://www.youtube.com/watch?v=yPQfcG-eimk" expect(page).to have_content author.name expect(page).to have_content "Refugees" @@ -261,7 +258,6 @@ feature "Proposals" do fill_in "proposal_question", with: "This is a question" fill_in "proposal_summary", with: "This is the summary" fill_in "proposal_description", with: "This is the description" - fill_in "proposal_external_url", with: "http://google.com/robots.txt" fill_in "proposal_responsible_name", with: "Some other robot" check "proposal_terms_of_service" @@ -328,7 +324,6 @@ feature "Proposals" do fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" 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" check "proposal_terms_of_service" click_button "Create proposal" @@ -442,10 +437,8 @@ feature "Proposals" do visit new_proposal_path fill_in "proposal_title", with: "Help refugees" - fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" - 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_summary", with: "In summary what we want is..." + fill_in_ckeditor "proposal_description", with: "A description with enough characters" fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yPQfcG-eimk" fill_in "proposal_responsible_name", with: "Isabel Garcia" check "proposal_terms_of_service" @@ -632,7 +625,6 @@ feature "Proposals" do fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" fill_in "proposal_summary", with: "Basically..." fill_in "proposal_description", with: "Let's do something to end child poverty" - fill_in "proposal_external_url", with: "http://rescue.org/refugees" fill_in "proposal_responsible_name", with: "Isabel Garcia" click_button "Save changes" @@ -1835,7 +1827,6 @@ feature "Successful proposals" do fill_in "proposal_summary", with: "In summary what we want is..." fill_in "proposal_question", with: "Would you like to?" 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: "https://www.youtube.com/watch?v=yPQfcG-eimk" fill_in "proposal_tag_list", with: "Refugees, Solidarity" check "proposal_terms_of_service" diff --git a/spec/features/tags/proposals_spec.rb b/spec/features/tags/proposals_spec.rb index eb330b79d..6aec4910c 100644 --- a/spec/features/tags/proposals_spec.rb +++ b/spec/features/tags/proposals_spec.rb @@ -100,7 +100,6 @@ feature "Tags" do fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" fill_in "proposal_summary", with: "In summary, what we want is..." fill_in_ckeditor "proposal_description", with: "A description with enough characters" - fill_in "proposal_external_url", with: "http://rescue.org/refugees" fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=Ae6gQmhaMn4" fill_in "proposal_responsible_name", with: "Isabel Garcia" check "proposal_terms_of_service" @@ -145,7 +144,6 @@ feature "Tags" do fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" fill_in "proposal_summary", with: "In summary, what we want is..." fill_in "proposal_description", with: "A description suitable for this test" - fill_in "proposal_external_url", with: "http://rescue.org/refugees" fill_in "proposal_responsible_name", with: "Isabel Garcia" check "proposal_terms_of_service" diff --git a/spec/models/proposal_spec.rb b/spec/models/proposal_spec.rb index 426e59e70..2eb777d5d 100644 --- a/spec/models/proposal_spec.rb +++ b/spec/models/proposal_spec.rb @@ -491,12 +491,6 @@ describe Proposal do expect(results).to eq([proposal]) end - it "searches by question" do - proposal = create(:proposal, question: "to be or not to be") - results = described_class.search("to be or not to be") - expect(results).to eq([proposal]) - end - it "searches by author name" do author = create(:user, username: "Danny Trejo") proposal = create(:proposal, author: author) @@ -575,7 +569,6 @@ describe Proposal do context "order" do it "orders by weight" do - proposal_question = create(:proposal, question: "stop corruption") proposal_title = create(:proposal, title: "stop corruption") proposal_description = create(:proposal, description: "stop corruption") proposal_summary = create(:proposal, summary: "stop corruption") @@ -583,9 +576,8 @@ describe Proposal do results = described_class.search("stop corruption") expect(results.first).to eq(proposal_title) - expect(results.second).to eq(proposal_question) - expect(results.third).to eq(proposal_summary) - expect(results.fourth).to eq(proposal_description) + expect(results.second).to eq(proposal_summary) + expect(results.third).to eq(proposal_description) end it "orders by weight and then by votes" do diff --git a/spec/support/common_actions/proposals.rb b/spec/support/common_actions/proposals.rb index 93797935b..2ee198d14 100644 --- a/spec/support/common_actions/proposals.rb +++ b/spec/support/common_actions/proposals.rb @@ -1,8 +1,8 @@ module Proposals def create_successful_proposals - [create(:proposal, title: "Winter is coming", question: "Do you speak it?", + [create(:proposal, title: "Winter is coming", cached_votes_up: Proposal.votes_needed_for_success + 100), - create(:proposal, title: "Fire and blood", question: "You talking to me?", + create(:proposal, title: "Fire and blood", cached_votes_up: Proposal.votes_needed_for_success + 1)] end