From d9a48d66f977afbe9d5e196e9e22d882b16b3566 Mon Sep 17 00:00:00 2001 From: mmd-osm Date: Sat, 3 Nov 2018 18:32:02 +0100 Subject: [PATCH] Limit notes sizes to 2000 characters --- app/models/note_comment.rb | 3 ++- app/views/browse/new_note.html.erb | 2 +- app/views/browse/note.html.erb | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) 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? -%> -- 2.39.5