Add form to publish a new first level comment from the comments box

This commit is contained in:
Amaia Castro
2017-01-18 16:39:06 +01:00
parent 35d2c54b4e
commit 1af047089f
6 changed files with 58 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
class Legislation::AnnotationsController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :authenticate_user!, only: [:create]
before_action :authenticate_user!, only: [:create, :new_comment]
before_action :convert_ranges_parameters, only: [:create]
load_and_authorize_resource :process
@@ -43,6 +43,7 @@ class Legislation::AnnotationsController < ApplicationController
def comments
@annotation = Legislation::Annotation.find(params[:annotation_id])
@comment = @annotation.comments.new
end
def new
@@ -51,6 +52,19 @@ class Legislation::AnnotationsController < ApplicationController
end
end
def new_comment
@draft_version = Legislation::DraftVersion.find(params[:draft_version_id])
@annotation = @draft_version.annotations.find(params[:annotation_id])
@comment = @annotation.comments.new(body: params[:comment][:body], user: current_user)
if @comment.save
@comment = @annotation.comments.new
end
respond_to do |format|
format.js { render :comments }
end
end
private
def annotation_params