2020-04-27 12:12:29 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-06-15 17:34:12 +02:00
|
|
|
json.extract! @machine, :id, :name, :description, :spec, :disabled, :slug
|
2015-05-05 03:10:25 +02:00
|
|
|
json.machine_image @machine.machine_image.attachment.large.url if @machine.machine_image
|
|
|
|
json.machine_files_attributes @machine.machine_files do |f|
|
|
|
|
json.id f.id
|
|
|
|
json.attachment f.attachment_identifier
|
|
|
|
json.attachment_url f.attachment_url
|
|
|
|
end
|
2017-10-10 18:12:07 +02:00
|
|
|
json.trainings @machine.trainings.each, :id, :name, :disabled
|
2021-06-25 17:24:34 +02:00
|
|
|
if current_user
|
|
|
|
json.current_user_is_trained current_user.training_machine?(@machine)
|
|
|
|
if !current_user.training_machine?(@machine) && current_user.next_training_reservation_by_machine(@machine)
|
|
|
|
json.current_user_next_training_reservation do
|
|
|
|
json.partial! 'api/reservations/reservation', reservation: current_user.next_training_reservation_by_machine(@machine)
|
|
|
|
end
|
2020-04-27 12:12:29 +02:00
|
|
|
end
|
2021-06-29 15:59:57 +02:00
|
|
|
json.current_user_has_packs current_user.packs?(@machine)
|
2021-06-25 17:24:34 +02:00
|
|
|
json.has_prepaid_packs_for_current_user @machine.packs?(current_user)
|
2020-04-27 12:12:29 +02:00
|
|
|
end
|
2015-05-05 03:10:25 +02:00
|
|
|
|
|
|
|
json.machine_projects @machine.projects.published.last(10) do |p|
|
|
|
|
json.id p.id
|
|
|
|
json.name p.name
|
|
|
|
json.slug p.slug
|
|
|
|
end
|