1.設定 不可預約 的資料只有登入的會員才能查看(查詢目前已預約狀況)。

2.設定 不可預約 的資料只有管理者帳號才能預約租借(線上預約)。

3.可以設定未登入的使用者無法查看查詢目前已預約狀況
This commit is contained in:
邱博亞 2023-10-18 21:56:19 +08:00
parent 864358bd69
commit 6ad48313ed
6 changed files with 28 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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?

View File

@ -65,6 +65,12 @@
<%= f.check_box :disable_view_calendar_page %>
</div>
</div>
<div class="control-group">
<%= f.label :disable_no_logins_view_calendar, t("property_hire.disable_no_logins_view_calendar"), :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :disable_no_logins_view_calendar %>
</div>
</div>
<div class="control-group">
<%= f.label :carousel_image_width, t("property_hire.default_carousel_image_width"), :class => "control-label muted" %>
<div class="controls">

View File

@ -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)

View File

@ -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頁面底部顯示)