returns an array with all funders and own institutional templates
# File app/models/dmptemplate.rb, line 63 def self.funders_and_own_templates(org_id) funders_templates = self.funders_templates #verify if org type is not a funder current_org = Organisation.find(org_id) if current_org.organisation_type.name != I18n.t("helpers.org_type.funder") then own_institutional_templates = self.own_institutional_templates(org_id) else own_institutional_templates = [] end templates_list = Array.new templates_list += own_institutional_templates templates_list += funders_templates templates_list = templates_list.sort_by { |f| f['title'].downcase } return templates_list end
returns all funders templates
# File app/models/dmptemplate.rb, line 44 def self.funders_templates new_org_obejcts = OrganisationType.find_by_name(I18n.t("helpers.org_type.funder")).organisations org_templates = Array.new new_org_obejcts.each do |neworg| org_templates += neworg.dmptemplates end return org_templates end
returns all institutional templates bellowing to the current user's org
# File app/models/dmptemplate.rb, line 57 def self.own_institutional_templates(org_id) new_templates = self.where("organisation_id = ?", org_id) return new_templates end
# File app/models/dmptemplate.rb, line 32 def self.templates_org_type(ot) new_org_obejcts = OrganisationType.find_by_name(ot).organisations org_templates = Array.new new_org_obejcts.each do |neworg| org_templates += neworg.dmptemplates.where("published = ?", true) end return org_templates end
verify if a template has customisation by current user's org
# File app/models/dmptemplate.rb, line 88 def has_customisations?(org_id, temp) if temp.organisation_id != org_id then temp.phases.each do |phase| phase.versions.each do |version| version.sections.each do |section| return true if section.organisation_id == org_id end end return false end else return false end end
verify if there are any publish version for the template
# File app/models/dmptemplate.rb, line 106 def has_published_versions? phases.each do |phase| return true if !phase.latest_published_version.nil? end return false end
# File app/models/dmptemplate.rb, line 82 def org_type org_type = organisation.organisation_type.name return org_type end
# File app/models/dmptemplate.rb, line 28 def to_s "#{title}" end