diff --git a/app/controllers/api/v1/availabilities_controller.rb b/app/controllers/api/v1/availabilities_controller.rb index f1e13ab1..e37b70d1 100644 --- a/app/controllers/api/v1/availabilities_controller.rb +++ b/app/controllers/api/v1/availabilities_controller.rb @@ -24,7 +24,7 @@ def index end # Trigger the job to create next month's availabilities if needed - #trigger_recurring_availability_job(viewing_month, viewing_year) + # trigger_recurring_availability_job(viewing_month, viewing_year) # Fetch the availabilities within the specified date range @availabilities = Availability.where(start_time: start_date..end_date) diff --git a/app/controllers/api/v1/orders_controller.rb b/app/controllers/api/v1/orders_controller.rb index dceb0509..1eeb68ab 100644 --- a/app/controllers/api/v1/orders_controller.rb +++ b/app/controllers/api/v1/orders_controller.rb @@ -157,7 +157,7 @@ def associate_address_with_user(order) # Check if the address should be saved to the user if order.address.save_to_user # Ensure the address is not already associated with the user or the organization - unless order.user.addresses.exists?(id: order.address.id) || + unless order.user.addresses.exists?(id: order.address.id) || (order.user.organization && order.user.organization.addresses.exists?(id: order.address.id)) order.user.addresses << order.address end diff --git a/app/serializers/user_profile_serializer.rb b/app/serializers/user_profile_serializer.rb index 54b802b2..3530e89a 100644 --- a/app/serializers/user_profile_serializer.rb +++ b/app/serializers/user_profile_serializer.rb @@ -2,9 +2,9 @@ class UserProfileSerializer include JSONAPI::Serializer attributes :name, :email, :id, :bio, :role, :profile_image_url, :organization_id -# attribute :events, if: Proc.new { |user, params| params[:role] == "speaker" || params[:role] == "teacher" } do |user| -# user.events ? user.events.map { |event| EventSerializer.new(event).serializable_hash } : [] -# end + # attribute :events, if: Proc.new { |user, params| params[:role] == "speaker" || params[:role] == "teacher" } do |user| + # user.events ? user.events.map { |event| EventSerializer.new(event).serializable_hash } : [] + # end attribute :orders do |user| if user.orders @@ -42,29 +42,29 @@ class UserProfileSerializer else {} end -# attribute :availabilities, if: Proc.new { |user, params| params[:role] == "speaker" || params[:role] == "teacher" } do |user| -# user.availabilities ? user.availabilities.map { |availability| AvailabilitySerializer.new(availability).serializable_hash } : [] -# end + # attribute :availabilities, if: Proc.new { |user, params| params[:role] == "speaker" || params[:role] == "teacher" } do |user| + # user.availabilities ? user.availabilities.map { |availability| AvailabilitySerializer.new(availability).serializable_hash } : [] + # end -# attribute :pending_bookings, if: Proc.new { |user, params| params[:role] == "speaker" } do |user| -# user.pending_bookings ? user.pending_bookings.map { |booking| BookingSerializer.new(booking).serializable_hash } : [] -# end + # attribute :pending_bookings, if: Proc.new { |user, params| params[:role] == "speaker" } do |user| + # user.pending_bookings ? user.pending_bookings.map { |booking| BookingSerializer.new(booking).serializable_hash } : [] + # end -# attribute :confirmed_bookings, if: Proc.new { |user, params| params[:role] == "speaker" } do |user| -# user.confirmed_bookings ? user.confirmed_bookings.map { |booking| BookingSerializer.new(booking).serializable_hash } : [] -# end + # attribute :confirmed_bookings, if: Proc.new { |user, params| params[:role] == "speaker" } do |user| + # user.confirmed_bookings ? user.confirmed_bookings.map { |booking| BookingSerializer.new(booking).serializable_hash } : [] + # end -# attribute :bookings, if: Proc.new { |user, params| params[:role] == "teacher" } do |user| -# user.bookings ? user.bookings.map { |booking| BookingSerializer.new(booking).serializable_hash } : [] + # attribute :bookings, if: Proc.new { |user, params| params[:role] == "teacher" } do |user| + # user.bookings ? user.bookings.map { |booking| BookingSerializer.new(booking).serializable_hash } : [] end attribute :donations do |user| user.donations ? user.donations.map { |donation| DonationSerializer.new(donation).serializable_hash } : [] end -# attribute :orders, if: Proc.new { |user, params| params[:role] == "teacher" } do |user| -# user.orders ? user.orders.map { |order| OrderSerializer.new(order).serializable_hash } : [] -# end + # attribute :orders, if: Proc.new { |user, params| params[:role] == "teacher" } do |user| + # user.orders ? user.orders.map { |order| OrderSerializer.new(order).serializable_hash } : [] + # end def profile_image_url if @resource.profile_image.attached?