Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove question and external_url fields from proposals and legislation proposals #3397

Merged
merged 5 commits into from
May 17, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Next Next commit
Remove question and external_url fields from proposals
  • Loading branch information
decabeza committed Apr 30, 2019
commit 0995480b73fb26340129520a94dc3b1015e4ee37
6 changes: 3 additions & 3 deletions app/controllers/management/proposals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def set_proposal
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

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/proposals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def publish
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],
Expand Down
1 change: 0 additions & 1 deletion app/models/proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def to_param

def searchable_values
{ title => "A",
question => "B",
author.username => "B",
tag_list.join(" ") => "B",
geozone.try(:name) => "B",
Expand Down
4 changes: 0 additions & 4 deletions app/views/admin/hidden_proposals/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@
<div class="moderation-description">
<p><small><%= proposal.summary %></small></p>
<%= proposal.description %>
<% if proposal.external_url.present? %>
<p><%= text_with_links proposal.external_url %></p>
<% end %>
<% if proposal.video_url.present? %>
<p><%= text_with_links proposal.video_url %></p>
<% end %>
<p><%= proposal.question %></p>
</div>
</td>
<td class="align-top">
Expand Down
2 changes: 1 addition & 1 deletion app/views/documents/_additional_documents.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="small-12 column">
<div class="additional-document-link">
<p>
<strong><%= t("proposals.show.title_external_url") %></strong>
<strong><%= t("documents.additional") %></strong>
</p>
<%= render partial: "documents/additional_document", collection: documents, as: :document %>
</div>
Expand Down
5 changes: 0 additions & 5 deletions app/views/proposals/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@
aria: {describedby: "video-url-help-text"} %>
</div>

<div class="small-12 column">
<%= f.label :external_url, t("proposals.form.proposal_external_url") %>
<%= f.text_field :external_url, placeholder: t("proposals.form.proposal_external_url"), label: false %>
</div>

<% if feature?(:allow_images) %>
<div class="images small-12 column">
<%= render "images/nested_image", imageable: @proposal, f: f %>
Expand Down
14 changes: 0 additions & 14 deletions app/views/proposals/_info.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@
</div>
<% end %>

<% if @proposal.external_url.present? %>
<div class="document-link">
<p>
<span class="icon-document"></span>&nbsp;
<strong><%= t("proposals.show.title_external_url") %></strong>
</p>
<%= text_with_links @proposal.external_url %>
</div>
<% end %>

<% if @proposal.video_url.present? %>
<div class="video-link">
<p>
Expand All @@ -62,10 +52,6 @@
</div>
<% end %>

<% if @proposal.question.present? %>
<h4><%= @proposal.question %></h4>
<% end %>

<% if @proposal.retired? %>
<div id="retired_explanation" class="callout">
<h2>
Expand Down
1 change: 0 additions & 1 deletion config/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Proposal:
id: integer
title: string
description: string
external_url: string
cached_votes_up: integer
comments_count: integer
hot_score: integer
Expand Down
1 change: 1 addition & 0 deletions config/locales/en/documents.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ en:
documents:
title: Documents
max_documents_allowed_reached_html: You have reached the maximum number of documents allowed! <strong>You have to delete one before you can upload another.</strong>
additional: Additional documentation
form:
title: Documents
title_placeholder: Add a descriptive title for the document
Expand Down
4 changes: 0 additions & 4 deletions config/locales/en/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions config/locales/es/documents.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ es:
documents:
title: Documentos
max_documents_allowed_reached_html: "¡Has alcanzado el número máximo de documentos permitidos! <strong>Tienes que eliminar uno antes de poder subir otro.</strong>"
additional: Documentación adicional
form:
title: Documentos
title_placeholder: Añade un título descriptivo para el documento
Expand Down
4 changes: 0 additions & 4 deletions config/locales/es/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 0 additions & 8 deletions db/dev_seeds/proposals.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ def add_image_to(imageable)
description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>"
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(","),
Expand All @@ -51,10 +49,8 @@ def add_image_to(imageable)
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,
Expand All @@ -73,10 +69,8 @@ def add_image_to(imageable)
description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>"
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(","),
Expand All @@ -94,10 +88,8 @@ def add_image_to(imageable)
description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>"
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(","),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class RemoveQuestionAndExternalUrlFromProposals < ActiveRecord::Migration
def change
remove_column :proposals, :question, :string
remove_column :proposals, :external_url, :string
end
end
4 changes: 0 additions & 4 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,6 @@
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
Expand Down Expand Up @@ -1172,8 +1171,6 @@
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
Expand Down Expand Up @@ -1203,7 +1200,6 @@
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
Expand Down
2 changes: 0 additions & 2 deletions spec/factories/proposals.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
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:https://external_documention.es"
video_url "https://youtu.be/nhuNb0XtRhQ"
responsible_name "John Snow"
terms_of_service "1"
Expand Down
2 changes: 0 additions & 2 deletions spec/features/admin/hidden_proposals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
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

Expand Down
2 changes: 0 additions & 2 deletions spec/features/management/proposals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
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:https://rescue.org/refugees"
fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yRYFKcMa_Ek"
check "proposal_terms_of_service"

Expand All @@ -37,7 +36,6 @@
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:https://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)
Expand Down
13 changes: 2 additions & 11 deletions spec/features/proposals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@
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:https://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))
Expand Down Expand Up @@ -222,7 +221,6 @@
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:https://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"
Expand All @@ -243,7 +241,6 @@
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:https://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"
Expand All @@ -261,7 +258,6 @@
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:https://google.com/robots.txt"
fill_in "proposal_responsible_name", with: "Some other robot"
check "proposal_terms_of_service"

Expand Down Expand Up @@ -328,7 +324,6 @@
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:https://rescue.org/refugees"
check "proposal_terms_of_service"

click_button "Create proposal"
Expand Down Expand Up @@ -442,10 +437,8 @@
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:https://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"
Expand Down Expand Up @@ -632,7 +625,6 @@
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:https://rescue.org/refugees"
fill_in "proposal_responsible_name", with: "Isabel Garcia"

click_button "Save changes"
Expand Down Expand Up @@ -1835,7 +1827,6 @@
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:https://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"
Expand Down
2 changes: 0 additions & 2 deletions spec/features/tags/proposals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
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:https://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"
Expand Down Expand Up @@ -145,7 +144,6 @@
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:https://rescue.org/refugees"
fill_in "proposal_responsible_name", with: "Isabel Garcia"
check "proposal_terms_of_service"

Expand Down
12 changes: 2 additions & 10 deletions spec/models/proposal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -491,12 +491,6 @@
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)
Expand Down Expand Up @@ -575,17 +569,15 @@
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")

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
Expand Down
4 changes: 2 additions & 2 deletions spec/support/common_actions/proposals.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down