|
|
|
@ -13,6 +13,8 @@ class Annotation < ApplicationRecord |
|
|
|
|
|
|
|
|
|
|
|
validates :content, presence: true |
|
|
|
validates :content, presence: true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before_save :parse_content |
|
|
|
|
|
|
|
|
|
|
|
def documents |
|
|
|
def documents |
|
|
|
annotation_documents.collect(&:document) |
|
|
|
annotation_documents.collect(&:document) |
|
|
|
end |
|
|
|
end |
|
|
|
@ -31,6 +33,18 @@ class Annotation < ApplicationRecord |
|
|
|
documents.map(&:id) |
|
|
|
documents.map(&:id) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def parse_content |
|
|
|
|
|
|
|
pr = phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil") |
|
|
|
|
|
|
|
pr = pr.gsub(/(PhilRep|Phil)\.?,?/i, "Phil") |
|
|
|
|
|
|
|
annotated_doc_title = document.short_title || document.title |
|
|
|
|
|
|
|
annotated_doc_date = document.doc_date.present? ? document.doc_date.try(:strftime, "%B %d, %Y") : document.year |
|
|
|
|
|
|
|
contents = content.split(" citing ") |
|
|
|
|
|
|
|
contents[0] = [annotated_doc_title, document.clean_reference_number, annotated_doc_date, pr].join(", ") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.content = contents.join(" citing ") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
searchable do |
|
|
|
searchable do |
|
|
|
integer :document_id |
|
|
|
integer :document_id |
|
|
|
integer :doctrine_id |
|
|
|
integer :doctrine_id |
|
|
|
|