diff --git a/app/controllers/polls/questions_controller.rb b/app/controllers/polls/questions_controller.rb index dcf459485..07d7aa28f 100644 --- a/app/controllers/polls/questions_controller.rb +++ b/app/controllers/polls/questions_controller.rb @@ -3,6 +3,18 @@ class Polls::QuestionsController < ApplicationController load_and_authorize_resource :poll load_and_authorize_resource :question, class: 'Poll::Question', through: :poll + has_filters %w{opened expired incoming} + has_orders %w{most_voted newest oldest}, only: :show + + def show + @commentable = @question.proposal.present? ? @question.proposal : @question + @comment_tree = CommentTree.new(@commentable, params[:page], @current_order) + set_comment_flags(@comment_tree.comments) + + #@question_answer = @question.answers.where(author_id: current_user.try(:id)).first + @answers_by_question_id = {@question.id => params[:answer]} + end + def answer partial_result = @question.partial_results.find_or_initialize_by(author: current_user, amount: 1, diff --git a/app/models/abilities/everyone.rb b/app/models/abilities/everyone.rb index 8424500a3..d8b7c1da7 100644 --- a/app/models/abilities/everyone.rb +++ b/app/models/abilities/everyone.rb @@ -7,6 +7,7 @@ module Abilities can [:read, :map, :summary], Proposal can :read, Comment can :read, Poll + can :read, Poll::Question can :read, SpendingProposal can :read, Legislation can :read, User diff --git a/app/views/polls/questions/show.html.erb b/app/views/polls/questions/show.html.erb new file mode 100644 index 000000000..e48a65ad0 --- /dev/null +++ b/app/views/polls/questions/show.html.erb @@ -0,0 +1,55 @@ +
+
+
+ <%= render "shared/back_link" %> + +

<%= @question.title %>

+ + <% if @question.proposal.present? %> +
+ <%= link_to t('questions.show.original_proposal'), @question.proposal %> +
+ <% end %> + +

<%= @question.summary %>

+ +
    + <% @question.geozones.each do |g| %> +
  • <%= g.name %>
  • + <% end %> +
+
+ +
+

+ <%= t('questions.show.author') %>
+ <%= link_to @question.author.name, @question.author %> +

+ +

+ <%= t('questions.show.external_url') %>
+ <%# link_to @question.external_url, @question.external_url %> +

+
+
+
+ +
+
+

<%= @question.question %>

+
+
+ +
+ <%= render "answers", question: @question %> +
+ +
+
+

<%= t('questions.show.more_info') %>

+ <%= @question.description %> +
+
+ + +<%= render "comments" %> diff --git a/app/views/polls/show.html.erb b/app/views/polls/show.html.erb index ad7818a78..d9bfbbd3b 100644 --- a/app/views/polls/show.html.erb +++ b/app/views/polls/show.html.erb @@ -27,7 +27,7 @@ <% @answerable_questions.each do |question| %>
- <%= question.title %> + <%= link_to question.title, poll_question_path(@poll, question) %>
<%= render 'polls/questions/answers', question: question %> @@ -44,7 +44,7 @@ <% @non_answerable_questions.each do |question| %>
- <%= question.title %> + <%= link_to question.title, poll_question_path(@poll, question) %>
<%= render 'polls/questions/answers', question: question %> diff --git a/config/routes.rb b/config/routes.rb index 69a613bdd..0d227717b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -84,7 +84,7 @@ Rails.application.routes.draw do end resources :polls, only: [:show, :index] do - resources :questions, only: [], controller: 'polls/questions' do + resources :questions, only: [:show], controller: 'polls/questions' do post :answer, on: :member end end