diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb
index c95c8ed1f..db4fb567c 100644
--- a/app/controllers/admin/poll/polls_controller.rb
+++ b/app/controllers/admin/poll/polls_controller.rb
@@ -73,7 +73,9 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController
end
def poll_params
- params.require(:poll).permit(:name, :starts_at, :ends_at, :geozone_restricted, geozone_ids: [])
+ params.require(:poll).permit(:name, :starts_at, :ends_at, :geozone_restricted, :summary, :description,
+ geozone_ids: [],
+ image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
end
def search_params
diff --git a/app/models/poll.rb b/app/models/poll.rb
index 3873ac5e0..e852e912a 100644
--- a/app/models/poll.rb
+++ b/app/models/poll.rb
@@ -1,4 +1,6 @@
class Poll < ActiveRecord::Base
+ include Imageable
+
has_many :booth_assignments, class_name: "Poll::BoothAssignment"
has_many :booths, through: :booth_assignments
has_many :partial_results, through: :booth_assignments
diff --git a/app/views/admin/poll/polls/_form.html.erb b/app/views/admin/poll/polls/_form.html.erb
index 0b99ea9f5..3fa7daa4f 100644
--- a/app/views/admin/poll/polls/_form.html.erb
+++ b/app/views/admin/poll/polls/_form.html.erb
@@ -19,6 +19,43 @@
+
+
+ <%=f.text_area :summary, rows: 4%>
+
+
+
+
+
+ <%=f.text_area :description, rows: 8%>
+
+
+
+
+
+ <%= f.label :image, t("images.form.admin_title") %>
+
+
+ <%= f.fields_for :image do |image_builder| %>
+ <%= render 'images/image_fields', f: image_builder, imageable: @poll %>
+ <% end %>
+
+
+
+ <%= link_to_add_association t('images.form.add_new_image'), f, :image,
+ force_non_association_create: true,
+ partial: "images/image_fields",
+ id: "new_image_link",
+ class: "button hollow #{"hide" if @poll.image.present?}",
+ render_options: {
+ locals: { imageable: @poll }
+ },
+ data: {
+ association_insertion_node: "#nested-image",
+ association_insertion_method: "append"
+ } %>
+
+
<%= f.check_box :geozone_restricted, data: { checkbox_toggle: "#geozones" } %>
diff --git a/config/locales/en/images.yml b/config/locales/en/images.yml
index 6f16061fa..087c85021 100644
--- a/config/locales/en/images.yml
+++ b/config/locales/en/images.yml
@@ -9,6 +9,8 @@ en:
delete_button: Remove image
note: "You can upload one image of following content types: %{accepted_content_types}, up to %{max_file_size} MB."
add_new_image: Add image
+ title_placeholder: Add a descriptive title for the image
+ admin_title: "Main image of the poll"
actions:
destroy:
diff --git a/config/locales/es/images.yml b/config/locales/es/images.yml
index 869a0824e..0207bceed 100644
--- a/config/locales/es/images.yml
+++ b/config/locales/es/images.yml
@@ -9,6 +9,7 @@ es:
note: "Puedes subir una imagen en los formatos: %{accepted_content_types}, y de hasta %{max_file_size} MB por archivo."
add_new_image: Añadir imagen
title_placeholder: Añade un título descriptivo para la imagen
+ admin_title: "Imagen principal de la votación"
actions:
destroy:
diff --git a/db/migrate/20170928132402_add_summary_and_description_to_polls.rb b/db/migrate/20170928132402_add_summary_and_description_to_polls.rb
new file mode 100644
index 000000000..6fb965346
--- /dev/null
+++ b/db/migrate/20170928132402_add_summary_and_description_to_polls.rb
@@ -0,0 +1,6 @@
+class AddSummaryAndDescriptionToPolls < ActiveRecord::Migration
+ def change
+ add_column :polls, :summary, :text
+ add_column :polls, :description, :text
+ end
+end