can [:index, :new, :create, :show, :edit, :update, :destroy], :oauth2_application
can [:index, :destroy], :oauth2_authorized_application
can [:new, :show, :create, :destroy], :oauth2_authorization
+ can [:show], :dashboard
can [:new, :create, :edit, :update, :comment, :subscribe, :unsubscribe], DiaryEntry
can [:make_friend, :remove_friend], Friendship
can [:new, :create, :reply, :show, :inbox, :outbox, :mark, :destroy], Message
margin-bottom: 0;
}
-.users-show {
- // Silly exception; remove when user page is redesigned.
- .content-inner {
- max-width: none;
- }
+.dashboards-show {
p#no_home_location {
margin: $lineheight;
}
--- /dev/null
+class DashboardsController < ApplicationController
+ layout "site"
+
+ before_action :authorize_web
+ before_action :set_locale
+
+ authorize_resource :class => false
+
+ before_action :check_database_readable
+
+ def show
+ @user = current_user
+ end
+end
<% if @user.home_lon and @user.home_lat and contact.home_lon and contact.home_lat %>
<% distance = @user.distance(contact) %>
<% if distance < 1 %>
- (<%= t "users.show.m away", :count => (distance * 1000).round %>)
+ (<%= t ".m away", :count => (distance * 1000).round %>)
<% else %>
- (<%= t "users.show.km away", :count => distance.round %>)
+ (<%= t ".km away", :count => distance.round %>)
<% end %>
<% end %>
</p>
--- /dev/null
+<% content_for :heading do %>
+ <h1><%= t ".title" %></h1>
+<% end %>
+
+<div class="row">
+ <% if current_user and @user.id == current_user.id %>
+ <div class="col-md order-md-last">
+ <% if @user.home_lat.nil? or @user.home_lon.nil? %>
+ <div id="map" class="content_map">
+ <p id="no_home_location"><%= 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", :data => { :user => user_data } %>
+ <% end %>
+
+ <% friends = @user.friends %>
+ <% nearby = @user.nearby - friends %>
+ </div>
+
+ <div class="col-md">
+ <h3><%= t ".my friends" %></h3>
+
+ <% if friends.empty? %>
+ <%= t ".no friends" %>
+ <% else %>
+ <ul class='secondary-actions clearfix'>
+ <li><%= link_to t(".friends_changesets"), friend_changesets_path %></li>
+ <li><%= link_to t(".friends_diaries"), friends_diary_entries_path %></li>
+ </ul>
+ <div id="friends-container">
+ <%= render :partial => "contact", :collection => friends, :locals => { :type => "friend" } %>
+ </div>
+ <% end %>
+
+ <hr>
+
+ <h3><%= t ".nearby users" %></h3>
+
+ <% if nearby.empty? %>
+ <%= t ".no nearby users" %>
+ <% else %>
+ <ul class='secondary-actions clearfix'>
+ <li><%= link_to t(".nearby_changesets"), nearby_changesets_path %></li>
+ <li><%= link_to t(".nearby_diaries"), nearby_diary_entries_path %></li>
+ </ul>
+ <div id="nearbyusers">
+ <%= render :partial => "contact", :collection => nearby, :locals => { :type => "nearby mapper" } %>
+ </div>
+ <% end %>
+ </div>
+ <% end %>
+</div>
</span>
</a>
<div class='dropdown-menu dropdown-menu-right'>
+ <%= link_to t("users.show.my_dashboard"), dashboard_path, :class => "dropdown-item" %>
<%= link_to inbox_messages_path, :class => "dropdown-item" do %>
<%= t("users.show.my messages") %>
<span class='count-number'><%= number_with_delimiter(current_user.new_messages.size) %></span>
<% end -%>
<% end %>
-
-<div class="row">
- <% if current_user and @user.id == current_user.id %>
- <div class="col-md order-md-last">
- <% if @user.home_lat.nil? or @user.home_lon.nil? %>
- <div id="map" class="content_map">
- <p id="no_home_location"><%= 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", :data => { :user => user_data } %>
- <% end %>
-
- <% friends = @user.friends %>
- <% nearby = @user.nearby - friends %>
- </div>
-
- <div class="col-md">
- <h3><%= t ".my friends" %></h3>
-
- <% if friends.empty? %>
- <%= t ".no friends" %>
- <% else %>
- <ul class='secondary-actions clearfix'>
- <li><%= link_to t(".friends_changesets"), friend_changesets_path %></li>
- <li><%= link_to t(".friends_diaries"), friends_diary_entries_path %></li>
- </ul>
- <div id="friends-container">
- <%= render :partial => "contact", :collection => friends, :locals => { :type => "friend" } %>
- </div>
- <% end %>
-
- <hr>
-
- <h3><%= t ".nearby users" %></h3>
-
- <% if nearby.empty? %>
- <%= t ".no nearby users" %>
- <% else %>
- <ul class='secondary-actions clearfix'>
- <li><%= link_to t(".nearby_changesets"), nearby_changesets_path %></li>
- <li><%= link_to t(".nearby_diaries"), nearby_diary_entries_path %></li>
- </ul>
- <div id="nearbyusers">
- <%= render :partial => "contact", :collection => nearby, :locals => { :type => "nearby mapper" } %>
- </div>
- <% end %>
- </div>
- <% end %>
-</div>
title_particular: "OpenStreetMap changeset #%{changeset_id} discussion"
timeout:
sorry: "Sorry, the list of changeset comments you requested took too long to retrieve."
+ dashboards:
+ contact:
+ km away: "%{count}km away"
+ m away: "%{count}m away"
+ popup:
+ your location: "Your location"
+ nearby mapper: "Nearby mapper"
+ friend: "Friend"
+ show:
+ title: My Dashboard
+ no_home_location_html: "%{edit_profile_link} and set your home location to see nearby users."
+ edit_your_profile: Edit your profile
+ my friends: My friends
+ no friends: You have not added any friends yet.
+ nearby users: "Other nearby users"
+ no nearby users: "There are no other users who admit to mapping nearby yet."
+ friends_changesets: "friends' changesets"
+ friends_diaries: "friends' diary entries"
+ nearby_changesets: "nearby user changesets"
+ nearby_diaries: "nearby user diary entries"
diary_entries:
new:
title: New Diary Entry
my settings: My Settings
my comments: My Comments
my_preferences: My Preferences
+ my_dashboard: My Dashboard
blocks on me: Blocks on Me
blocks by me: Blocks by Me
edit_profile: Edit Profile
spam score: "Spam Score:"
description: Description
user location: User location
- no_home_location_html: "%{edit_profile_link} and set your home location to see nearby users."
- edit_your_profile: Edit your profile
- my friends: My friends
- no friends: You have not added any friends yet.
- km away: "%{count}km away"
- m away: "%{count}m away"
- nearby users: "Other nearby users"
- no nearby users: "There are no other users who admit to mapping nearby yet."
role:
administrator: "This user is an administrator"
moderator: "This user is a moderator"
unhide_user: "Unhide this User"
delete_user: "Delete this User"
confirm: "Confirm"
- friends_changesets: "friends' changesets"
- friends_diaries: "friends' diary entries"
- nearby_changesets: "nearby user changesets"
- nearby_diaries: "nearby user diary entries"
report: Report this User
- popup:
- your location: "Your location"
- nearby mapper: "Nearby mapper"
- friend: "Friend"
account:
title: "Edit account"
my settings: My Settings
match "/user/:display_name/account" => "users#account", :via => [:get, :post], :as => "user_account"
post "/user/:display_name/set_status" => "users#set_status", :as => :set_status_user
+ resource :dashboard, :only => [:show]
resource :preferences, :only => [:show, :edit, :update]
resource :profile, :only => [:edit, :update]
--- /dev/null
+require "test_helper"
+
+class DashboardsControllerTest < ActionDispatch::IntegrationTest
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/dashboard", :method => :get },
+ { :controller => "dashboards", :action => "show" }
+ )
+ end
+
+ def test_show_no_friends
+ user = create(:user)
+ session_for(user)
+
+ get dashboard_path
+ end
+
+ def test_show_with_friends
+ user = create(:user, :home_lon => 1.1, :home_lat => 1.1)
+ friend_user = create(:user, :home_lon => 1.2, :home_lat => 1.2)
+ create(:friendship, :befriender => user, :befriendee => friend_user)
+ create(:changeset, :user => friend_user)
+ session_for(user)
+
+ get dashboard_path
+
+ # Friends should be visible as we're now logged in
+ assert_select "div#friends-container" do
+ assert_select "div.contact-activity", :count => 1
+ end
+ end
+end
assert_response :not_found
# Test a normal user
- user = create(:user, :home_lon => 1.1, :home_lat => 1.1)
- friend_user = create(:user, :home_lon => 1.2, :home_lat => 1.2)
- create(:friendship, :befriender => user, :befriendee => friend_user)
- create(:changeset, :user => friend_user)
+ user = create(:user)
get user_path(user)
assert_response :success
assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0
end
- # Friends should be visible as we're now logged in
- assert_select "div#friends-container" do
- assert_select "div.contact-activity", :count => 1
- end
-
# Login as a moderator
session_for(create(:moderator_user))