]> git.openstreetmap.org Git - rails.git/commitdiff
Modify the way Friends are added
authornertc <davidtsiklauri7@gmail.com>
Tue, 14 Jan 2025 07:32:54 +0000 (11:32 +0400)
committernertc <davidtsiklauri7@gmail.com>
Tue, 14 Jan 2025 07:32:54 +0000 (11:32 +0400)
14 files changed:
app/controllers/diary_entries_controller.rb
app/controllers/friendships_controller.rb
app/helpers/changesets_helper.rb
app/mailers/user_mailer.rb
app/views/dashboards/_contact.html.erb
app/views/dashboards/show.html.erb
app/views/user_mailer/friendship_notification.html.erb
app/views/user_mailer/friendship_notification.text.erb
app/views/users/show.html.erb
config/locales/en.yml
test/controllers/friendships_controller_test.rb
test/controllers/oauth2_authorized_applications_controller_test.rb
test/system/dashboard_test.rb
test/system/friendships_test.rb

index 27099cd9cf9835558624088b34568b0fa9e587fa..5f39a0886ffad10f697b65a9a485fbe049c2f10e 100644 (file)
@@ -28,7 +28,7 @@ class DiaryEntriesController < ApplicationController
       end
     elsif params[:friends]
       if current_user
-        @title = t ".title_friends"
+        @title = t ".title_followed"
         entries = DiaryEntry.where(:user => current_user.friends)
       else
         require_user
index 8f0c1ad859c4332eb46c81d82db4e28d6a8fe755..8de438fd21fda3d76c12851f8854ed35be345a3d 100644 (file)
@@ -18,7 +18,7 @@ class FriendshipsController < ApplicationController
       friendship.befriender = current_user
       friendship.befriendee = @friend
       if current_user.friends_with?(@friend)
-        flash[:warning] = t ".already_a_friend", :name => @friend.display_name
+        flash[:warning] = t ".already_followed", :name => @friend.display_name
       elsif current_user.friendships.where(:created_at => Time.now.utc - 1.hour..).count >= current_user.max_friends_per_hour
         flash[:error] = t ".limit_exceeded"
       elsif friendship.save
@@ -40,7 +40,7 @@ class FriendshipsController < ApplicationController
         Friendship.where(:befriender => current_user, :befriendee => @friend).delete_all
         flash[:notice] = t ".success", :name => @friend.display_name
       else
-        flash[:error] = t ".not_a_friend", :name => @friend.display_name
+        flash[:error] = t ".not_followed", :name => @friend.display_name
       end
 
       referer = safe_referer(params[:referer]) if params[:referer]
index 4605658f65c0a3f1f0202cd70b7e3934adad9f96..d3bc5ed9ac085cf0259ebdf37a7a085bbe1caa30 100644 (file)
@@ -32,7 +32,7 @@ module ChangesetsHelper
 
   def changeset_index_title(params, user)
     if params[:friends] && user
-      t "changesets.index.title_friend"
+      t "changesets.index.title_followed"
     elsif params[:nearby] && user
       t "changesets.index.title_nearby"
     elsif params[:display_name]
index 1dd13fb2d220787af6562f11281abb6bd0da07cc..fc1b10551e8b75ad10834ba494c12b36574e7c8f 100644 (file)
@@ -123,7 +123,7 @@ class UserMailer < ApplicationMailer
     with_recipient_locale friendship.befriendee do
       @friendship = friendship
       @viewurl = user_url(@friendship.befriender)
-      @friendurl = make_friend_url(@friendship.befriender)
+      @followurl = follow_url(@friendship.befriender)
       @author = @friendship.befriender.display_name
 
       attach_user_avatar(@friendship.befriender)
index 759faab8f7d50d713a301ffab32b29d6ba959e65..41d0a24f29beea2259baef3e91d1b24e11959a5e 100644 (file)
@@ -1,7 +1,7 @@
 <% user_data = {
      :lon => contact.home_lon,
      :lat => contact.home_lat,
-     :icon => image_path(type == "friend" ? "marker-blue.png" : "marker-green.png"),
+     :icon => image_path(type == "following" ? "marker-blue.png" : "marker-green.png"),
      :description => render(:partial => "popup", :object => contact, :locals => { :type => type })
    } %>
 <%= tag.div :class => "clearfix row", :data => { :user => user_data } do %>
