Merge pull request #3008 from evazion/fix-disallow-blank-notes

Fix #1566: disallow blank note bodies.
This commit is contained in:
Albert Yi
2017-05-01 14:18:28 -07:00
committed by GitHub
3 changed files with 9 additions and 7 deletions

View File

@@ -8,8 +8,7 @@ class Note < ActiveRecord::Base
has_many :versions, lambda {order("note_versions.id ASC")}, :class_name => "NoteVersion", :dependent => :destroy
before_validation :initialize_creator, :on => :create
before_validation :initialize_updater
before_validation :blank_body
validates_presence_of :post_id, :creator_id, :updater_id, :x, :y, :width, :height
validates_presence_of :post_id, :creator_id, :updater_id, :x, :y, :width, :height, :body
validate :post_must_exist
validate :note_within_image
after_save :update_post
@@ -124,10 +123,6 @@ class Note < ActiveRecord::Base
Post.exists?(["id = ? AND is_note_locked = ?", post_id, true])
end
def blank_body
self.body = "(empty)" if body.blank?
end
def creator_name
User.id_to_name(creator_id).tr("_", " ")
end