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