<% end %>
diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml
index 6a6e2ad85..f6b6be383 100644
--- a/config/locales/en/activerecord.yml
+++ b/config/locales/en/activerecord.yml
@@ -216,6 +216,9 @@ en:
poll/question/answer:
title: "Answer"
description: "Description"
+ poll/question/answer/video:
+ title: Title
+ url: External video
errors:
models:
user:
diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml
index e28c7f40b..981eca84e 100644
--- a/config/locales/en/admin.yml
+++ b/config/locales/en/admin.yml
@@ -602,7 +602,17 @@ en:
video_list: Video list (%{count})
answers:
new:
- title: "New answer"
+ title: New answer
+ videos:
+ index:
+ title: Videos
+ add_video: Add video
+ video_title: Title
+ video_url: External video
+ new:
+ title: New video
+ edit:
+ title: Edit video
recounts:
index:
title: "Recounts"
diff --git a/config/locales/en/responders.yml b/config/locales/en/responders.yml
index fd187c495..88f68a955 100644
--- a/config/locales/en/responders.yml
+++ b/config/locales/en/responders.yml
@@ -9,6 +9,7 @@ en:
poll: "Poll created successfully."
poll_booth: "Booth created successfully."
poll_question_answer: "Answer created successfully"
+ poll_question_answer_video: "Video created successfully"
proposal: "Proposal created successfully."
proposal_notification: "Your message has been sent correctly."
spending_proposal: "Spending proposal created successfully. You can access it from %{activity}"
@@ -31,3 +32,4 @@ en:
budget_investment: "Investment project deleted succesfully."
error: "Could not delete"
topic: "Topic deleted successfully."
+ poll_question_answer_video: "Answer video deleted successfully."
diff --git a/config/locales/es/activerecord.yml b/config/locales/es/activerecord.yml
index 9b83d9516..d04eb72da 100644
--- a/config/locales/es/activerecord.yml
+++ b/config/locales/es/activerecord.yml
@@ -210,6 +210,9 @@ es:
poll/question/answer:
title: "Respuesta"
description: "Descripción"
+ poll/question/answer/video:
+ title: Título
+ url: Vídeo externo
errors:
models:
user:
diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml
index f025437cf..f57c4fbea 100644
--- a/config/locales/es/admin.yml
+++ b/config/locales/es/admin.yml
@@ -606,6 +606,16 @@ es:
title: "Nueva respuesta"
video_url: Video externo
documents: Documentos (1)
+ videos:
+ index:
+ title: Vídeos
+ add_video: Añadir vídeo
+ video_title: Título
+ video_url: External video
+ new:
+ title: Nuevo video
+ edit:
+ title: Editar vídeo
recounts:
index:
title: "Recuentos"
diff --git a/config/locales/es/responders.yml b/config/locales/es/responders.yml
index a35387ff3..01f19d96e 100644
--- a/config/locales/es/responders.yml
+++ b/config/locales/es/responders.yml
@@ -9,6 +9,7 @@ es:
poll: "Votación creada correctamente."
poll_booth: "Urna creada correctamente."
poll_question_answer: "Respuesta creada correctamente"
+ poll_question_answer_video: "Vídeo creado correctamente"
proposal: "Propuesta creada correctamente."
proposal_notification: "Tu message ha sido enviado correctamente."
spending_proposal: "Propuesta de inversión creada correctamente. Puedes acceder a ella desde %{activity}"
@@ -31,3 +32,4 @@ es:
budget_investment: "Propuesta de inversión eliminada."
error: "No se pudo borrar"
topic: "Tema eliminado."
+ poll_question_answer_video: "Vídeo de respuesta eliminado."
diff --git a/config/locales/fr/activerecord.yml b/config/locales/fr/activerecord.yml
index 5c6117d31..bd8acfd50 100644
--- a/config/locales/fr/activerecord.yml
+++ b/config/locales/fr/activerecord.yml
@@ -150,6 +150,9 @@ fr:
poll/question/answer:
title: "Réponse"
description: "Description"
+ poll/question/answer/video:
+ title: Titre
+ url: Vidéo externe
errors:
models:
user:
diff --git a/config/locales/fr/admin.yml b/config/locales/fr/admin.yml
index 0217c9217..ba29e068b 100644
--- a/config/locales/fr/admin.yml
+++ b/config/locales/fr/admin.yml
@@ -393,6 +393,16 @@ fr:
answers:
new:
title: "Nouvelle réponse"
+ videos:
+ index:
+ title: Vidéos
+ add_video: Ajouter une vidéo
+ video_title: Titre
+ video_url: Vidéo externe
+ new:
+ title: Nouveau vidéo
+ edit:
+ title: Modifier la vidéo
recounts:
index:
title: "Dépouillements"
diff --git a/config/locales/fr/responders.yml b/config/locales/fr/responders.yml
index 9897e3455..1d1cfae0c 100644
--- a/config/locales/fr/responders.yml
+++ b/config/locales/fr/responders.yml
@@ -8,6 +8,8 @@ fr:
direct_message: "Votre message a été envoyé avec succès."
poll: "Vote créé avec succès."
poll_booth: "Urne créée avec succès."
+ poll_question_answer: "Réponse créée avec succès"
+ poll_question_answer_video: "Vidéo créée avec succès"
proposal: "Proposition créée avec succès."
proposal_notification: "Votre message a correctement été envoyé."
spending_proposal: "Proposition de dépense créée avec succès. Vous pouvez y accéder depuis %{activity}"
@@ -27,3 +29,4 @@ fr:
spending_proposal: "Proposition de dépense supprimée avec succès."
budget_investment: "Budget d'investissement supprimé avec succès."
error: "Suppression impossible"
+ poll_question_answer_video: "Réponse vidéo supprimée avec succès."
diff --git a/config/routes.rb b/config/routes.rb
index 89691feac..1428dc4fa 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -300,8 +300,10 @@ Rails.application.routes.draw do
end
end
- resources :questions do
- resources :answers, only: [:new, :create], controller: 'questions/answers'
+ resources :questions, shallow: true do
+ resources :answers, only: [:new, :create], controller: 'questions/answers' do
+ resources :videos, controller: 'questions/answers/videos'
+ end
end
end
diff --git a/spec/features/admin/poll/questions/answers/videos/videos_spec.rb b/spec/features/admin/poll/questions/answers/videos/videos_spec.rb
new file mode 100644
index 000000000..ee04ce128
--- /dev/null
+++ b/spec/features/admin/poll/questions/answers/videos/videos_spec.rb
@@ -0,0 +1,33 @@
+require 'rails_helper'
+
+feature 'Videos' do
+
+ background do
+ admin = create(:administrator)
+ login_as(admin.user)
+ end
+
+ scenario "Create" do
+ question = create(:poll_question)
+ answer = create(:poll_question_answer, question: question)
+ video_title = "'Magical' by Junko Ohashi"
+ video_url = "https://www.youtube.com/watch?v=-JMf43st-1A"
+
+ visit admin_question_path(question)
+
+ within("#poll_question_answer_#{answer.id}") do
+ click_link "Video list (#{answer.videos.count})"
+ end
+
+ click_link "Add video"
+
+ fill_in 'poll_question_answer_video_title', with: video_title
+ fill_in 'poll_question_answer_video_url', with: video_url
+
+ click_button "Save"
+
+ expect(page).to have_content(video_title)
+ expect(page).to have_content(video_url)
+ end
+
+end
From 0cf5299846ce095a2cae958532949019ba570009 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mar=C3=ADa=20Checa?=
Date: Fri, 6 Oct 2017 00:04:25 +0200
Subject: [PATCH 11/91] Set voting messages
---
app/views/polls/questions/_answers.html.erb | 4 ++--
app/views/polls/show.html.erb | 5 +++++
config/locales/en/general.yml | 3 ++-
config/locales/es/general.yml | 3 ++-
4 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/app/views/polls/questions/_answers.html.erb b/app/views/polls/questions/_answers.html.erb
index 2bef6de72..ccc9f0322 100644
--- a/app/views/polls/questions/_answers.html.erb
+++ b/app/views/polls/questions/_answers.html.erb
@@ -2,8 +2,8 @@
<% if can? :answer, question %>
<% question.question_answers.each do |answer| %>
<% if @answers_by_question_id[question.id] == answer.title %>
- ">
+ ">
<%= answer.title %>
<% else %>
diff --git a/app/views/polls/show.html.erb b/app/views/polls/show.html.erb
index b3a78e402..894899a72 100644
--- a/app/views/polls/show.html.erb
+++ b/app/views/polls/show.html.erb
@@ -38,6 +38,11 @@
<%= t("polls.show.already_voted_in_booth") %>
<% else %>
+ <% if current_user && !@poll.votable_by?(current_user) %>
+
+ <%= t("polls.show.already_voted_in_web") %>
+
+ <% end %>
<% @questions.each do |question| %>
<%= render 'polls/questions/question', question: question %>
<% end %>
diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml
index 1796049eb..473ac7391 100644
--- a/config/locales/en/general.yml
+++ b/config/locales/en/general.yml
@@ -481,7 +481,8 @@ en:
help_text_1: "Voting takes place when a citizen proposal supports reaches 1% of the census with voting rights. Voting can also include questions that the City Council ask to the citizens decision."
help_text_2: "To participate in the next vote you have to sign up on %{org} and verify your account. All registered voters in the city over 16 years old can vote. The results of all votes are binding on the government."
show:
- already_voted_in_booth: "You have already participated in a booth for this poll."
+ already_voted_in_booth: "You have already participated in a physical booth. You can not participate again."
+ already_voted_in_web: "You have already participated in this poll. If you vote again it will be overwritten."
back: Back to voting
cant_answer_not_logged_in: "You must %{signin} or %{signup} to participate."
signin: Sign in
diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml
index d5997e746..0af33da1d 100644
--- a/config/locales/es/general.yml
+++ b/config/locales/es/general.yml
@@ -481,7 +481,8 @@ es:
help_text_1: "Las votaciones se convocan cuando una propuesta ciudadana alcanza el 1% de apoyos del censo con derecho a voto. En las votaciones también se pueden incluir cuestiones que el Ayuntamiento somete a decisión directa de la ciudadanía."
help_text_2: "Para participar en la próxima votación tienes que registrarte en %{org} y verificar tu cuenta. Pueden votar todas las personas empadronadas en la ciudad mayores de 16 años. Los resultados de todas las votaciones serán vinculantes para el gobierno."
show:
- already_voted_in_booth: "Ya has participado en esta votación en una urna."
+ already_voted_in_booth: "Ya has participado en esta votación en urnas presenciales, no puedes volver a participar."
+ already_voted_in_web: "Ya has participado en esta votación. Si vuelves a votar se sobreescribirá tu resultado anterior."
back: Volver a votaciones
cant_answer_not_logged_in: "Necesitas %{signin} o %{signup} para participar."
signin: iniciar sesión
From 6192ea8b780e46b1e5711bb278ef20602b7c2887 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mar=C3=ADa=20Checa?=
Date: Thu, 5 Oct 2017 15:19:09 +0200
Subject: [PATCH 12/91] Added documents to Poll::Question::Answer
---
app/models/poll/question/answer.rb | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/app/models/poll/question/answer.rb b/app/models/poll/question/answer.rb
index 1746c480c..e1da38fe8 100644
--- a/app/models/poll/question/answer.rb
+++ b/app/models/poll/question/answer.rb
@@ -1,5 +1,10 @@
class Poll::Question::Answer < ActiveRecord::Base
include Galleryable
+ include Documentable
+ documentable max_documents_allowed: 3,
+ max_file_size: 3.megabytes,
+ accepted_content_types: [ "application/pdf" ]
+ accepts_nested_attributes_for :documents, allow_destroy: true
belongs_to :question, class_name: 'Poll::Question', foreign_key: 'question_id'
From 590344a576fb777be429709925738ffff76ac3f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mar=C3=ADa=20Checa?=
Date: Thu, 5 Oct 2017 15:20:09 +0200
Subject: [PATCH 13/91] Added view to upload documents to poll answers
---
.../poll/questions/answers_controller.rb | 21 +++++++-
.../poll/questions/answers/documents.html.erb | 51 +++++++++++++++++++
config/routes.rb | 4 +-
3 files changed, 73 insertions(+), 3 deletions(-)
create mode 100644 app/views/admin/poll/questions/answers/documents.html.erb
diff --git a/app/controllers/admin/poll/questions/answers_controller.rb b/app/controllers/admin/poll/questions/answers_controller.rb
index 660339844..9223e65d4 100644
--- a/app/controllers/admin/poll/questions/answers_controller.rb
+++ b/app/controllers/admin/poll/questions/answers_controller.rb
@@ -1,5 +1,6 @@
class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController
before_action :load_question
+ before_action :load_answer, only: [:update, :documents]
load_and_authorize_resource :question, class: "::Poll::Question"
@@ -18,10 +19,28 @@ class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController
end
end
+ def update
+ if @answer.update(answer_params)
+ redirect_to admin_question_path(@question), notice: t("flash.actions.save_changes.notice")
+ else
+ redirect_to :back
+ end
+ end
+
+ def documents
+ @documents = @answer.documents
+
+ render 'admin/poll/questions/answers/documents'
+ end
+
private
def answer_params
- params.require(:poll_question_answer).permit(:title, :description, :question_id)
+ params.require(:poll_question_answer).permit(:title, :description, :question_id, documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
+ end
+
+ def load_answer
+ @answer = ::Poll::Question::Answer.find(params[:id] || params[:answer_id])
end
def load_question
diff --git a/app/views/admin/poll/questions/answers/documents.html.erb b/app/views/admin/poll/questions/answers/documents.html.erb
new file mode 100644
index 000000000..17c6f52a3
--- /dev/null
+++ b/app/views/admin/poll/questions/answers/documents.html.erb
@@ -0,0 +1,51 @@
+
From 7fad60484220bb0e5a1796821a7bade726b81540 Mon Sep 17 00:00:00 2001
From: Angel Perez
Date: Fri, 6 Oct 2017 13:09:33 -0400
Subject: [PATCH 49/91] Avoid show div into markup for answers' information
If an answer does not contain any description or images
associated, the "poll-more-info-answers" div won't be
shown in the markup
Change requested by #1998
---
app/views/polls/show.html.erb | 38 +++++++++++++++++------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/app/views/polls/show.html.erb b/app/views/polls/show.html.erb
index 1eb128333..e3405c0a8 100644
--- a/app/views/polls/show.html.erb
+++ b/app/views/polls/show.html.erb
@@ -66,29 +66,29 @@
-
-
+ <% @poll.questions.map(&:question_answers).flatten.each do |answer| %>
+ <% if answer.description.present? || answer.images.any? %>
+
+
- <% @poll.questions.map(&:question_answers).flatten.each do |answer| %>
-
+
- <% if answer.description.present? %>
-
<%= answer.title %>
- <% end %>
+ <% if answer.description.present? %>
+
<%= answer.title %>
- <% if answer.images.any? %>
- <%= render "gallery", answer: answer %>
- <% end %>
+
+ <% end %>
+
<% @questions.each do |question| %>
<%= render 'polls/questions/question', question: question, token: @token %>
<% end %>
diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml
index 13ab81041..8f999d0ec 100644
--- a/config/locales/en/general.yml
+++ b/config/locales/en/general.yml
@@ -497,7 +497,7 @@ en:
show:
vote_answer: "Vote %{answer}"
voted: "You have voted %{answer}"
- voted_token: "You can write down this vote identifier, to check your vote on the final results."
+ voted_token: "You can write down this vote identifier, to check your vote on the final results:"
proposal_notifications:
new:
title: "Send message"
diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml
index 1650fb37b..677b03a4a 100644
--- a/config/locales/es/general.yml
+++ b/config/locales/es/general.yml
@@ -497,7 +497,7 @@ es:
show:
vote_answer: "Votar %{answer}"
voted: "Has votado %{answer}"
- voted_token: "Puedes apuntar este identificador de voto, para comprobar tu votación en el resultado final"
+ voted_token: "Puedes apuntar este identificador de voto, para comprobar tu votación en el resultado final:"
proposal_notifications:
new:
title: "Enviar mensaje"
diff --git a/db/migrate/20171006145053_add_token_to_poll_voters.rb b/db/migrate/20171006145053_add_token_to_poll_voters.rb
index 01e68031e..5d07f5065 100644
--- a/db/migrate/20171006145053_add_token_to_poll_voters.rb
+++ b/db/migrate/20171006145053_add_token_to_poll_voters.rb
@@ -1,6 +1,5 @@
class AddTokenToPollVoters < ActiveRecord::Migration
def change
add_column :poll_voters, :token, :string
- add_column :poll_voters, :token_seen_at, :date
end
end
diff --git a/db/schema.rb b/db/schema.rb
index be956a309..cafec3a82 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -761,7 +761,6 @@ ActiveRecord::Schema.define(version: 20171006145053) do
t.string "origin"
t.integer "officer_id"
t.string "token"
- t.date "token_seen_at"
end
add_index "poll_voters", ["booth_assignment_id"], name: "index_poll_voters_on_booth_assignment_id", using: :btree
From 8b8e8aff8fa636748128e4a3ab377fb19d1cc0da Mon Sep 17 00:00:00 2001
From: Angel Perez
Date: Fri, 6 Oct 2017 14:46:13 -0400
Subject: [PATCH 54/91] Show answer's title if answer has any records
associated
If an answer has a description and/or documents/images
associated, the answer's title will be shown on the UI
so the user can associate a certain answer with its
related records
See issue #1998, as well as commit 7fad604
---
app/views/polls/show.html.erb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/views/polls/show.html.erb b/app/views/polls/show.html.erb
index 8347455ae..5dc138f8d 100644
--- a/app/views/polls/show.html.erb
+++ b/app/views/polls/show.html.erb
@@ -74,9 +74,9 @@
<% end %>
From 8b2f6d454c302401f3a14fbbbcd916327a2d303a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mar=C3=ADa=20Checa?=
Date: Sat, 7 Oct 2017 17:33:27 +0200
Subject: [PATCH 82/91] Show poll answers in poll show view after voting on a
booth
If the user votes in a booth, it can see the poll and answers but can't see what he/she voted and the answers are inactive (no link, inactive ui style).
---
app/views/polls/questions/_answers.html.erb | 6 +++---
app/views/polls/show.html.erb | 6 +++---
spec/features/polls/polls_spec.rb | 12 ++++++++----
3 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/app/views/polls/questions/_answers.html.erb b/app/views/polls/questions/_answers.html.erb
index 7cdb50cfb..7d9bc4cac 100644
--- a/app/views/polls/questions/_answers.html.erb
+++ b/app/views/polls/questions/_answers.html.erb
@@ -1,8 +1,8 @@
- <% if can?(:answer, question) %>
+ <% if can?(:answer, question) && !question.poll.voted_in_booth?(current_user) %>
<% question.question_answers.each do |answer| %>
- <% if @answers_by_question_id[question.id] == answer.title &&
- (!voted_before_sign_in(question) ||
+ <% if @answers_by_question_id[question.id] == answer.title &&
+ (!voted_before_sign_in(question) ||
question.poll.voted_in_booth?(current_user)) %>
">
diff --git a/app/views/polls/show.html.erb b/app/views/polls/show.html.erb
index 126617684..80d8db60e 100644
--- a/app/views/polls/show.html.erb
+++ b/app/views/polls/show.html.erb
@@ -50,10 +50,10 @@
<%= t("polls.show.already_voted_in_web") %>
<% end %>
+ <% end %>
- <% @questions.each do |question| %>
- <%= render 'polls/questions/question', question: question, token: @token %>
- <% end %>
+ <% @questions.each do |question| %>
+ <%= render 'polls/questions/question', question: question, token: @token %>
<% end %>
diff --git a/spec/features/polls/polls_spec.rb b/spec/features/polls/polls_spec.rb
index 8f7a9b2de..d2be04447 100644
--- a/spec/features/polls/polls_spec.rb
+++ b/spec/features/polls/polls_spec.rb
@@ -319,10 +319,14 @@ feature 'Polls' do
visit poll_path(poll)
expect(page).to have_content "You have already participated in a physical booth. You can not participate again."
- expect(page).to have_content('Han Solo')
- expect(page).to have_content('Chewbacca')
- expect(page).to_not have_link('Han Solo')
- expect(page).to_not have_link('Chewbacca')
+
+ within("#poll_question_#{question.id}_answers") do
+ expect(page).to have_content('Han Solo')
+ expect(page).to have_content('Chewbacca')
+
+ expect(page).to_not have_link('Han Solo')
+ expect(page).to_not have_link('Chewbacca')
+ end
end
end
From 65237db099cba57b4a928b5e23765bc053170777 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mar=C3=ADa=20Checa?=
Date: Sat, 7 Oct 2017 17:50:42 +0200
Subject: [PATCH 83/91] Fixed poll answer document upload redirect
---
app/controllers/admin/poll/questions/answers_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/admin/poll/questions/answers_controller.rb b/app/controllers/admin/poll/questions/answers_controller.rb
index 511807b10..51c44dd94 100644
--- a/app/controllers/admin/poll/questions/answers_controller.rb
+++ b/app/controllers/admin/poll/questions/answers_controller.rb
@@ -26,7 +26,7 @@ class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController
def update
if @answer.update(answer_params)
- redirect_to admin_answer_path(@answer),
+ redirect_to admin_question_path(@answer.question),
notice: t("flash.actions.save_changes.notice")
else
redirect_to :back
From ca24be79e3c81a2ba36c0cf04d33a403861af148 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mar=C3=ADa=20Checa?=
Date: Sat, 7 Oct 2017 19:12:17 +0200
Subject: [PATCH 84/91] Moved token message below questions
---
app/views/polls/show.html.erb | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/views/polls/show.html.erb b/app/views/polls/show.html.erb
index 437328615..5ec66751c 100644
--- a/app/views/polls/show.html.erb
+++ b/app/views/polls/show.html.erb
@@ -39,12 +39,6 @@
<% else %>
- <% if poll_voter_token(@poll, current_user).empty? %>
-
- <%= t('poll_questions.show.voted_token') %>
-
- <% end %>
-
<% if current_user && !@poll.votable_by?(current_user) %>