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