diff --git a/app/controllers/admin/legislation/questions_controller.rb b/app/controllers/admin/legislation/questions_controller.rb index a643c39f5..9a1c3eb5b 100644 --- a/app/controllers/admin/legislation/questions_controller.rb +++ b/app/controllers/admin/legislation/questions_controller.rb @@ -7,6 +7,7 @@ class Admin::Legislation::QuestionsController < Admin::Legislation::BaseControll end def create + @question.author = current_user if @question.save redirect_to admin_legislation_process_questions_path else diff --git a/app/controllers/legislation/questions_controller.rb b/app/controllers/legislation/questions_controller.rb index 01653fca3..7114c98cb 100644 --- a/app/controllers/legislation/questions_controller.rb +++ b/app/controllers/legislation/questions_controller.rb @@ -2,6 +2,11 @@ class Legislation::QuestionsController < Legislation::BaseController load_and_authorize_resource :process load_and_authorize_resource :question, through: :process + has_orders %w{most_voted newest oldest}, only: :show + def show + @commentable = @question + @comment_tree = CommentTree.new(@commentable, params[:page], @current_order) + set_comment_flags(@comment_tree.comments) end end diff --git a/app/models/legislation/question.rb b/app/models/legislation/question.rb index c7c123437..2b779d1f8 100644 --- a/app/models/legislation/question.rb +++ b/app/models/legislation/question.rb @@ -1,8 +1,11 @@ class Legislation::Question < ActiveRecord::Base + acts_as_paranoid column: :hidden_at + include ActsAsParanoidAliases + + belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id' belongs_to :process, class_name: 'Legislation::Process', foreign_key: 'legislation_process_id' has_many :question_options, class_name: 'Legislation::QuestionOption', foreign_key: 'legislation_question_id', dependent: :destroy, inverse_of: :question - # has_many :answers has_many :comments, as: :commentable accepts_nested_attributes_for :question_options, :reject_if => proc { |attributes| attributes[:value].blank? }, allow_destroy: true diff --git a/app/models/legislation/question_option.rb b/app/models/legislation/question_option.rb index 6d3654877..93bc20320 100644 --- a/app/models/legislation/question_option.rb +++ b/app/models/legislation/question_option.rb @@ -1,7 +1,8 @@ class Legislation::QuestionOption < ActiveRecord::Base - belongs_to :question, class_name: 'Legislation::Question', foreign_key: 'legislation_question_id', inverse_of: :question_options + acts_as_paranoid column: :hidden_at + include ActsAsParanoidAliases - # has_many :answers + belongs_to :question, class_name: 'Legislation::Question', foreign_key: 'legislation_question_id', inverse_of: :question_options validates :question, presence: true validates :value, presence: true, uniqueness: { scope: :legislation_question_id } diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index 549b62862..deb6fa58d 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -1,6 +1,6 @@ <% cache [locale_and_user_status(comment), comment, commentable_cache_key(comment.commentable), comment.author, (@comment_flags[comment.id] if @comment_flags)] do %>
+ <%= t("legislation.questions.show.comments") %> + (<%= @question.comments_count %>) +
+ + <%= render 'shared/wide_order_selector', i18n_namespace: "comments" %> + + <% if user_signed_in? %> + <%= render 'comments/form', {commentable: @question, parent_id: nil, toggeable: false} %> + <% else %> ++ +