class Phase

Project:

DMPonline v4

Description:

This model describes informmation about the phase of a plan, it's title, order of display and which template it belongs to.

Created:

03/09/2014

Copyright:

Digital Curation Centre

Public Instance Methods

has_sections() click to toggle source

verify if a phase has a published version or a version with one or more sections

# File app/models/phase.rb, line 44
def has_sections
        versions = self.versions.where('published = ?', true).order('updated_at DESC')
        if versions.any? then
                version = versions.first
                if !version.sections.empty? then
                        has_section = true
                else
                        has_section = false
                end  
        else
                version = self.versions.order('updated_at DESC').first 
                if !version.sections.empty? then
                        has_section = true
                else
                        has_section = false
                end  
        end
        return has_section
end
latest_published_version() click to toggle source

Verify if this phase has any published versions

# File app/models/phase.rb, line 34
def latest_published_version
        versions.order("number DESC").each do |version|
                if version.published then
                        return version
                end
        end
        return nil
end
latest_version() click to toggle source
# File app/models/phase.rb, line 29
def latest_version
        return versions.order("number DESC").last
end
to_s() click to toggle source
# File app/models/phase.rb, line 25
def to_s
        "#{title}"
end