]> git.openstreetmap.org Git - rails.git/commitdiff
Add support for viewing a list of your friends' changesets
authorMikel Maron <mikel_maron@yahoo.com>
Thu, 15 Dec 2011 02:43:38 +0000 (21:43 -0500)
committerTom Hughes <tom@compton.nu>
Thu, 15 Dec 2011 21:25:27 +0000 (21:25 +0000)
app/controllers/changeset_controller.rb
app/views/user/view.html.erb
config/locales/en.yml
config/routes.rb

index 9fc2bc320315ce06e2c31bffbc80f2c929c075aa..033d89e4e45302f08e2e5c782798f5b36447b66a 100644 (file)
@@ -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
index 2fa271a02be8ea630779692789c604a13f2f0b6c..c13a276f7dc57afb909a90a3bed2e0c7bdc0d811 100644 (file)
   <% 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>
index f24bc490f4d8e21469dfb65b577ceba7eb4772f0..955f4a97c142b5ffe68167262fe29c5be5dd7926 100644 (file)
@@ -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"
index 0a617b6a30a8ed4c766c43704dd599b0aa1a52cc..a60caeb2f087937d946186f8575fec98446df56f 100644 (file)
@@ -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'