From: Anton Khorev Date: Wed, 19 Feb 2025 00:59:38 +0000 (+0300) Subject: Remove current user check from dashboard view X-Git-Tag: live~88^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/50bf0a6379ed8ffb31719a29d63d17f8e72fc07b?hp=--cc Remove current user check from dashboard view --- 50bf0a6379ed8ffb31719a29d63d17f8e72fc07b diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb index 54dba26d3..cb73cc38f 100644 --- a/app/controllers/dashboards_controller.rb +++ b/app/controllers/dashboards_controller.rb @@ -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 diff --git a/app/views/dashboards/_contact.html.erb b/app/views/dashboards/_contact.html.erb index 8e78524de..021f1a335 100644 --- a/app/views/dashboards/_contact.html.erb +++ b/app/views/dashboards/_contact.html.erb @@ -11,8 +11,8 @@

<%= 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 %> diff --git a/app/views/dashboards/show.html.erb b/app/views/dashboards/show.html.erb index a198f534d..e110ad531 100644 --- a/app/views/dashboards/show.html.erb +++ b/app/views/dashboards/show.html.erb @@ -3,60 +3,58 @@ <% end %>

- <% if current_user and @user.id == current_user.id %> -
- <% if !@user.home_location? %> -
-

<%= t(".no_home_location_html", :edit_profile_link => link_to(t(".edit_your_profile"), edit_profile_path)) %>

-
- <% 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 } %> +
+ <% if !current_user.home_location? %> +
+

<%= t(".no_home_location_html", :edit_profile_link => link_to(t(".edit_your_profile"), edit_profile_path)) %>

+
+ <% 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 } %> + <% end %> +
-
-

<%= t ".followings" %>

+
+

<%= t ".followings" %>

- <% if @followings.empty? %> - <%= t ".no followings" %> - <% else %> - -
- <%= render :partial => "contact", :collection => @followings, :locals => { :type => "following" } %> -
- <% end %> + <% if @followings.empty? %> + <%= t ".no followings" %> + <% else %> + +
+ <%= render :partial => "contact", :collection => @followings, :locals => { :type => "following" } %> +
+ <% end %> -
+
-

<%= t ".nearby users" %>

+

<%= t ".nearby users" %>

- <% if @nearby_users.empty? %> - <%= t ".no nearby users" %> - <% else %> - -
- <%= render :partial => "contact", :collection => @nearby_users, :locals => { :type => "nearby mapper" } %> -
- <% end %> -
- <% end %> + <% if @nearby_users.empty? %> + <%= t ".no nearby users" %> + <% else %> + +
+ <%= render :partial => "contact", :collection => @nearby_users, :locals => { :type => "nearby mapper" } %> +
+ <% end %> +
diff --git a/test/controllers/dashboards_controller_test.rb b/test/controllers/dashboards_controller_test.rb index 0adf58a9e..c55636585 100644 --- a/test/controllers/dashboards_controller_test.rb +++ b/test/controllers/dashboards_controller_test.rb @@ -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