@@ -36,9 +36,9 @@
         <li><%= link_to t("users.show.send message"), new_message_path(contact) %></li>
         <li>
           <% if current_user.friends_with?(contact) %>
-            <%= link_to t("users.show.remove as friend"), remove_friend_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %>
+            <%= link_to t("users.show.unfollow"), remove_friend_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %>
           <% else %>
-            <%= link_to t("users.show.add as friend"), make_friend_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %>
+            <%= link_to t("users.follow"), make_friend_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %>
           <% end %>
         </li>
       </ul>
index c4b595e9b931dc6ba5e79be030105f082433a3d3..b1ca90e85425de3fa6ff844aa695e00752f59e9d 100644 (file)
     </div>
 
     <div class="col-md">
-      <h2><%= t ".my friends" %></h2>
+      <h2><%= t ".followings" %></h2>
 
       <% if friends.empty? %>
-        <%= t ".no friends" %>
+        <%= t ".no followings" %>
       <% else %>
         <nav class='secondary-actions mb-3'>
           <ul class='clearfix'>
-            <li><%= link_to t(".friends_changesets"), friend_changesets_path %></li>
-            <li><%= link_to t(".friends_diaries"), friends_diary_entries_path %></li>
+            <li><%= link_to t(".followed_changesets"), friend_changesets_path %></li>
+            <li><%= link_to t(".followed_diaries"), friends_diary_entries_path %></li>
           </ul>
         </nav>
         <div>
-          <%= render :partial => "contact", :collection => friends, :locals => { :type => "friend" } %>
+          <%= render :partial => "contact", :collection => friends, :locals => { :type => "following" } %>
         </div>
       <% end %>
 
index 40af762d70ff6f0698c0e2bb28c6e6b3b0f62c27..fffad9fa2c5efc8f7a03464abbdf25aecf1641d3 100644 (file)
@@ -1,11 +1,11 @@
 <p><%= t ".hi", :to_user => @friendship.befriendee.display_name %></p>
 
-<p><%= t ".had_added_you", :user => @friendship.befriender.display_name %></p>
+<p><%= t ".followed_you", :user => @friendship.befriender.display_name %></p>
 
 <%= message_body do %>
   <p><%= t ".see_their_profile_html", :userurl => link_to(@viewurl, @viewurl) %></p>
 
   <% unless @friendship.befriendee.friends_with?(@friendship.befriender) -%>
-  <p><%= t ".befriend_them_html", :befriendurl => link_to(@friendurl, @friendurl) %></p>
+  <p><%= t ".follow_them_html", :followurl => link_to(@followurl, @followurl) %></p>
   <% end -%>
 <% end %>
index 104b0f1c925f63a2c4820974c69dd986249647b7..593bc765a270f9f99a5a7367d1331b61684f80f2 100644 (file)
@@ -1,9 +1,9 @@
 <%= t ".hi", :to_user => @friendship.befriendee.display_name %>
 
-<%= t '.had_added_you', :user => @friendship.befriender.display_name %>
+<%= t '.followed_you', :user => @friendship.befriender.display_name %>
 
 <%= t '.see_their_profile', :userurl => @viewurl %>
 
 <% unless @friendship.befriendee.friends_with?(@friendship.befriender) -%>
-<%= t '.befriend_them', :befriendurl => @friendurl %>
+<%= t '.follow_them', :followurl => @followurl %>
 <% end -%>
index c168972aac44a945a8118454ec5c97e807505bdc..efeac90bc23f6b4cc2dc834a9e6945f1180757a8 100644 (file)
@@ -84,9 +84,9 @@
             <% if current_user %>
               <li>
                 <% if current_user.friends_with?(@user) %>
-                  <%= link_to t(".remove as friend"), remove_friend_path(:display_name => @user.display_name), :method => :post %>
+                  <%= link_to t(".unfollow"), remove_friend_path(:display_name => @user.display_name), :method => :post %>
                 <% else %>
-                  <%= link_to t(".add as friend"), make_friend_path(:display_name => @user.display_name), :method => :post %>
+                  <%= link_to t(".follow"), make_friend_path(:display_name => @user.display_name), :method => :post %>
                 <% end %>
               </li>
             <% end %>
