### Motivation
In the French community, we've had a problem for over a year with someone 
creating a huge number of anonymous notes, which hampers the processing of 
other relevant notes in the same area. See [this 
discussion](https://forum.openstreetmap.fr/t/notes-anonymes-a-gogo/18362) on 
the French community forum.

I thought it would be a good idea to count the number of anonymous notes 
created in the same browser and to display a warning when this number becomes 
too high, to encourage visitors to become users and contributors.

### Description

This PR creates a new warning in the UI of the new note form if an anonymous 
visitor has already created too many anonymous notes (threshold set at 20 for 
now)
![image](https://github.com/user-attachments/assets/4812efa9-f402-4601-aa9c-eb0ea969954f)

**Changes**:
- in template views/note/new.html.erb
  - add a new div element displaying the warning (hidden at first)
- in locales/en.yml
  - add text and links for the warning, with ‘(N)’ being replaced by the number 
of anonymous notes
- in new_note.js
  - when an anonymous note is created: add +1 to the counter in localStorage
  - when the form is displayed: check the counter in localStorage. If more that 
20 notes have already been created: display the warning, and replace (N) in the 
text warning with the number of anonymous notes already created.
 
**Possible additional change (not included yet)**
After an even larger number of anonymous notes (50?), I thought we could hide 
the textarea, and trigger its display by clicking on a button _sure you want to 
post an anonymous note again?_, which would force the visitor to perform an 
additional action. This is not included in this PR yet, but tell me if you want 
me to add it.

### How has this been tested?
The code has been tested on my personal computer using rails built-in 
webserver. I verified that the new note form is still working fine both when 
logged in and in anonymous mode.

However, as described in issue #5467 I was not able to make all the tests 
requested in 
[CONTRIBUTING.md](https://github.com/openstreetmap/openstreetmap-website/blob/master/CONTRIBUTING.md).

As this is my very first PR, I'm not sure I've done everything right, 
so I welcome any relevant comments!
You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/5468

-- Commit Summary --

  * display warning in new note form after too many anonymous notes

-- File Changes --

    M app/assets/javascripts/index/new_note.js (13)
    M app/views/notes/new.html.erb (5)
    M config/locales/en.yml (4)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/5468.patch
https://github.com/openstreetmap/openstreetmap-website/pull/5468.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5468
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5...@github.com>
_______________________________________________
rails-dev mailing list
rails-dev@openstreetmap.org
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to