1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/app/views/api/machines/index.json.jbuilder
2016-03-23 18:39:41 +01:00

14 lines
731 B
Ruby

user_is_admin = (current_user and current_user.is_admin?)
json.array!(@machines) do |machine|
json.extract! machine, :id, :name, :description, :spec, :slug
json.url machine_url(machine, format: :json)
json.machine_image machine.machine_image.attachment.medium.url if machine.machine_image
json.current_user_is_training current_user.is_training_machine?(machine) if current_user
json.current_user_training_reservation do
json.partial! 'api/reservations/reservation', reservation: current_user.training_reservation_by_machine(machine)
end if current_user and !current_user.is_training_machine?(machine) and current_user.training_reservation_by_machine(machine)
json.plan_ids machine.plan_ids if user_is_admin
end