Split the non-public information off of the profile page
This opens up many possibilities for more interesting things to be shown on the dashboard, as well as making it easier to find if you have lots of content in your profile.
This commit is contained in:
parent
7d46f5db60
commit
cb7b79a58f
12 changed files with 137 additions and 90 deletions
|
@ -42,6 +42,7 @@ class Ability
|
|||
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
|
||||
|
|
|
@ -1123,11 +1123,7 @@ tr.turn:hover {
|
|||
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;
|
||||
}
|
||||
|
|
14
app/controllers/dashboards_controller.rb
Normal file
14
app/controllers/dashboards_controller.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
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
|
|
@ -12,9 +12,9 @@
|
|||
<% 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>
|
61
app/views/dashboards/show.html.erb
Normal file
61
app/views/dashboards/show.html.erb
Normal file
|
@ -0,0 +1,61 @@
|
|||
<% 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>
|
|
@ -90,6 +90,7 @@
|
|||
</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>
|
||||
|
|
|
@ -185,61 +185,3 @@
|
|||
<% 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>
|
||||
|
|
|
@ -416,6 +416,26 @@ en:
|
|||
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
|
||||
|
@ -2484,6 +2504,7 @@ en:
|
|||
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
|
||||
|
@ -2505,14 +2526,6 @@ en:
|
|||
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"
|
||||
|
@ -2533,15 +2546,7 @@ en:
|
|||
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
|
||||
|
|
|
@ -240,6 +240,7 @@ OpenStreetMap::Application.routes.draw do
|
|||
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]
|
||||
|
||||
|
|
34
test/controllers/dashboards_controller_test.rb
Normal file
34
test/controllers/dashboards_controller_test.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
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
|
|
@ -556,10 +556,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
|
|||
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
|
||||
|
@ -626,11 +623,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
|
|||
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))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue