Skip to content

Commit

Permalink
checkpoint end of wed session
Browse files Browse the repository at this point in the history
  • Loading branch information
BethFrank committed Nov 6, 2013
1 parent 8f70dbd commit c16b9b3
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions app/models/source/bibtex.rb
Expand Up @@ -14,9 +14,9 @@ class Source::Bibtex < Source
soft_validate(:sv_authors_exist)
soft_validate(:sv_year_exists)
soft_validate(:sv_date_exists, set: :recommended_fields)
#soft_validate(:no_writer, set: :recommended_fields)
soft_validate(:sv_contains_a_writer, set: :recommended_fields)
#soft_validate(:no_title, set: :recommended_fields)
#soft_validate(:sv_journal_exists, set: :recommended_fields)
soft_validate(:sv_is_article_missing_journal, set: :recommended_fields)
#soft_validate(:sv_URL_exists, set: :recommended_fields)
#endregion

Expand Down Expand Up @@ -107,8 +107,8 @@ def self.bibtex_author_to_person(bibtex_author)
suffix: bibtex_author.suffix)
end

def has_authors?
# return true if there is a bibtex author or if author roles exist.
#region has_<attribute>? section
def has_authors? # is there a bibtex author or author roles?

# return true if !(self.author.to_s.strip.length == 0)
return true if !(self.author.blank?)
Expand All @@ -126,12 +126,20 @@ def has_editors?
(self.editors.count > 0) ? (return true) : (return false)
end

def has_writer? # contains either an author or editor
(has_authors?) || (has_editors?) ? true : false
end

def has_date? # is there a year or stated year?
return true if !(self.year.blank?)
return true if !(self.stated_year.blank?)
return false
end

#TODO write has_note?

#endregion

protected

def check_bibtex_type # must have a valid bibtex_type
Expand Down Expand Up @@ -161,8 +169,8 @@ def sv_authors_exist
end
end

def no_writer # neither author nor editor
if !(has_authors?) && !(has_editors?)
def sv_contains_a_writer # neither author nor editor
if !has_writer?
soft_validations.add(:author, 'There is neither an author,nor editor associated with this source')
soft_validations.add(:editor, 'There is neither an author,nor editor associated with this source')
end
Expand Down Expand Up @@ -191,7 +199,7 @@ def no_journal
soft_validations.add(:bibtex_type, 'The source is missing a journal name') if self.journal.blank?
end

def article_missing_journal
def sv_is_article_missing_journal
if (self.bibtex_type == 'article')
if (self.journal.blank?)
soft_validations.add(:bibtex_type, 'The article is missing a journal name')
Expand Down Expand Up @@ -226,7 +234,7 @@ def missing_required_bibtex_fields
article_missing_journal
sv_year_exists
when 'book' #:book => [[:author,:editor],:title,:publisher,:year]
self.no_writer
sv_contains_a_writer
self.no_title
self.no_publisher
sv_year_exists
Expand All @@ -238,7 +246,7 @@ def missing_required_bibtex_fields
self.no_booktitle
sv_year_exists
when 'inbook' # :inbook => [[:author,:editor],:title,[:chapter,:pages],:publisher,:year],
self.no_writer
sv_contains_a_writer
self.no_title
self.no_included
self.no_publisher
Expand All @@ -264,14 +272,15 @@ def missing_required_bibtex_fields
when 'proceedings' # :proceedings => [:title,:year],
when 'techreport' # :techreport => [:author,:title,:institution,:year],
when 'unpublished' # :unpublished => [:author,:title,:note]
sv_author_exists
sv_authors_exist
no_title
#check for note
#check for note

end

end

#endregion

end

0 comments on commit c16b9b3

Please sign in to comment.