index d1faa7a50c2b428938565059e94388e63fd6d20b..f9fe33041e08d7c0f2c23c83c99514f873629506 100644 (file)
@@ -92,7 +92,7 @@ en:
         support_url: Support URL
         allow_read_prefs:  read their user preferences
         allow_write_prefs: modify their user preferences
-        allow_write_diary: create diary entries, comments and make friends
+        allow_write_diary: create diary entries and comments
         allow_write_api:   modify the map
         allow_read_gpx:    read their private GPS traces
         allow_write_gpx:   upload GPS traces
@@ -478,7 +478,7 @@ en:
       title: "Changesets"
       title_user: "Changesets by %{user}"
       title_user_link_html: "Changesets by %{user_link}"
-      title_friend: "Changesets by my friends"
+      title_followed: "Changesets by followings"
       title_nearby: "Changesets by nearby users"
       empty: "No changesets found."
       empty_area: "No changesets in this area."
@@ -544,17 +544,17 @@ en:
     popup:
       your location: "Your location"
       nearby mapper: "Nearby mapper"
-      friend: "Friend"
+      following: "Following"
     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.
+      followings: Followings  
+      no followings: You have not followed any user 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"
+      followed_changesets: "changesets"
+      followed_diaries: "diary entries"
       nearby_changesets: "nearby user changesets"
       nearby_diaries: "nearby user diary entries"
   diary_entries:
@@ -565,7 +565,7 @@ en:
       use_map_link: Use Map
     index:
       title: "Users' Diaries"
-      title_friends: "Friends' Diaries"
+      title_followed: "Followings' Diaries"
       title_nearby: "Nearby Users' Diaries"
       user_title: "%{user}'s Diary"
       in_language_title: "Diary Entries in %{language}"
@@ -688,17 +688,17 @@ en:
       description: Couldn't find a file/directory/API operation by that name on the OpenStreetMap server (HTTP 404)
   friendships:
     make_friend:
-      heading: "Add %{user} as a friend?"
-      button: "Add as friend"
-      success: "%{name} is now your friend!"
-      failed: "Sorry, failed to add %{name} as a friend."
-      already_a_friend: "You are already friends with %{name}."
-      limit_exceeded: "You have friended a lot of users recently. Please wait a while before trying to friend any more."
+      heading: "Do you want to follow %{user}?"
+      button: "Follow User"
+      success: "You are now following %{name}!"
+      failed: "Sorry, your request to follow %{name} has failed."
+      already_followed: "You already follow %{name}."
+      limit_exceeded: "You have followed a lot of users recently. Please wait a while before trying to follow any more."
     remove_friend:
-      heading: "Unfriend %{user}?"
-      button: "Unfriend"
-      success: "%{name} was removed from your friends."
-      not_a_friend: "%{name} is not one of your friends."
+      heading: "Do you want to unfollow %{user}?"
+      button: "Unfollow"
+      success: "You successfully unfollowed %{name}."
+      not_followed: "You are not following %{name}."
   geocoder:
     search:
       title:
@@ -1662,12 +1662,12 @@ en:
       footer_html: "You can also read the message at %{readurl} and you can send a message to the author at %{replyurl}"
     friendship_notification:
       hi: "Hi %{to_user},"
-      subject: "[OpenStreetMap] %{user} added you as a friend"
-      had_added_you: "%{user} has added you as a friend on OpenStreetMap."
+      subject: "[OpenStreetMap] %{user} followed you"
+      followed_you: "%{user} is now following you on OpenStreetMap."
       see_their_profile: "You can see their profile at %{userurl}."
       see_their_profile_html: "You can see their profile at %{userurl}."
-      befriend_them: "You can also add them as a friend at %{befriendurl}."
-      befriend_them_html: "You can also add them as a friend at %{befriendurl}."
+      follow_them: "You can also follow them at %{followurl}."
+      follow_them_html: "You can also follow them at %{followurl}."
     gpx_details:
       details: "Your file details:"
       filename: Filename
@@ -2698,7 +2698,7 @@ en:
       openid: Sign-in using OpenStreetMap
       read_prefs: Read user preferences
       write_prefs: Modify user preferences
-      write_diary: Create diary entries, comments and make friends
+      write_diary: Create diary entries and comments
       write_api: Modify the map
       read_gpx: Read private GPS traces
       write_gpx: Upload GPS traces
@@ -2818,8 +2818,8 @@ en:
       edits: Edits
       traces: Traces
       notes: Map Notes
