1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-08 23:46:14 +01:00
fab-manager/app/views/api/machines/index.json.jbuilder

14 lines
731 B
Plaintext
Raw Normal View History

2016-03-23 18:39:41 +01:00
user_is_admin = (current_user and current_user.is_admin?)
2015-05-05 03:10:25 +02:00
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
2016-03-23 18:39:41 +01:00
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
2015-05-05 03:10:25 +02:00
end