From 4dd7b1345f94b2254542eac254fba53e79e4b573 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Fri, 24 Feb 2023 15:24:09 +0100 Subject: [PATCH] (bug) members can change/cancel their reservations --- CHANGELOG.md | 1 + app/views/api/availabilities/_slot.json.jbuilder | 6 +++--- app/views/api/availabilities/machine.json.jbuilder | 2 +- app/views/api/availabilities/spaces.json.jbuilder | 2 +- app/views/api/availabilities/trainings.json.jbuilder | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42efe57f8..f3223bb76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Fix a bug: unable to update recurrent events - Fix a bug: invalid border color for slots +- Fix a bug: members can change/cancel their reservations ## v5.7.1 2023 February 20 diff --git a/app/views/api/availabilities/_slot.json.jbuilder b/app/views/api/availabilities/_slot.json.jbuilder index 12a95454e..70f3b3f2c 100644 --- a/app/views/api/availabilities/_slot.json.jbuilder +++ b/app/views/api/availabilities/_slot.json.jbuilder @@ -1,8 +1,8 @@ # frozen_string_literal: true json.slot_id slot.id -json.can_modify slot.modifiable?(operator_role, @user&.id, reservable) -json.title Slots::TitleService.new(operator_role, @user).call(slot, [reservable]) +json.can_modify slot.modifiable?(operator_role, user&.id, reservable) +json.title Slots::TitleService.new(operator_role, user).call(slot, [reservable]) json.start slot.start_at.iso8601 json.end slot.end_at.iso8601 json.is_reserved slot.reserved?(reservable) @@ -10,7 +10,7 @@ json.is_completed slot.full?(reservable) json.backgroundColor 'white' json.availability_id slot.availability_id -json.slots_reservations_ids Slots::ReservationsService.user_reservations(slot, @user, reservable)[:reservations] +json.slots_reservations_ids Slots::ReservationsService.user_reservations(slot, user, reservable)[:reservations] json.tag_ids slot.availability.tag_ids json.tags slot.availability.tags do |t| diff --git a/app/views/api/availabilities/machine.json.jbuilder b/app/views/api/availabilities/machine.json.jbuilder index 7535a6d6f..0ba0fa432 100644 --- a/app/views/api/availabilities/machine.json.jbuilder +++ b/app/views/api/availabilities/machine.json.jbuilder @@ -1,7 +1,7 @@ # frozen_string_literal: true json.array!(@slots) do |slot| - json.partial! 'api/availabilities/slot', slot: slot, operator_role: @operator_role, reservable: @machine + json.partial! 'api/availabilities/slot', slot: slot, operator_role: @operator_role, reservable: @machine, user: @customer json.borderColor machines_slot_border_color(slot, @machine, @customer) json.machine do diff --git a/app/views/api/availabilities/spaces.json.jbuilder b/app/views/api/availabilities/spaces.json.jbuilder index 2200fb689..56be9d4bf 100644 --- a/app/views/api/availabilities/spaces.json.jbuilder +++ b/app/views/api/availabilities/spaces.json.jbuilder @@ -1,7 +1,7 @@ # frozen_string_literal: true json.array!(@slots) do |slot| - json.partial! 'api/availabilities/slot', slot: slot, operator_role: @operator_role, reservable: @space + json.partial! 'api/availabilities/slot', slot: slot, operator_role: @operator_role, reservable: @space, user: @customer json.is_completed slot.full? json.borderColor space_slot_border_color(slot) diff --git a/app/views/api/availabilities/trainings.json.jbuilder b/app/views/api/availabilities/trainings.json.jbuilder index b4efdce10..5bd40637c 100644 --- a/app/views/api/availabilities/trainings.json.jbuilder +++ b/app/views/api/availabilities/trainings.json.jbuilder @@ -1,7 +1,7 @@ # frozen_string_literal: true json.array!(@slots) do |slot| - json.partial! 'api/availabilities/slot', slot: slot, operator_role: @operator_role, reservable: slot.availability.trainings.first + json.partial! 'api/availabilities/slot', slot: slot, operator_role: @operator_role, reservable: slot.availability.trainings.first, user: @customer json.borderColor trainings_events_border_color(slot.availability) json.is_completed slot.full?