diff --git a/app/controllers/property_hires_controller.rb b/app/controllers/property_hires_controller.rb index 55ac37b..9cb013d 100644 --- a/app/controllers/property_hires_controller.rb +++ b/app/controllers/property_hires_controller.rb @@ -30,6 +30,7 @@ class PropertyHiresController < ApplicationController data = properties.collect do |property| actions = [] url_to_show = "#{url}/#{property.to_param}" + hire_url = nil if property.can_be_hired_frontend hire_url = url_to_show + "?method=hire" actions << { @@ -38,7 +39,7 @@ class PropertyHiresController < ApplicationController "link" => hire_url } end - unless property.disable_view_calendar_page + if !property.disable_view_calendar_page && property.can_be_show_frontend actions << { "text" => t("property_hire.view_calendar"), "btn-class" => "btn-info", @@ -48,7 +49,7 @@ class PropertyHiresController < ApplicationController if property.disable_content_page if hire_url url_to_show = hire_url - elsif !property.disable_view_calendar_page + elsif !property.disable_view_calendar_page && property.can_be_show_frontend url_to_show += "?method=view_calendar" end end @@ -168,7 +169,7 @@ class PropertyHiresController < ApplicationController "link" => url_to_show + "?method=hire" } end - unless property.disable_view_calendar_page + if !property.disable_view_calendar_page && property.can_be_show_frontend actions << { "text" => t("property_hire.view_calendar"), "btn-class" => "btn-info", @@ -190,6 +191,9 @@ class PropertyHiresController < ApplicationController def view_calendar params = OrbitHelper.params property = Property.where(:uid => params[:uid]).first rescue nil + if property.disable_view_calendar_page || !property.can_be_show_frontend + return nil + end page = Page.where(:page_id => params[:page_id]).first return {} if property.nil? { @@ -297,6 +301,9 @@ class PropertyHiresController < ApplicationController def hire params = OrbitHelper.params property = Property.where(:uid => params[:uid]).first rescue nil + if !property.can_be_hired_frontend + return nil + end page = Page.where(:page_id => params[:page_id]).first return {} if property.nil? hire = nil diff --git a/app/models/property.rb b/app/models/property.rb index edb2839..07611e1 100644 --- a/app/models/property.rb +++ b/app/models/property.rb @@ -158,9 +158,11 @@ class Property if setting @@disable_content_page = setting.disable_content_page rescue false @@disable_view_calendar_page = setting.disable_view_calendar_page rescue false + @@disable_no_logins_view_calendar = setting.disable_no_logins_view_calendar rescue false else @@disable_content_page = false @@disable_view_calendar_page = false + @@disable_no_logins_view_calendar = false end end init_class_variables @@ -170,6 +172,9 @@ class Property def disable_view_calendar_page @@disable_view_calendar_page end + def disable_no_logins_view_calendar + @@disable_no_logins_view_calendar + end def custom_text(field_name,type="name",locale=nil) locale = locale || I18n.locale default_text = I18n.with_locale(locale){I18n.t("property_hire.#{field_name}")} @@ -565,4 +570,8 @@ class Property user = OrbitHelper.current_user self.can_be_hired || (user && (user.is_admin? || property.owners.include?(user.member_profile_id))) end + def can_be_show_frontend + user = OrbitHelper.current_user + (!disable_no_logins_view_calendar && self.can_be_hired) || user + end end \ No newline at end of file diff --git a/app/models/property_hire_setting.rb b/app/models/property_hire_setting.rb index 85412c3..246ddfa 100644 --- a/app/models/property_hire_setting.rb +++ b/app/models/property_hire_setting.rb @@ -6,6 +6,7 @@ class PropertyHireSetting field :carousel_image_width, type: String, :default => "75%" field :disable_content_page, type: Boolean, :default => false field :disable_view_calendar_page, type: Boolean, :default => false + field :disable_no_logins_view_calendar, type: Boolean, :default => false field :allow_no_logins_user, type: Boolean, :default => false field :calendar_type, type: Integer, default: 0 # 0=> 顯示, 1=> 不顯示 def self.auto_approve_enabled? diff --git a/app/views/admin/property_hires/settings.html.erb b/app/views/admin/property_hires/settings.html.erb index 779b38f..578770a 100644 --- a/app/views/admin/property_hires/settings.html.erb +++ b/app/views/admin/property_hires/settings.html.erb @@ -65,6 +65,12 @@ <%= f.check_box :disable_view_calendar_page %> +
+ <%= f.label :disable_no_logins_view_calendar, t("property_hire.disable_no_logins_view_calendar"), :class => "control-label muted" %> +
+ <%= f.check_box :disable_no_logins_view_calendar %> +
+
<%= f.label :carousel_image_width, t("property_hire.default_carousel_image_width"), :class => "control-label muted" %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index a007944..f9d3ae0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -44,6 +44,7 @@ en: files_links: "Files, Links" disable_content_page: Disable content page disable_view_calendar_page: 'Disable "Calendar" page' + disable_no_logins_view_calendar: 'Disable Calendar page for no logins user' display_img: Display Cover Image in Content Page carousel_image: Carousel Image carousel_image_title: Carousel Image(display at the bottom of show page) diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index dffc589..24d270a 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -44,6 +44,7 @@ zh_tw: files_links: "檔案與連結" disable_content_page: 關閉內容頁 disable_view_calendar_page: '關閉"查詢目前預約狀況"頁面' + disable_no_logins_view_calendar: '關閉未登入使用者"查詢目前預約狀況"頁面' display_img: 內容頁顯示封面圖片 carousel_image: 輪播圖片 carousel_image_title: 輪播圖片(在show頁面底部顯示)