Skip to content

Commit

Permalink
friends changesets
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikel Maron committed Dec 15, 2011
1 parent a0a2a39 commit db49758
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
27 changes: 26 additions & 1 deletion app/controllers/changeset_controller.rb
Expand Up @@ -275,6 +275,27 @@ def list
end
end

if params[:friends]
user = @user
if user
friend_ids = []
user.friends.each do |friend|
friend_user = User.find(friend.friend_user_id)
if friend_user.data_public?
friend_ids << friend.friend_user_id
end
end
if friend_ids.length > 0
conditions = cond_merge conditions, ['user_id in (?)', friend_ids]
else
conditions = cond_merge conditions, ['false']
end
elsif request.format == :html
@title = t 'user.no_such_user.title'
render :template => 'user/no_such_user', :status => :not_found
end
end

if params[:bbox]
bbox = params[:bbox]
elsif params[:minlon] and params[:minlat] and params[:maxlon] and params[:maxlat]
Expand All @@ -291,7 +312,11 @@ def list
user_link = render_to_string :partial => "user", :object => user
end

if user and bbox
if params[:friends] and user
@title = t 'changeset.list.title_friend'
@heading = t 'changeset.list.heading_friend'
@description = t 'changeset.list.description_friend'
elsif user and bbox
@title = t 'changeset.list.title_user_bbox', :user => user.display_name, :bbox => bbox.to_s
@heading = t 'changeset.list.heading_user_bbox', :user => user.display_name, :bbox => bbox.to_s
@description = t 'changeset.list.description_user_bbox', :user => user_link, :bbox => bbox_link
Expand Down
1 change: 1 addition & 0 deletions app/views/user/view.html.erb
Expand Up @@ -108,6 +108,7 @@
<% if friends.empty? %>
<%= t 'user.view.no friends' %>
<% else %>
<%= link_to t('user.view.friends_changesets'), {:controller => 'browse', :action => 'friends'} %><br/><br/>
<table id="friends">
<%= render :partial => "contact", :collection => friends %>
</table>
Expand Down
4 changes: 4 additions & 0 deletions config/locales/en.yml
Expand Up @@ -302,16 +302,19 @@ en:
title_user: "Changesets by {{user}}"
title_bbox: "Changesets within {{bbox}}"
title_user_bbox: "Changesets by {{user}} within {{bbox}}"
title_friend: "Changesets by your friends"

heading: "Changesets"
heading_user: "Changesets"
heading_bbox: "Changesets"
heading_user_bbox: "Changesets"
heading_friend: "Changesets"

description: "Recent changes"
description_user: "Changesets by {{user}}"
description_bbox: "Changesets within {{bbox}}"
description_user_bbox: "Changesets by {{user}} within {{bbox}}"
description_friend: "Changesets by your friends"
timeout:
sorry: "Sorry, the list of changesets you requested took too long to retrieve."
diary_entry:
Expand Down Expand Up @@ -1643,6 +1646,7 @@ en:
unhide_user: "unhide this user"
delete_user: "delete this user"
confirm: "Confirm"
friends_changesets: "Browse all changesets by friends"
popup:
your location: "Your location"
nearby mapper: "Nearby mapper"
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -86,6 +86,7 @@
map.changeset '/browse/changeset/:id', :controller => 'browse', :action => 'changeset', :id => /\d+/
map.connect '/user/:display_name/edits/feed', :controller => 'changeset', :action => 'list', :format =>:atom
map.connect '/user/:display_name/edits', :controller => 'changeset', :action => 'list'
map.connect '/browse/friends', :controller => 'changeset', :action => 'list', :friends => true
map.connect '/browse/changesets/feed', :controller => 'changeset', :action => 'list', :format => :atom
map.connect '/browse/changesets', :controller => 'changeset', :action => 'list'
map.connect '/browse', :controller => 'changeset', :action => 'list'
Expand Down

0 comments on commit db49758

Please sign in to comment.