class Department

Constants

CATEGORIES
LABEL_TYPES

Public Class Methods

first_or_create_by_hr_title(hr_title) click to toggle source

This should match by hr_title or title or create a new department

# File lib/buweb/department.rb, line 90
def self.first_or_create_by_hr_title(hr_title)
  best_match = Department.where(hr_title: hr_title).first
  ok_match = Department.where(title: hr_title).first
  if best_match || ok_match
    best_match ? best_match : ok_match.update_attributes(hr_title: hr_title) # TODO: make this more readable and isolate responsibilities
  else
    Department.create!(title: hr_title, hr_title: hr_title) # will throw an error if this fails
  end
end

Public Instance Methods

aliases_string() click to toggle source
# File lib/buweb/department.rb, line 100
def aliases_string
  self.aliases.join('| ') if aliases.present?
end
aliases_string=(string) click to toggle source

TODO: Adam wants this changed to be in the controllers

# File lib/buweb/department.rb, line 105
def aliases_string=(string)
  self.aliases = string.to_s.split('|').map(&:strip)
end
as_indexed_json(*) click to toggle source
# File lib/buweb/department.rb, line 109
def as_indexed_json(*)
  {
    slug: slug,
    title: title,
    title_edge: title,
    aliases: aliases,
    description: description,
    location: location,
    location_details: location_details,
    website: website,
    phone: full_biola_phone_number,
    email: email,
    fax: fax,
    categories: categories,
    normalized_data: {
      title: title,
      subtitles: [],
      short_description: short_description,
      location: location,
      image_url: nil,
      phone: full_biola_phone_number,
      alternate_phone: nil,
      published: published,
      email: email,
      page_url: page_url
    },
    is_public: is_public?  # if this was false it would be hidden from unauthenticated users.
  }
end
dependent_indexes() click to toggle source
# File lib/buweb/department.rb, line 153
def dependent_indexes
  [:people, :events]
end
dont_index?() click to toggle source
# File lib/buweb/department.rb, line 157
def dont_index?
  !published
end
is_public?() click to toggle source
# File lib/buweb/department.rb, line 161
def is_public?
  true
end
people() click to toggle source
# File lib/buweb/department.rb, line 81
def people
  memberships.map(&:person)
end
set_slug() click to toggle source

sets slug from title

# File lib/buweb/department.rb, line 166
def set_slug
  self.slug = title.parameterize if title?
end
to_s() click to toggle source
# File lib/buweb/department.rb, line 85
def to_s
  title
end