From: mmd-osm Date: Sat, 3 Nov 2018 17:32:02 +0000 (+0100) Subject: Limit notes sizes to 2000 characters X-Git-Tag: live~3374^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/d9a48d66f977afbe9d5e196e9e22d882b16b3566?ds=sidebyside;hp=--cc Limit notes sizes to 2000 characters --- d9a48d66f977afbe9d5e196e9e22d882b16b3566 diff --git a/app/models/note_comment.rb b/app/models/note_comment.rb index f8450d0a3..c9caa1b85 100644 --- a/app/models/note_comment.rb +++ b/app/models/note_comment.rb @@ -33,7 +33,8 @@ class NoteComment < ActiveRecord::Base validates :visible, :inclusion => [true, false] validates :author, :associated => true validates :event, :inclusion => %w[opened closed reopened commented hidden] - validates :body, :format => /\A[^\x00-\x08\x0b-\x0c\x0e-\x1f\x7f\ufffe\uffff]*\z/ + validates :body, :allow_blank => false, :length => { :maximum => 2000 }, + :format => /\A[^\x00-\x08\x0b-\x0c\x0e-\x1f\x7f\ufffe\uffff]*\z/ # Return the comment text def body diff --git a/app/views/browse/new_note.html.erb b/app/views/browse/new_note.html.erb index f6518daf2..e8b64b705 100644 --- a/app/views/browse/new_note.html.erb +++ b/app/views/browse/new_note.html.erb @@ -10,7 +10,7 @@
- +
diff --git a/app/views/browse/note.html.erb b/app/views/browse/note.html.erb index 53ea0759e..a677a7c14 100644 --- a/app/views/browse/note.html.erb +++ b/app/views/browse/note.html.erb @@ -42,7 +42,7 @@ <% if @note.status == "open" %> - +
<% if current_user and current_user.moderator? -%>