Add warnings when creating notes anonymously

This commit is contained in:
Anton Khorev 2024-05-14 19:42:59 +03:00
parent 54e5b3cceb
commit 822466c6c6
3 changed files with 19 additions and 1 deletions

View 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">

View 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:

View file

@ -160,9 +160,19 @@ class NotesControllerTest < ActionDispatch::IntegrationTest
assert_select "div.details", /Resolved by deleted/
end
def test_new_note
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