-      remove as friend: Unfriend
-      add as friend: Add Friend
+      unfollow: Unfollow
+      follow: Follow
       mapper since: "Mapper since:"
       last map edit: "Last map edit:"
       no activity yet: "No activity yet"
index f63a8e44982318701c6c486ecda0d283798543da..5e5cf1344c8908d5c44543b6064b8bfa8c93f587 100644 (file)
@@ -5,24 +5,24 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest
   # test all routes which lead to this controller
   def test_routes
     assert_routing(
-      { :path => "/user/username/make_friend", :method => :get },
-      { :controller => "friendships", :action => "make_friend", :display_name => "username" }
+      { :path => "/user/username/follow", :method => :get },
+      { :controller => "friendships", :action => "follow", :display_name => "username" }
     )
     assert_routing(
-      { :path => "/user/username/make_friend", :method => :post },
-      { :controller => "friendships", :action => "make_friend", :display_name => "username" }
+      { :path => "/user/username/follow", :method => :post },
+      { :controller => "friendships", :action => "follow", :display_name => "username" }
     )
     assert_routing(
-      { :path => "/user/username/remove_friend", :method => :get },
-      { :controller => "friendships", :action => "remove_friend", :display_name => "username" }
+      { :path => "/user/username/unfollow", :method => :get },
+      { :controller => "friendships", :action => "unfollow", :display_name => "username" }
     )
     assert_routing(
-      { :path => "/user/username/remove_friend", :method => :post },
-      { :controller => "friendships", :action => "remove_friend", :display_name => "username" }
+      { :path => "/user/username/unfollow", :method => :post },
+      { :controller => "friendships", :action => "unfollow", :display_name => "username" }
     )
   end
 
-  def test_make_friend
+  def test_follow
     # Get users to work with
     user = create(:user)
     friend = create(:user)
@@ -44,7 +44,7 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest
     # When logged in a GET should get a confirmation page
     get make_friend_path(friend)
     assert_response :success
-    assert_template :make_friend
+    assert_template :follow
     assert_select "form" do
       assert_select "input[type='hidden'][name='referer']", 0
       assert_select "input[type='submit']", 1
@@ -58,7 +58,7 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest
       end
     end
     assert_redirected_to user_path(friend)
-    assert_match(/is now your friend/, flash[:notice])
+    assert_match(/You are now following/, flash[:notice])
     assert Friendship.find_by(:befriender => user, :befriendee => friend)
     email = ActionMailer::Base.deliveries.first
     assert_equal 1, email.to.count
@@ -72,11 +72,11 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest
       end
     end
     assert_redirected_to user_path(friend)
-    assert_match(/You are already friends with/, flash[:warning])
+    assert_match(/You already follow/, flash[:warning])
     assert Friendship.find_by(:befriender => user, :befriendee => friend)
   end
 
-  def test_make_friend_with_referer
+  def test_follow_with_referer
     # Get users to work with
     user = create(:user)
     friend = create(:user)
@@ -88,7 +88,7 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest
     # The GET should preserve any referer
     get make_friend_path(friend), :params => { :referer => "/test" }
     assert_response :success
-    assert_template :make_friend
+    assert_template :follow
     assert_select "form" do
       assert_select "input[type='hidden'][name='referer'][value='/test']", 1
       assert_select "input[type='submit']", 1
@@ -102,7 +102,7 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest
       end
     end
     assert_redirected_to "/test"
-    assert_match(/is now your friend/, flash[:notice])
+    assert_match(/You are now following/, flash[:notice])
     assert Friendship.find_by(:befriender => user, :befriendee => friend)
     email = ActionMailer::Base.deliveries.first
     assert_equal 1, email.to.count
@@ -110,7 +110,7 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest
     ActionMailer::Base.deliveries.clear
   end
 
-  def test_make_friend_unknown_user
+  def test_follow_unknown_user
     # Should error when a bogus user is specified
     session_for(create(:user))
     get make_friend_path("No Such User")
@@ -118,7 +118,7 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest
     assert_template :no_such_user
   end
 
-  def test_remove_friend
+  def test_unfollow
     # Get users to work with
     user = create(:user)
     friend = create(:user)
@@ -141,7 +141,7 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest
     # When logged in a GET should get a confirmation page
     get remove_friend_path(friend)
     assert_response :success
