mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-11 01:50:18 +08:00
32 lines
790 B
Ruby
32 lines
790 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
module Api
|
||
|
module V1
|
||
|
class InventoriesController < BaseController
|
||
|
before_action :load_team, only: %i(show index)
|
||
|
before_action :load_inventory, only: %i(show)
|
||
|
|
||
|
def index
|
||
|
inventories =
|
||
|
@team.repositories.page(params[:page]).per(params[:page_size])
|
||
|
render json: inventories, each_serializer: InventorySerializer
|
||
|
end
|
||
|
|
||
|
def show
|
||
|
render json: @inventory, serializer: InventorySerializer
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
def load_team
|
||
|
@team = Team.find(params.require(:team_id))
|
||
|
return render json: {}, status: :forbidden unless can_read_team?(@team)
|
||
|
end
|
||
|
|
||
|
def load_inventory
|
||
|
@inventory = @team.repositories.find(params.require(:id))
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|