Skip to content

Commit 0ae489e

Browse files
committed
Merge remote-tracking branch 'upstream/pull/5705'
2 parents 8463533 + 50bf0a6 commit 0ae489e

File tree

4 files changed

+58
-56
lines changed

4 files changed

+58
-56
lines changed

app/controllers/dashboards_controller.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class DashboardsController < ApplicationController
99
before_action :check_database_readable
1010

1111
def show
12-
@user = current_user
12+
@followings = current_user.followings
13+
@nearby_users = current_user.nearby - @followings
1314
end
1415
end

app/views/dashboards/_contact.html.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<div class="col">
1212
<p class='text-body-secondary mb-0'>
1313
<%= link_to contact.display_name, contact %>
14-
<% if @user.home_location? and contact.home_location? %>
15-
<% distance = @user.distance(contact) %>
14+
<% if current_user.home_location? and contact.home_location? %>
15+
<% distance = current_user.distance(contact) %>
1616
<% if distance < 1 %>
1717
(<%= t ".m away", :count => (distance * 1000).round %>)
1818
<% else %>

app/views/dashboards/show.html.erb

+48-53
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,58 @@
33
<% end %>
44

55
<div class="row">
6-
<% if current_user and @user.id == current_user.id %>
7-
<div class="col-md order-md-last">
8-
<% if !@user.home_location? %>
9-
<div id="map" class="content_map border border-secondary-subtle">
10-
<p class="m-3"><%= t(".no_home_location_html", :edit_profile_link => link_to(t(".edit_your_profile"), edit_profile_path)) %></p>
11-
</div>
12-
<% else %>
13-
<% content_for :head do %>
14-
<%= javascript_include_tag "user" %>
15-
<% end %>
16-
<% user_data = {
17-
:lon => current_user.home_lon,
18-
:lat => current_user.home_lat,
19-
:icon => image_path("marker-red.png"),
20-
:description => render(:partial => "popup", :object => current_user, :locals => { :type => "your location" })
21-
} %>
22-
<%= tag.div "", :id => "map", :class => "content_map border border-secondary-subtle rounded z-0", :data => { :user => user_data } %>
6+
<div class="col-md order-md-last">
7+
<% if !current_user.home_location? %>
8+
<div id="map" class="content_map border border-secondary-subtle">
9+
<p class="m-3"><%= t(".no_home_location_html", :edit_profile_link => link_to(t(".edit_your_profile"), edit_profile_path)) %></p>
10+
</div>
11+
<% else %>
12+
<% content_for :head do %>
13+
<%= javascript_include_tag "user" %>
2314
<% end %>
15+
<% user_data = {
16+
:lon => current_user.home_lon,
17+
:lat => current_user.home_lat,
18+
:icon => image_path("marker-red.png"),
19+
:description => render(:partial => "popup", :object => current_user, :locals => { :type => "your location" })
20+
} %>
21+
<%= tag.div "", :id => "map", :class => "content_map border border-secondary-subtle rounded z-0", :data => { :user => user_data } %>
22+
<% end %>
23+
</div>
2424

25-
<% followings = @user.followings %>
26-
<% nearby = @user.nearby - followings %>
27-
</div>
25+
<div class="col-md">
26+
<h2><%= t ".followings" %></h2>
2827

29-
<div class="col-md">
30-
<h2><%= t ".followings" %></h2>
28+
<% if @followings.empty? %>
29+
<%= t ".no followings" %>
30+
<% else %>
31+
<nav class='secondary-actions mb-3'>
32+
<ul class='clearfix'>
33+
<li><%= link_to t(".followed_changesets"), friend_changesets_path %></li>
34+
<li><%= link_to t(".followed_diaries"), friends_diary_entries_path %></li>
35+
</ul>
36+
</nav>
37+
<div>
38+
<%= render :partial => "contact", :collection => @followings, :locals => { :type => "following" } %>
39+
</div>
40+
<% end %>
3141

32-
<% if followings.empty? %>
33-
<%= t ".no followings" %>
34-
<% else %>
35-
<nav class='secondary-actions mb-3'>
36-
<ul class='clearfix'>
37-
<li><%= link_to t(".followed_changesets"), friend_changesets_path %></li>
38-
<li><%= link_to t(".followed_diaries"), friends_diary_entries_path %></li>
39-
</ul>
40-
</nav>
41-
<div>
42-
<%= render :partial => "contact", :collection => followings, :locals => { :type => "following" } %>
43-
</div>
44-
<% end %>
45-
46-
<hr>
42+
<hr>
4743

48-
<h2><%= t ".nearby users" %></h2>
44+
<h2><%= t ".nearby users" %></h2>
4945

50-
<% if nearby.empty? %>
51-
<%= t ".no nearby users" %>
52-
<% else %>
53-
<nav class='secondary-actions mb-3'>
54-
<ul class='clearfix'>
55-
<li><%= link_to t(".nearby_changesets"), nearby_changesets_path %></li>
56-
<li><%= link_to t(".nearby_diaries"), nearby_diary_entries_path %></li>
57-
</ul>
58-
</nav>
59-
<div id="nearbyusers">
60-
<%= render :partial => "contact", :collection => nearby, :locals => { :type => "nearby mapper" } %>
61-
</div>
62-
<% end %>
63-
</div>
64-
<% end %>
46+
<% if @nearby_users.empty? %>
47+
<%= t ".no nearby users" %>
48+
<% else %>
49+
<nav class='secondary-actions mb-3'>
50+
<ul class='clearfix'>
51+
<li><%= link_to t(".nearby_changesets"), nearby_changesets_path %></li>
52+
<li><%= link_to t(".nearby_diaries"), nearby_diary_entries_path %></li>
53+
</ul>
54+
</nav>
55+
<div id="nearbyusers">
56+
<%= render :partial => "contact", :collection => @nearby_users, :locals => { :type => "nearby mapper" } %>
57+
</div>
58+
<% end %>
59+
</div>
6560
</div>

test/controllers/dashboards_controller_test.rb

+6
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@ def test_routes
99
{ :controller => "dashboards", :action => "show" }
1010
)
1111
end
12+
13+
def test_show_unauthorized
14+
get dashboard_path
15+
16+
assert_redirected_to login_path(:referer => dashboard_path)
17+
end
1218
end

0 commit comments

Comments
 (0)