-    assert_template :remove_friend
+    assert_template :unfollow
     assert_select "form" do
       assert_select "input[type='hidden'][name='referer']", 0
       assert_select "input[type='submit']", 1
@@ -151,17 +151,17 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest
     # When logged in a POST should remove the friendship
     post remove_friend_path(friend)
     assert_redirected_to user_path(friend)
-    assert_match(/was removed from your friends/, flash[:notice])
+    assert_match(/You successfully unfollowed/, flash[:notice])
     assert_nil Friendship.find_by(:befriender => user, :befriendee => friend)
 
     # A second POST should report that the friendship does not exist
     post remove_friend_path(friend)
     assert_redirected_to user_path(friend)
-    assert_match(/is not one of your friends/, flash[:error])
+    assert_match(/You are not following/, flash[:error])
     assert_nil Friendship.find_by(:befriender => user, :befriendee => friend)
   end
 
-  def test_remove_friend_with_referer
+  def test_unfollow_with_referer
     # Get users to work with
     user = create(:user)
     friend = create(:user)
@@ -174,7 +174,7 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest
     # The GET should preserve any referer
     get remove_friend_path(friend), :params => { :referer => "/test" }
     assert_response :success
-    assert_template :remove_friend
+    assert_template :unfollow
     assert_select "form" do
       assert_select "input[type='hidden'][name='referer'][value='/test']", 1
       assert_select "input[type='submit']", 1
@@ -184,11 +184,11 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest
     # When logged in a POST should remove the friendship and refer
     post remove_friend_path(friend), :params => { :referer => "/test" }
     assert_redirected_to "/test"
-    assert_match(/was removed from your friends/, flash[:notice])
+    assert_match(/You successfully unfollowed/, flash[:notice])
     assert_nil Friendship.find_by(:befriender => user, :befriendee => friend)
   end
 
-  def test_remove_friend_unknown_user
+  def test_unfollow_unknown_user
     # Should error when a bogus user is specified
     session_for(create(:user))
     get remove_friend_path("No Such User")
index 3a9088401e7e77dad6ff80d1ed1d08ac1475afa0..584d00ce859992958c3749f97e0218abfdb85085 100644 (file)
@@ -56,7 +56,7 @@ class Oauth2AuthorizedApplicationsControllerTest < ActionDispatch::IntegrationTe
       assert_select "li", :count => 3
       assert_select "li", :text => "Read user preferences"
       assert_select "li", :text => "Modify user preferences"
-      assert_select "li", :text => "Create diary entries, comments and make friends"
+      assert_select "li", :text => "Create diary entries and comments"
     end
   end
 
index bc2e3b4e974c79949603a5666260226d6e1afe93..ef1b952dc24e7c216af9924cc7b48579377d4be5 100644 (file)
@@ -1,12 +1,12 @@
 require "application_system_test_case"
 
 class DashboardSystemTest < ApplicationSystemTestCase
-  test "show no users if have no friends" do
+  test "show no users if have no followings" do
     user = create(:user)
     sign_in_as(user)
 
     visit dashboard_path
-    assert_text "You have not added any friends yet."
+    assert_text "You have not followed any user yet."
   end
 
   test "show users if have friends" do
@@ -17,9 +17,9 @@ class DashboardSystemTest < ApplicationSystemTestCase
     sign_in_as(user)
 
     visit dashboard_path
-    assert_no_text "You have not added any friends yet."
+    assert_no_text "You have not followed any user yet."
 
-    friends_heading = find :element, "h2", :text => "My friends"
+    friends_heading = find :element, "h2", :text => "Followings"
     others_heading = find :element, "h2", :text => "Other nearby users"
 
     assert_link friend_user.display_name, :below => friends_heading, :above => others_heading
index 1db4d3c256926b2e0a281760e5374fafb47daf99..25b627f535c9829faf795b1e8d3a5513185d450c 100644 (file)
@@ -8,11 +8,11 @@ class FriendshipsTest < ApplicationSystemTestCase
 
     with_settings(:max_friends_per_hour => 0) do
       visit user_path(befriendee)
-      assert_link "Add Friend"
+      assert_link "Follow"
 
-      click_on "Add Friend"
-      assert_text "You have friended a lot of users recently"
-      assert_link "Add Friend"
+      click_on "Follow"
+      assert_text "You have followed a lot of users recently"
+      assert_link "Follow"
     end
   end
 end