summaryrefslogtreecommitdiff
path: root/app/models/note.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb40
1 files changed, 13 insertions, 27 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index 849139701d4..23ced536b67 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -2,39 +2,26 @@ require 'carrierwave/orm/activerecord'
require 'file_size_validator'
class Note < ActiveRecord::Base
+ mount_uploader :attachment, AttachmentUploader
attr_accessible :note, :noteable, :noteable_id, :noteable_type, :project_id,
:attachment, :line_code
belongs_to :project
belongs_to :noteable, polymorphic: true
- belongs_to :author,
- class_name: "User"
+ belongs_to :author, class_name: "User"
- delegate :name,
- to: :project,
- prefix: true
-
- delegate :name,
- :email,
- to: :author,
- prefix: true
+ delegate :name, to: :project, prefix: true
+ delegate :name, :email, to: :author, prefix: true
attr_accessor :notify
attr_accessor :notify_author
validates_presence_of :project
- validates :note,
- presence: true,
- length: { within: 0..5000 }
-
- validates :attachment,
- file_size: {
- maximum: 10.megabytes.to_i
- }
+ validates :note, presence: true, length: { within: 0..5000 }
+ validates :attachment, file_size: { maximum: 10.megabytes.to_i }
scope :common, where(noteable_id: nil)
-
scope :today, where("created_at >= :date", date: Date.today)
scope :last_week, where("created_at >= :date", date: (Date.today - 7.days))
scope :since, lambda { |day| where("created_at >= :date", date: (day)) }
@@ -42,14 +29,13 @@ class Note < ActiveRecord::Base
scope :inc_author_project, includes(:project, :author)
scope :inc_author, includes(:author)
- mount_uploader :attachment, AttachmentUploader
-
def self.create_status_change_note(noteable, author, status)
- create({ noteable: noteable,
- project: noteable.project,
- author: author,
- note: "_Status changed to #{status}_" },
- without_protection: true)
+ create({
+ noteable: noteable,
+ project: noteable.project,
+ author: author,
+ note: "_Status changed to #{status}_"
+ }, without_protection: true)
end
def notify
@@ -114,6 +100,7 @@ class Note < ActiveRecord::Base
note.start_with?('-1') || note.start_with?(':-1:')
end
end
+
# == Schema Information
#
# Table name: notes
@@ -129,4 +116,3 @@ end
# attachment :string(255)
# line_code :string(255)
#
-