]> git.openstreetmap.org Git - rails.git/commitdiff
Add warnings when creating notes anonymously
authorAnton Khorev <tony29@yandex.ru>
Tue, 14 May 2024 16:42:59 +0000 (19:42 +0300)
committerAnton Khorev <tony29@yandex.ru>
Tue, 14 May 2024 16:42:59 +0000 (19:42 +0300)
app/views/notes/new.html.erb
config/locales/en.yml
test/controllers/notes_controller_test.rb

index ee9837056b0c5756cf2994a6ef93f6358439e291..6728b32ffbc6a501abb252fc6941b3ec3e2cfdcd 100644 (file)
@@ -4,6 +4,11 @@
 
 <div class="note">
   <p class="alert alert-info"><%= t(".intro") %></p>
+  <% if !current_user %>
+    <p class="alert alert-warning"><%= t ".anonymous_warning_html",
+                                         :log_in => link_to(t(".anonymous_warning_log_in"), login_path(:referer => new_note_path)),
+                                         :sign_up => link_to(t(".anonymous_warning_sign_up"), user_new_path) %></p>
+  <% end %>
   <form action="#">
     <input type="hidden" name="lon" autocomplete="off">
     <input type="hidden" name="lat" autocomplete="off">
index 45c44765d58aaa7e6234b2aaef639a90778d27ab..774be22d43d9bc530576927814cabd4dc9ae7726 100644 (file)
@@ -3081,6 +3081,9 @@ en:
     new:
       title: "New Note"
       intro: "Spotted a mistake or something missing? Let other mappers know so we can fix it. Move the marker to the correct position and type a note to explain the problem."
+      anonymous_warning_html: "You are not logged in. Please %{log_in} or %{sign_up} if you want to receive updates for your note."
+      anonymous_warning_log_in: "log in"
+      anonymous_warning_sign_up: "sign up"
       advice: "Your note is public and may be used to update the map, so don't enter personal information, or information from copyrighted maps or directory listings."
       add: Add Note
   javascripts:
index 5ecece0f4c842ef8c05bc03c7983609c10e8c6c6..a543342698648aad26dc1991a42fcc3f0ab2330f 100644 (file)
@@ -160,9 +160,19 @@ class NotesControllerTest < ActionDispatch::IntegrationTest
     assert_select "div.details", /Resolved by deleted/
   end
 
+  def test_new_note_anonymous
+    get new_note_path
+    assert_response :success
+    assert_template "notes/new"
+    assert_select "#sidebar_content a[href='#{login_path(:referer => new_note_path)}']", :count => 1
+  end
+
   def test_new_note
+    session_for(create(:user))
+
     get new_note_path
     assert_response :success
     assert_template "notes/new"
+    assert_select "#sidebar_content a[href='#{login_path(:referer => new_note_path)}']", :count => 0
   end
 end