Basic annotation creation

This commit is contained in:
Fernando Blat
2017-01-10 18:21:37 +01:00
parent 4fe656bdd4
commit 4431d95d31
8 changed files with 75 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ class Legislation::AnnotationsController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :authenticate_user!, only: [:create]
before_action :convert_ranges_parameters, only: [:create]
load_and_authorize_resource :process
load_and_authorize_resource :draft_version, through: :process
@@ -44,6 +45,13 @@ class Legislation::AnnotationsController < ApplicationController
@annotation = Legislation::Annotation.find(params[:annotation_id])
end
def new
respond_to do |format|
format.js
end
end
private
def annotation_params
@@ -58,4 +66,11 @@ class Legislation::AnnotationsController < ApplicationController
"legislation_draft_version_id": @draft_version.id
end
def convert_ranges_parameters
if params[:annotation] && params[:annotation][:ranges]
params[:annotation][:ranges] = JSON.parse(params[:annotation][:ranges])
end
rescue JSON::ParserError
end
end