mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
(bug) unable to reserve a space
This commit is contained in:
parent
2ad842a93b
commit
6ce762f778
@ -2,6 +2,7 @@
|
||||
|
||||
## next deploy
|
||||
|
||||
- Fix a bug: unable to reserve a space
|
||||
## v5.4.7 2022 June 29
|
||||
|
||||
- Removed the admins' button to scroll to the featured event
|
||||
|
@ -167,7 +167,7 @@ class API::AvailabilitiesController < API::ApiController
|
||||
availabilities_filtered << a if filter_event?(a)
|
||||
end
|
||||
end
|
||||
availabilities_filtered.delete_if(&method(:remove_completed?))
|
||||
availabilities_filtered.delete_if(&method(:remove_full?))
|
||||
end
|
||||
|
||||
def filter_training?(availability)
|
||||
@ -186,8 +186,8 @@ class API::AvailabilitiesController < API::ApiController
|
||||
params[:evt] && params[:evt] == 'true' && availability.available_type == 'event'
|
||||
end
|
||||
|
||||
def remove_completed?(availability)
|
||||
params[:dispo] == 'false' && (availability.is_reserved || (availability.try(:completed?) && availability.completed?))
|
||||
def remove_full?(availability)
|
||||
params[:dispo] == 'false' && (availability.is_reserved || (availability.try(:full?) && availability.full?))
|
||||
end
|
||||
|
||||
def define_max_visibility
|
||||
|
@ -44,7 +44,7 @@ module AvailabilityHelper
|
||||
def trainings_events_border_color(availability)
|
||||
if availability.is_reserved
|
||||
IS_RESERVED_BY_CURRENT_USER
|
||||
elsif availability.completed?
|
||||
elsif availability.full?
|
||||
IS_COMPLETED
|
||||
else
|
||||
case availability.available_type
|
||||
|
@ -111,9 +111,9 @@ class Availability < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
# return training reservations is complete?
|
||||
# if haven't defined a nb_total_places, places are unlimited
|
||||
def completed?
|
||||
# check if the reservations are complete?
|
||||
# if a nb_total_places hasn't been defined, then places are unlimited
|
||||
def full?
|
||||
return false if nb_total_places.blank?
|
||||
|
||||
if available_type == 'training' || available_type == 'space'
|
||||
|
@ -45,21 +45,21 @@ class CartItem::Reservation < CartItem::BaseItem
|
||||
@slots.each do |slot|
|
||||
availability = Availability.find_by(id: slot[:availability_id])
|
||||
if availability.nil?
|
||||
@errors[:slot] = 'slot availability no exist'
|
||||
@errors[:slot] = 'slot availability does not exist'
|
||||
return false
|
||||
end
|
||||
|
||||
if availability.available_type == 'machines'
|
||||
s = Slot.find_by(start_at: slot[:start_at], end_at: slot[:end_at], availability_id: slot[:availability_id], canceled_at: nil)
|
||||
unless s.nil?
|
||||
@errors[:slot] = 'slot has reserved'
|
||||
@errors[:slot] = 'slot is reserved'
|
||||
return false
|
||||
end
|
||||
elsif availability.available_type == 'space' && availability.spaces.first.disabled.nil?
|
||||
elsif availability.available_type == 'space' && availability.spaces.first.disabled
|
||||
@errors[:slot] = 'space is disabled'
|
||||
return false
|
||||
elsif availability.completed?
|
||||
@errors[:slot] = 'availability has completed'
|
||||
elsif availability.full?
|
||||
@errors[:slot] = 'availability is complete'
|
||||
return false
|
||||
end
|
||||
|
||||
|
@ -112,7 +112,7 @@ class Reservation < ApplicationRecord
|
||||
|
||||
def training_not_fully_reserved
|
||||
slot = slots.first
|
||||
errors.add(:training, 'already fully reserved') if Availability.find(slot.availability_id).completed?
|
||||
errors.add(:training, 'already fully reserved') if Availability.find(slot.availability_id).full?
|
||||
end
|
||||
|
||||
def slots_not_locked
|
||||
|
@ -25,7 +25,7 @@ json.array!(@availabilities) do |availability|
|
||||
if availability.is_reserved
|
||||
json.is_reserved true
|
||||
json.title "#{availability.title}' - #{t('trainings.i_ve_reserved')}"
|
||||
elsif availability.completed?
|
||||
elsif availability.full?
|
||||
json.is_completed true
|
||||
json.title "#{availability.title} - #{t('trainings.completed')}"
|
||||
end
|
||||
|
@ -5,7 +5,7 @@ json.array!(@availabilities) do |a|
|
||||
if a.is_reserved
|
||||
json.is_reserved true
|
||||
json.title "#{a.trainings[0].name}' - #{t('trainings.i_ve_reserved')}"
|
||||
elsif a.completed?
|
||||
elsif a.full?
|
||||
json.is_completed true
|
||||
json.title "#{a.trainings[0].name} - #{t('trainings.completed')}"
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user