From ce829bcc7cead94384bfec1c6e120d1ddecd4fc1 Mon Sep 17 00:00:00 2001 From: Mikel Maron Date: Wed, 14 Dec 2011 21:43:38 -0500 Subject: [PATCH] Add support for viewing a list of your friends' changesets --- app/controllers/changeset_controller.rb | 27 ++++++++++++++++++++++++- app/views/user/view.html.erb | 1 + config/locales/en.yml | 4 ++++ config/routes.rb | 1 + 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/app/controllers/changeset_controller.rb b/app/controllers/changeset_controller.rb index 9fc2bc320..033d89e4e 100644 --- a/app/controllers/changeset_controller.rb +++ b/app/controllers/changeset_controller.rb @@ -266,6 +266,27 @@ class ChangesetController < ApplicationController return 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 = BoundingBox.from_bbox_params(params) @@ -282,7 +303,11 @@ class ChangesetController < ApplicationController 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 diff --git a/app/views/user/view.html.erb b/app/views/user/view.html.erb index 2fa271a02..c13a276f7 100644 --- a/app/views/user/view.html.erb +++ b/app/views/user/view.html.erb @@ -118,6 +118,7 @@ <% if friends.empty? %> <%= t 'user.view.no friends' %> <% else %> + <%= link_to t('user.view.friends_changesets'), {:controller => 'browse', :action => 'friends'} %>

<%= render :partial => "contact", :collection => friends %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index f24bc490f..955f4a97c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -307,16 +307,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: @@ -1692,6 +1695,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" diff --git a/config/routes.rb b/config/routes.rb index 0a617b6a3..a60caeb2f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -86,6 +86,7 @@ OpenStreetMap::Application.routes.draw do match '/browse/changeset/:id' => 'browse#changeset', :as => :changeset, :id => /\d+/ match '/user/:display_name/edits' => 'changeset#list' match '/user/:display_name/edits/feed' => 'changeset#feed', :format => :atom + match '/browse/friends' => 'changeset#list', :friends => true match '/browse/changesets' => 'changeset#list' match '/browse/changesets/feed' => 'changeset#feed', :format => :atom match '/browse' => 'changeset#list' -- 2.39.5