<% 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/43] 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/43] 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/43] 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 @@
+