Commit 582d0b5a authored by hellekin's avatar hellekin

Add positions policy and controller

parent babfaa7c
# frozen_string_literal: true
class Api::V0::PositionsController < ApplicationController
def index
@positions = policy_scope(Position)
render jsonapi: @positions,
fields: params[:fields],
include: include_from_params
end
def show
@position = policy_scope(Position).find(params[:id])
authorize @position
render jsonapi: @position,
include: include_from_params,
fields: params[:fields]
end
private
def model_types
%w(locations).freeze
end
end
# frozen_string_literal: true
class PositionPolicy < ApplicationPolicy
def index?
true
end
def show?
true
end
def create?
user.editor?
end
def update?
create?
end
def destroy?
user.maintainer?
end
class Scope < Scope
def resolve
scope.all
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment