From f2ad2647a5ce77d9778ea3e1b1faad6dd18ee9a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Wed, 2 Oct 2024 09:38:50 +0800 Subject: [PATCH] Fix bug. --- app/controllers/property_hires_controller.rb | 4 ++-- app/models/property.rb | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/property_hires_controller.rb b/app/controllers/property_hires_controller.rb index aa9ddc8..425f978 100644 --- a/app/controllers/property_hires_controller.rb +++ b/app/controllers/property_hires_controller.rb @@ -34,7 +34,7 @@ class PropertyHiresController < ApplicationController def index_data(properties, url) ma = ModuleApp.find_by_key("property_hire") - is_user_manager = (OrbitHelper.current_user.is_admin? || OrbitHelper.current_user.is_manager?(ma) || OrbitHelper.current_user.is_sub_manager?(ma)) + is_user_manager = OrbitHelper.current_user && (OrbitHelper.current_user.is_admin? || OrbitHelper.current_user.is_manager?(ma) || OrbitHelper.current_user.is_sub_manager?(ma)) data = properties.collect do |property| actions = [] url_to_show = "#{url}/#{property.to_param}?method=hire" @@ -334,7 +334,7 @@ class PropertyHiresController < ApplicationController allow_no_logins_user = PropertyHireSetting.first.allow_no_logins_user all_day_settings = property.all_day_settings.map{|d,settings| [d,settings.map{|s| [s.id.to_s,s.title]}]}.to_h ma = ModuleApp.find_by_key("property_hire") - is_user_manager = (OrbitHelper.current_user.is_admin? || OrbitHelper.current_user.is_manager?(ma) || OrbitHelper.current_user.is_sub_manager?(ma)) + is_user_manager = OrbitHelper.current_user && (OrbitHelper.current_user.is_admin? || OrbitHelper.current_user.is_manager?(ma) || OrbitHelper.current_user.is_sub_manager?(ma)) { "hire" => hire, "property" => property, diff --git a/app/models/property.rb b/app/models/property.rb index 2ec2c0c..1a21fcb 100644 --- a/app/models/property.rb +++ b/app/models/property.rb @@ -148,9 +148,10 @@ class Property end def can_reserve - start_time = self.p_hire_start_time || Time.now - end_time = self.p_hire_end_time || Time.now - return Time.now >= start_time && end_time >= Time.now + now = Time.now + start_time = self.p_hire_start_time || now + end_time = self.p_hire_end_time || now + return now >= start_time && end_time >= now end def p_hire_fields_enabled