1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-12 23:09:03 +01:00
fab-manager/app/views/open_api/v1/reservations/index.json.jbuilder

31 lines
1.0 KiB
Plaintext
Raw Normal View History

# frozen_string_literal: true
2016-05-04 18:17:50 +02:00
json.reservations @reservations do |reservation|
json.extract! reservation, :id, :reservable_id, :reservable_type, :updated_at, :created_at
2016-05-04 18:17:50 +02:00
if reservation.association(:statistic_profile).loaded?
json.user_id reservation.statistic_profile.user_id
unless reservation.statistic_profile.user.nil?
json.user do
json.partial! 'open_api/v1/users/user', user: reservation.statistic_profile.user
end
2016-05-04 18:17:50 +02:00
end
end
json.reservable do
2023-03-03 10:09:07 +01:00
case reservation.reservable_type
when 'Training'
2016-05-04 18:17:50 +02:00
json.partial! 'open_api/v1/trainings/training', training: reservation.reservable
2023-03-03 10:09:07 +01:00
when 'Machine'
2016-05-04 18:17:50 +02:00
json.partial! 'open_api/v1/machines/machine', machine: reservation.reservable
2023-03-03 10:09:07 +01:00
when 'Event'
2016-05-04 18:17:50 +02:00
json.partial! 'open_api/v1/events/event', event: reservation.reservable
end
end
2023-03-03 10:09:07 +01:00
json.reserved_slots reservation.slots_reservations do |slot_reservation|
json.extract! slot_reservation, :canceled_at
2023-03-30 13:22:36 +02:00
json.extract! slot_reservation.slot, :availability_id, :start_at, :end_at
2023-03-03 10:09:07 +01:00
end
2016-05-04 18:17:50 +02:00
end