Remove current user check from dashboard view

This commit is contained in:
Anton Khorev 2025-02-19 03:59:38 +03:00
parent 02d9467939
commit 50bf0a6379
4 changed files with 56 additions and 53 deletions

View file

@ -9,7 +9,6 @@ class DashboardsController < ApplicationController
before_action :check_database_readable
def show
@user = current_user
@followings = current_user.followings
@nearby_users = current_user.nearby - @followings
end

View file

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

View file

@ -3,60 +3,58 @@
<% end %>
<div class="row">
<% if current_user and @user.id == current_user.id %>
<div class="col-md order-md-last">
<% if !@user.home_location? %>
<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>
</div>
<% else %>
<% content_for :head do %>
<%= 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 } %>
<div class="col-md order-md-last">
<% if !current_user.home_location? %>
<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>
</div>
<% else %>
<% content_for :head do %>
<%= javascript_include_tag "user" %>
<% 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">
<h2><%= t ".followings" %></h2>
<div class="col-md">
<h2><%= t ".followings" %></h2>
<% if @followings.empty? %>
<%= t ".no followings" %>
<% else %>
<nav class='secondary-actions mb-3'>
<ul class='clearfix'>
<li><%= link_to t(".followed_changesets"), friend_changesets_path %></li>
<li><%= link_to t(".followed_diaries"), friends_diary_entries_path %></li>
</ul>
</nav>
<div>
<%= render :partial => "contact", :collection => @followings, :locals => { :type => "following" } %>
</div>
<% end %>
<% if @followings.empty? %>
<%= t ".no followings" %>
<% else %>
<nav class='secondary-actions mb-3'>
<ul class='clearfix'>
<li><%= link_to t(".followed_changesets"), friend_changesets_path %></li>
<li><%= link_to t(".followed_diaries"), friends_diary_entries_path %></li>
</ul>
</nav>
<div>
<%= render :partial => "contact", :collection => @followings, :locals => { :type => "following" } %>
</div>
<% end %>
<hr>
<hr>
<h2><%= t ".nearby users" %></h2>
<h2><%= t ".nearby users" %></h2>
<% if @nearby_users.empty? %>
<%= t ".no nearby users" %>
<% else %>
<nav class='secondary-actions mb-3'>
<ul class='clearfix'>
<li><%= link_to t(".nearby_changesets"), nearby_changesets_path %></li>
<li><%= link_to t(".nearby_diaries"), nearby_diary_entries_path %></li>
</ul>
</nav>
<div id="nearbyusers">
<%= render :partial => "contact", :collection => @nearby_users, :locals => { :type => "nearby mapper" } %>
</div>
<% end %>
</div>
<% end %>
<% if @nearby_users.empty? %>
<%= t ".no nearby users" %>
<% else %>
<nav class='secondary-actions mb-3'>
<ul class='clearfix'>
<li><%= link_to t(".nearby_changesets"), nearby_changesets_path %></li>
<li><%= link_to t(".nearby_diaries"), nearby_diary_entries_path %></li>
</ul>
</nav>
<div id="nearbyusers">
<%= render :partial => "contact", :collection => @nearby_users, :locals => { :type => "nearby mapper" } %>
</div>
<% end %>
</div>
</div>

View file

@ -9,4 +9,10 @@ class DashboardsControllerTest < ActionDispatch::IntegrationTest
{ :controller => "dashboards", :action => "show" }
)
end
def test_show_unauthorized
get dashboard_path
assert_redirected_to login_path(:referer => dashboard_path)
end
end