Fix predicate method names in the user model

This commit is contained in:
Tom Hughes 2023-08-15 18:53:14 +01:00
parent 65d092a579
commit 6982903ae7
14 changed files with 27 additions and 37 deletions

View file

@ -46,7 +46,7 @@ json.user do
end
if current_user && current_user == user && can?(:details, User)
if user.has_home?
if user.home_location?
json.home do
json.lat user.home_lat
json.lon user.home_lon

View file

@ -25,7 +25,7 @@ xml.tag! "user", :id => user.id,
end
end
if current_user && current_user == user && can?(:details, User)
if user.has_home?
if user.home_location?
xml.tag! "home", :lat => user.home_lat,
:lon => user.home_lon,
:zoom => user.home_zoom

View file

@ -11,7 +11,7 @@
<div class="col">
<p class='text-muted mb-0'>
<%= link_to contact.display_name, user_path(contact) %>
<% if @user.has_home? and contact.has_home? %>
<% if @user.home_location? and contact.home_location? %>
<% distance = @user.distance(contact) %>
<% if distance < 1 %>
(<%= t ".m away", :count => (distance * 1000).round %>)

View file

@ -5,7 +5,7 @@
<div class="row">
<% if current_user and @user.id == current_user.id %>
<div class="col-md order-md-last">
<% if !@user.has_home? %>
<% if !@user.home_location? %>
<div id="map" class="content_map border border-grey">
<p class="m-3"><%= t(".no_home_location_html", :edit_profile_link => link_to(t(".edit_your_profile"), edit_profile_path)) %></p>
</div>

View file

@ -4,7 +4,7 @@
<% content_for(:body_class) { "map-layout" } %>
<% if current_user&.has_home? %>
<% if current_user&.home_location? %>
<% content_for :greeting do %>
<%= link_to t("layouts.home"),
"#",

View file

@ -42,18 +42,18 @@
<fieldset>
<legend><%= t ".home location" -%></legend>
<p id="home_message" class="text-muted m-0<% if current_user.has_home? %> invisible<% end %>"><%= t ".no home location" %></p>
<p id="home_message" class="text-muted m-0<% if current_user.home_location? %> invisible<% end %>"><%= t ".no home location" %></p>
<div class="row">
<%= f.text_field :home_lat, :wrapper_class => "col-sm-4", :id => "home_lat" %>
<%= f.text_field :home_lon, :wrapper_class => "col-sm-4", :id => "home_lon" %>
<div class="col-sm-4 pt-2 align-self-end">
<button type="button" id="home_show" class="btn btn-outline-primary"<% unless current_user.has_home? %> hidden<% end %> disabled><%= t ".show" %></button>
<button type="button" id="home_delete" class="btn btn-outline-primary"<% unless current_user.has_home? %> hidden<% end %>><%= t ".delete" %></button>
<button type="button" id="home_show" class="btn btn-outline-primary"<% unless current_user.home_location? %> hidden<% end %> disabled><%= t ".show" %></button>
<button type="button" id="home_delete" class="btn btn-outline-primary"<% unless current_user.home_location? %> hidden<% end %>><%= t ".delete" %></button>
<button type="button" id="home_undelete" class="btn btn-outline-primary" hidden><%= t ".undelete" %></button>
</div>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="updatehome" value="1" <% unless current_user.has_home? %> checked <% end %> id="updatehome" />
<input class="form-check-input" type="checkbox" name="updatehome" value="1" <% unless current_user.home_location? %> checked <% end %> id="updatehome" />
<label class="form-check-label" for="updatehome"><%= t ".update home location on click" %></label>
</div>
<%= tag.div "", :id => "map", :class => "content_map set_location border border-grey rounded" %>