Return a permissions hash with all the annotations
This commit is contained in:
@@ -6,14 +6,14 @@ class AnnotationsController < ApplicationController
|
|||||||
@annotation = Annotation.new(annotation_params)
|
@annotation = Annotation.new(annotation_params)
|
||||||
@annotation.user = current_user
|
@annotation.user = current_user
|
||||||
if @annotation.save
|
if @annotation.save
|
||||||
render json: @annotation.to_json
|
render json: @annotation.to_json(methods: :permissions)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@annotation = Annotation.find!(params[:id])
|
@annotation = Annotation.find!(params[:id])
|
||||||
if @annotation.update_attributes(annotation_params)
|
if @annotation.update_attributes(annotation_params)
|
||||||
render json: @annotation.to_json
|
render json: @annotation.to_json(methods: :permissions)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ class AnnotationsController < ApplicationController
|
|||||||
def search
|
def search
|
||||||
@annotations = Annotation.where(legislation_id: params[:legislation_id])
|
@annotations = Annotation.where(legislation_id: params[:legislation_id])
|
||||||
annotations_hash = { total: @annotations.size, rows: @annotations }
|
annotations_hash = { total: @annotations.size, rows: @annotations }
|
||||||
render json: annotations_hash.to_json
|
render json: annotations_hash.to_json(methods: :permissions)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -3,4 +3,8 @@ class Annotation < ActiveRecord::Base
|
|||||||
|
|
||||||
belongs_to :legislation
|
belongs_to :legislation
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
|
def permissions
|
||||||
|
{ update: [user_id], delete: [user_id] }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user