Remove current user check from dashboard view
This commit is contained in:
parent
02d9467939
commit
50bf0a6379
4 changed files with 56 additions and 53 deletions
|
@ -9,7 +9,6 @@ class DashboardsController < ApplicationController
|
||||||
before_action :check_database_readable
|
before_action :check_database_readable
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@user = current_user
|
|
||||||
@followings = current_user.followings
|
@followings = current_user.followings
|
||||||
@nearby_users = current_user.nearby - @followings
|
@nearby_users = current_user.nearby - @followings
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<p class='text-body-secondary mb-0'>
|
<p class='text-body-secondary mb-0'>
|
||||||
<%= link_to contact.display_name, contact %>
|
<%= link_to contact.display_name, contact %>
|
||||||
<% if @user.home_location? and contact.home_location? %>
|
<% if current_user.home_location? and contact.home_location? %>
|
||||||
<% distance = @user.distance(contact) %>
|
<% distance = current_user.distance(contact) %>
|
||||||
<% if distance < 1 %>
|
<% if distance < 1 %>
|
||||||
(<%= t ".m away", :count => (distance * 1000).round %>)
|
(<%= t ".m away", :count => (distance * 1000).round %>)
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|
|
@ -3,60 +3,58 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<% if current_user and @user.id == current_user.id %>
|
<div class="col-md order-md-last">
|
||||||
<div class="col-md order-md-last">
|
<% if !current_user.home_location? %>
|
||||||
<% if !@user.home_location? %>
|
<div id="map" class="content_map border border-secondary-subtle">
|
||||||
<div id="map" class="content_map border border-secondary-subtle">
|
<p class="m-3"><%= t(".no_home_location_html", :edit_profile_link => link_to(t(".edit_your_profile"), edit_profile_path)) %></p>
|
||||||
<p class="m-3"><%= t(".no_home_location_html", :edit_profile_link => link_to(t(".edit_your_profile"), edit_profile_path)) %></p>
|
</div>
|
||||||
</div>
|
<% else %>
|
||||||
<% else %>
|
<% content_for :head do %>
|
||||||
<% content_for :head do %>
|
<%= javascript_include_tag "user" %>
|
||||||
<%= javascript_include_tag "user" %>
|
|
||||||
<% end %>
|
|
||||||
<% user_data = {
|
|
||||||
:lon => current_user.home_lon,
|
|
||||||
:lat => current_user.home_lat,
|
|
||||||
:icon => image_path("marker-red.png"),
|
|
||||||
:description => render(:partial => "popup", :object => current_user, :locals => { :type => "your location" })
|
|
||||||
} %>
|
|
||||||
<%= tag.div "", :id => "map", :class => "content_map border border-secondary-subtle rounded z-0", :data => { :user => user_data } %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
<% user_data = {
|
||||||
|
:lon => current_user.home_lon,
|
||||||
|
:lat => current_user.home_lat,
|
||||||
|
:icon => image_path("marker-red.png"),
|
||||||
|
:description => render(:partial => "popup", :object => current_user, :locals => { :type => "your location" })
|
||||||
|
} %>
|
||||||
|
<%= tag.div "", :id => "map", :class => "content_map border border-secondary-subtle rounded z-0", :data => { :user => user_data } %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
<h2><%= t ".followings" %></h2>
|
<h2><%= t ".followings" %></h2>
|
||||||
|
|
||||||
<% if @followings.empty? %>
|
<% if @followings.empty? %>
|
||||||
<%= t ".no followings" %>
|
<%= t ".no followings" %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<nav class='secondary-actions mb-3'>
|
<nav class='secondary-actions mb-3'>
|
||||||
<ul class='clearfix'>
|
<ul class='clearfix'>
|
||||||
<li><%= link_to t(".followed_changesets"), friend_changesets_path %></li>
|
<li><%= link_to t(".followed_changesets"), friend_changesets_path %></li>
|
||||||
<li><%= link_to t(".followed_diaries"), friends_diary_entries_path %></li>
|
<li><%= link_to t(".followed_diaries"), friends_diary_entries_path %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<div>
|
<div>
|
||||||
<%= render :partial => "contact", :collection => @followings, :locals => { :type => "following" } %>
|
<%= render :partial => "contact", :collection => @followings, :locals => { :type => "following" } %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<h2><%= t ".nearby users" %></h2>
|
<h2><%= t ".nearby users" %></h2>
|
||||||
|
|
||||||
<% if @nearby_users.empty? %>
|
<% if @nearby_users.empty? %>
|
||||||
<%= t ".no nearby users" %>
|
<%= t ".no nearby users" %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<nav class='secondary-actions mb-3'>
|
<nav class='secondary-actions mb-3'>
|
||||||
<ul class='clearfix'>
|
<ul class='clearfix'>
|
||||||
<li><%= link_to t(".nearby_changesets"), nearby_changesets_path %></li>
|
<li><%= link_to t(".nearby_changesets"), nearby_changesets_path %></li>
|
||||||
<li><%= link_to t(".nearby_diaries"), nearby_diary_entries_path %></li>
|
<li><%= link_to t(".nearby_diaries"), nearby_diary_entries_path %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<div id="nearbyusers">
|
<div id="nearbyusers">
|
||||||
<%= render :partial => "contact", :collection => @nearby_users, :locals => { :type => "nearby mapper" } %>
|
<%= render :partial => "contact", :collection => @nearby_users, :locals => { :type => "nearby mapper" } %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,4 +9,10 @@ class DashboardsControllerTest < ActionDispatch::IntegrationTest
|
||||||
{ :controller => "dashboards", :action => "show" }
|
{ :controller => "dashboards", :action => "show" }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_show_unauthorized
|
||||||
|
get dashboard_path
|
||||||
|
|
||||||
|
assert_redirected_to login_path(:referer => dashboard_path)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue