From 864358bd699c3e1e385adfc75f5b028eedd01d6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Sat, 26 Aug 2023 11:16:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B2=92=E7=99=BB=E5=85=A5=E4=B9=9F=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E7=9C=8B=E5=88=B0=E6=97=A5=E6=9B=86=EF=BC=8C=E6=B2=92?= =?UTF-8?q?=E6=9C=89=E9=96=8B=E6=94=BE=E9=A0=90=E7=B4=84=E6=99=82=EF=BC=8C?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E8=80=85=E4=BB=8D=E5=8F=AF=E4=BB=A5=E5=9C=A8?= =?UTF-8?q?=E5=89=8D=E8=87=BA=E9=A0=90=E7=B4=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/property_hires_controller.rb | 38 ++++++++++--------- app/models/property.rb | 4 ++ .../admin/property_hires/edit_hire.html.erb | 2 +- app/views/property_hires/hire.html.erb | 2 +- app/views/property_hires/hire_old.html.erb | 2 +- .../property_hires/view_calendar.html.erb | 2 +- 6 files changed, 29 insertions(+), 21 deletions(-) diff --git a/app/controllers/property_hires_controller.rb b/app/controllers/property_hires_controller.rb index 04b40f1..55ac37b 100644 --- a/app/controllers/property_hires_controller.rb +++ b/app/controllers/property_hires_controller.rb @@ -30,22 +30,26 @@ class PropertyHiresController < ApplicationController data = properties.collect do |property| actions = [] url_to_show = "#{url}/#{property.to_param}" - if property.can_be_hired + if property.can_be_hired_frontend hire_url = url_to_show + "?method=hire" actions << { "text" => t("property_hire.hire"), "btn-class" => "btn-primary", "link" => hire_url } - unless property.disable_view_calendar_page - actions << { - "text" => t("property_hire.view_calendar"), - "btn-class" => "btn-info", - "link" => url_to_show + "?method=view_calendar" - } - end - if property.disable_content_page + end + unless property.disable_view_calendar_page + actions << { + "text" => t("property_hire.view_calendar"), + "btn-class" => "btn-info", + "link" => url_to_show + "?method=view_calendar" + } + end + if property.disable_content_page + if hire_url url_to_show = hire_url + elsif !property.disable_view_calendar_page + url_to_show += "?method=view_calendar" end end { @@ -157,19 +161,19 @@ class PropertyHiresController < ApplicationController end actions = [] url_to_show = OrbitHelper.url_to_show(property.to_param) - if property.can_be_hired + if property.can_be_hired_frontend actions << { "text" => t("property_hire.hire"), "btn-class" => "btn-primary", "link" => url_to_show + "?method=hire" } - unless property.disable_view_calendar_page - actions << { - "text" => t("property_hire.view_calendar"), - "btn-class" => "btn-info", - "link" => url_to_show + "?method=view_calendar" - } - end + end + unless property.disable_view_calendar_page + actions << { + "text" => t("property_hire.view_calendar"), + "btn-class" => "btn-info", + "link" => url_to_show + "?method=view_calendar" + } end { "data" => data, diff --git a/app/models/property.rb b/app/models/property.rb index 3cbcc44..edb2839 100644 --- a/app/models/property.rb +++ b/app/models/property.rb @@ -561,4 +561,8 @@ class Property self.enable_fields_sort ? self.custom_field_names : self.default_field_names end end + def can_be_hired_frontend + user = OrbitHelper.current_user + self.can_be_hired || (user && (user.is_admin? || property.owners.include?(user.member_profile_id))) + end end \ No newline at end of file diff --git a/app/views/admin/property_hires/edit_hire.html.erb b/app/views/admin/property_hires/edit_hire.html.erb index 7f251ff..faa1cf5 100644 --- a/app/views/admin/property_hires/edit_hire.html.erb +++ b/app/views/admin/property_hires/edit_hire.html.erb @@ -327,7 +327,7 @@ ul.list-unstyled li { width: 100%; } -<% if !property.can_be_hired %> +<% if !property.can_be_hired_frontend %>