2019-06-06 16:34:53 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-01 10:38:42 +02:00
|
|
|
requested_current = (current_user and current_user.id == @member.id)
|
|
|
|
|
2018-07-04 14:05:44 +02:00
|
|
|
json.partial! 'api/members/member', member: @member
|
2019-01-10 16:50:54 +01:00
|
|
|
json.extract! @member, :uid, :slug, :is_allow_contact, :is_allow_newsletter
|
2016-08-02 15:11:26 +02:00
|
|
|
|
2019-06-06 12:00:21 +02:00
|
|
|
json.training_ids @member.statistic_profile.training_ids
|
2016-03-23 18:39:41 +01:00
|
|
|
json.trainings @member.trainings do |t|
|
|
|
|
json.id t.id
|
|
|
|
json.name t.name
|
|
|
|
end
|
|
|
|
json.training_reservations @member.reservations.where(reservable_type: 'Training') do |r|
|
|
|
|
json.id r.id
|
|
|
|
json.start_at r.slots.first.start_at
|
|
|
|
json.end_at r.slots.first.end_at
|
|
|
|
json.reservable r.reservable
|
2020-02-05 16:53:47 +01:00
|
|
|
json.reservable_type 'Training'
|
2019-06-06 12:00:21 +02:00
|
|
|
json.is_valid @member.statistic_profile.training_ids.include?(r.reservable_id)
|
2022-07-19 08:21:18 +02:00
|
|
|
json.canceled_at r.slots_reservations.first.canceled_at
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|
2020-02-05 16:53:47 +01:00
|
|
|
json.machine_reservations @member.reservations.where(reservable_type: 'Machine') do |r|
|
|
|
|
json.id r.id
|
|
|
|
json.start_at r.slots.first.start_at
|
|
|
|
json.end_at r.slots.first.end_at
|
|
|
|
json.reservable r.reservable
|
|
|
|
json.reservable_type 'Machine'
|
2022-07-19 08:21:18 +02:00
|
|
|
json.canceled_at r.slots_reservations.first.canceled_at
|
2020-02-05 16:53:47 +01:00
|
|
|
end
|
|
|
|
json.space_reservations @member.reservations.where(reservable_type: 'Space') do |r|
|
|
|
|
json.id r.id
|
|
|
|
json.start_at r.slots.first.start_at
|
|
|
|
json.end_at r.slots.first.end_at
|
|
|
|
json.reservable r.reservable
|
|
|
|
json.reservable_type 'Space'
|
2022-07-19 08:21:18 +02:00
|
|
|
json.canceled_at r.slots_reservations.first.canceled_at
|
2020-02-05 16:53:47 +01:00
|
|
|
end
|
2018-07-04 14:05:44 +02:00
|
|
|
|
2015-05-05 03:10:25 +02:00
|
|
|
json.all_projects @member.all_projects do |project|
|
2016-06-01 10:38:42 +02:00
|
|
|
if requested_current || project.state == 'published'
|
2019-06-06 16:34:53 +02:00
|
|
|
json.extract! project, :id, :name, :description, :licence_id, :slug, :state
|
|
|
|
json.author_id project.author.user_id
|
2020-10-29 15:53:29 +01:00
|
|
|
|
2016-06-01 10:38:42 +02:00
|
|
|
json.project_image project.project_image.attachment.large.url if project.project_image
|
|
|
|
json.machine_ids project.machine_ids
|
|
|
|
json.machines project.machines do |m|
|
|
|
|
json.id m.id
|
|
|
|
json.name m.name
|
|
|
|
end
|
|
|
|
json.user_ids project.user_ids
|
|
|
|
json.component_ids project.component_ids
|
|
|
|
json.components project.components do |c|
|
|
|
|
json.id c.id
|
|
|
|
json.name c.name
|
|
|
|
end
|
|
|
|
json.project_users project.project_users do |pu|
|
|
|
|
json.id pu.user.id
|
|
|
|
json.first_name pu.user.profile.first_name
|
|
|
|
json.last_name pu.user.profile.last_name
|
|
|
|
json.full_name pu.user.profile.full_name
|
2019-06-04 13:33:00 +02:00
|
|
|
if pu.user.profile.user_avatar
|
|
|
|
json.user_avatar do
|
|
|
|
json.id pu.user.profile.user_avatar.id
|
|
|
|
json.attachment_url pu.user.profile.user_avatar.attachment_url
|
|
|
|
end
|
|
|
|
end
|
2016-06-01 10:38:42 +02:00
|
|
|
json.username pu.user.username
|
|
|
|
json.is_valid pu.is_valid
|
2019-06-04 13:33:00 +02:00
|
|
|
json.valid_token pu.valid_token if !pu.is_valid && @member == pu.user
|
2016-06-01 10:38:42 +02:00
|
|
|
end
|
2015-05-05 03:10:25 +02:00
|
|
|
end
|
|
|
|
end
|
2016-03-23 18:39:41 +01:00
|
|
|
json.events_reservations @member.reservations.where(reservable_type: 'Event').joins(:slots).order('slots.start_at asc') do |r|
|
|
|
|
json.id r.id
|
|
|
|
json.start_at r.slots.first.start_at
|
|
|
|
json.end_at r.slots.first.end_at
|
|
|
|
json.nb_reserve_places r.nb_reserve_places
|
2016-08-29 16:54:10 +02:00
|
|
|
json.tickets r.tickets do |t|
|
|
|
|
json.booked t.booked
|
|
|
|
json.price_category do
|
|
|
|
json.name t.event_price_category.price_category.name
|
|
|
|
end
|
|
|
|
end
|
2016-03-23 18:39:41 +01:00
|
|
|
json.reservable r.reservable
|
2020-02-05 16:53:47 +01:00
|
|
|
json.reservable_type 'Event'
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|
|
|
|
json.invoices @member.invoices.order('reference DESC') do |i|
|
|
|
|
json.id i.id
|
|
|
|
json.reference i.reference
|
2019-06-06 16:34:53 +02:00
|
|
|
json.total i.total / 100.00
|
2016-03-23 18:39:41 +01:00
|
|
|
json.is_avoir i.is_a?(Avoir)
|
|
|
|
json.date i.is_a?(Avoir) ? i.avoir_date : i.created_at
|
|
|
|
end
|
|
|
|
json.tag_ids @member.tag_ids
|
|
|
|
json.tags @member.tags do |t|
|
|
|
|
json.id t.id
|
|
|
|
json.name t.name
|
|
|
|
end
|
|
|
|
json.merged_at @member.merged_at
|