Fix PropertyHireSetting.

This commit is contained in:
邱博亞 2024-03-14 20:10:33 +08:00
parent 24c8845f28
commit 76cd916a26
3 changed files with 9 additions and 6 deletions

View File

@ -240,7 +240,7 @@ class PropertyHiresController < ApplicationController
index_page = is_admin_page ? "/#{I18n.locale}/admin/property_hires" : "/#{I18n.locale}#{params[:url]}"
end
hire_page = is_admin_page ? request.referer : "#{index_page}?method=hire"
need_validate = (PropertyHireSetting.last.allow_no_logins_user rescue false) && current_user.nil?
need_validate = (PropertyHireSetting.first.allow_no_logins_user rescue false) && current_user.nil?
session.delete(:hire_data)
if need_validate
unless gotcha_valid?
@ -324,7 +324,7 @@ class PropertyHiresController < ApplicationController
else
hire = PHire.new(:id=>nil)
end
allow_no_logins_user = PropertyHireSetting.last.allow_no_logins_user
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
{
"hire" => hire,

View File

@ -151,10 +151,10 @@ class Property
end
end
def calendar_type
(self.custom_calendar_type == 0 ? (PropertyHireSetting.last.calendar_type rescue 0) : (self.custom_calendar_type - 1))
(self.custom_calendar_type == 0 ? (PropertyHireSetting.first.calendar_type rescue 0) : (self.custom_calendar_type - 1))
end
def self.init_class_variables
setting = PropertyHireSetting.last
setting = PropertyHireSetting.first
if setting
@@disable_content_page = setting.disable_content_page rescue false
@@disable_view_calendar_page = setting.disable_view_calendar_page rescue false
@ -530,7 +530,7 @@ class Property
times
end
def carousel_image_width
(self.custom_carousel_image_width.blank? ? PropertyHireSetting.last.carousel_image_width : self.custom_carousel_image_width) rescue "75%"
(self.custom_carousel_image_width.blank? ? PropertyHireSetting.first.carousel_image_width : self.custom_carousel_image_width) rescue "75%"
end
def get_attribute_value(attribute_field, signup_id)
SeminarSignupValue.find_by(seminar_signup_field_id: attribute_field.id, seminar_signup_id: signup_id)

View File

@ -13,8 +13,11 @@ module PropertyHire
data_count 1..30
require File.expand_path('../../../app/models/property_hire_setting', __FILE__)
if defined?(PropertyHireSetting)
if PropertyHireSetting.count == 0
settings_count = PropertyHireSetting.count
if settings_count == 0
PropertyHireSetting.create
elsif settings_count > 1
PropertyHireSetting.all[1..-1].each{|s| s.destroy}
end
end