Module: Dradis::Plugins::ContentService::Notes

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/dradis/plugins/content_service/notes.rb

Instance Method Summary collapse

Instance Method Details

#all_notesObject



5
6
7
# File 'lib/dradis/plugins/content_service/notes.rb', line 5

def all_notes
  project.notes.where(category: Category.report)
end

#create_note(args = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dradis/plugins/content_service/notes.rb', line 9

def create_note(args={})
  cat  = args.fetch(:category, default_note_category)
  node = args.fetch(:node, default_node_parent)
  text = args.fetch(:text, default_note_text)

  note = node.notes.new(
    text: text,
    category: cat,
    author: default_author
  )

  if note.valid?
    note.save
  else
    try_rescue_from_length_validation(
      model: note,
      field: :text,
      text: text,
      msg: 'Error in create_note()'
    )
  end

  note
end