diff --git a/app/controllers/admin/poll/questions_controller.rb b/app/controllers/admin/poll/questions_controller.rb index ab7297a95..3bbe1c395 100644 --- a/app/controllers/admin/poll/questions_controller.rb +++ b/app/controllers/admin/poll/questions_controller.rb @@ -1,4 +1,6 @@ class Admin::Poll::QuestionsController < Admin::BaseController + include CommentableActions + load_and_authorize_resource :poll load_and_authorize_resource :question, class: 'Poll::Question' @@ -20,6 +22,7 @@ class Admin::Poll::QuestionsController < Admin::BaseController def create @question.author = @question.proposal.try(:author) || current_user + recover_documents_from_cache(@question) if @question.save redirect_to admin_question_path(@question) @@ -29,6 +32,7 @@ class Admin::Poll::QuestionsController < Admin::BaseController end def show + @document = Document.new(documentable: @question) end def edit @@ -54,7 +58,8 @@ class Admin::Poll::QuestionsController < Admin::BaseController private def question_params - params.require(:poll_question).permit(:poll_id, :title, :question, :description, :proposal_id, :valid_answers) + params.require(:poll_question).permit(:poll_id, :title, :question, :description, :proposal_id, :valid_answers, :video_url, + documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id]) end def search_params diff --git a/app/controllers/polls/questions_controller.rb b/app/controllers/polls/questions_controller.rb index 1849dff97..bb1560f54 100644 --- a/app/controllers/polls/questions_controller.rb +++ b/app/controllers/polls/questions_controller.rb @@ -10,6 +10,8 @@ class Polls::QuestionsController < ApplicationController @comment_tree = CommentTree.new(@commentable, params[:page], @current_order) set_comment_flags(@comment_tree.comments) + @document = Document.new(documentable: @question) + question_answer = @question.answers.where(author_id: current_user.try(:id)).first @answers_by_question_id = {@question.id => question_answer.try(:answer)} end diff --git a/app/models/poll/question.rb b/app/models/poll/question.rb index 28dd8ed4a..8e02dcfe2 100644 --- a/app/models/poll/question.rb +++ b/app/models/poll/question.rb @@ -1,6 +1,11 @@ class Poll::Question < ActiveRecord::Base include Measurable include Searchable + include Documentable + documentable max_documents_allowed: 1, + max_file_size: 3.megabytes, + accepted_content_types: [ "application/pdf" ] + accepts_nested_attributes_for :documents, allow_destroy: true acts_as_paranoid column: :hidden_at include ActsAsParanoidAliases diff --git a/app/views/admin/poll/questions/_form.html.erb b/app/views/admin/poll/questions/_form.html.erb index 959aa4ddf..2b32ed680 100644 --- a/app/views/admin/poll/questions/_form.html.erb +++ b/app/views/admin/poll/questions/_form.html.erb @@ -26,6 +26,17 @@ ckeditor: { language: I18n.locale } %> +
<%= t("proposals.form.proposal_video_url_note") %>
+ <%= f.text_field :video_url, placeholder: t("proposals.form.proposal_video_url"), label: false, + aria: {describedby: "video-url-help-text"} %> +