Class: Staff

Inherits:
ApplicationRecord show all
Defined in:
app/models/staff.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.field_rolesObject



20
21
22
# File 'app/models/staff.rb', line 20

def self.field_roles
  @@field_roles ||= ['Director (Direct Ministry)','Team Leader (Direct Ministry)','Team Member - Mom','Field Staff In Training','Raising Support Full Time','Seminary Staff','Field Staff','Local Leader']
end

.get_roles(region) ⇒ Object



78
79
80
81
82
83
84
# File 'app/models/staff.rb', line 78

def self.get_roles(region)
  result = {}
  Staff.strategy_order.each do |strategy|
    result[strategy] = specialty_roles.where(strategy: strategy).where(region: region)
  end
  result
end

.get_staff(ssm_id) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'app/models/staff.rb', line 10

def self.get_staff(ssm_id)
  if ssm_id.nil? then raise "nil ssm_id!" end
  ssm_user = User.find_by(userID: ssm_id)
  if ssm_user.nil? then raise "ssm_id doesn't exist: #{ssm_id}" end
  username = ssm_user.username
  profile = StaffsiteProfile.find_by(userName: username)
   = profile.accountNo
  staff = Staff.find_by(accountNo: )
end

.staff_positionsObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/models/staff.rb', line 51

def self.staff_positions
  @@staff_positions ||= [
    "Associate Staff",
    "Staff Full Time",
    "Hourly Full Time",
    "Hourly on Call",
    "Salaried Exempt Full Time",
    "Salaried w Desig #",
    "Self-Supported Staff",
    "Staff on Delayed Payroll",
    "Staff on Paid Leave",
    "Staff on Unpaid Leave",
    "Staff Raising Init Supprt",
    "Affiliate",
    "Volunteer Full Time",
    "Volunteer Part Time",
    "Ministry Intern A",
    "Ministry Intern A Part Time",
    "Ministry Intern Hourly Part Tm",
    "STINT Full Time",
    "Staff Part Time"
  ]
end

.strategiesObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/staff.rb', line 28

def self.strategies
  @@strategies ||= {
    'National Director' => 'National Director',
    'Operations' => 'Operations',
    'HR' => 'Leadership Development',
    'LD' => 'Leadership Development',
    'Fund Dev' => 'Fund Development',
    'CFM' => 'Campus Field Ministry',
    'FLD' => 'Campus Field Ministry',
    'SV' =>  'Cru High School',
    'EFM' => 'Ethnic Field Ministry',
    'DES' => 'Destino',
    'EPI' => 'Epic',
    'ESS' => 'Every Student Sent',
    'NTN' => 'Nations',
    'BRD' => 'Bridges',
    'WSN' => 'Global Missions',
    'GLM' => 'Global Missions',
    'R&D' => 'Research and Development',
    'LHS' => 'Lake Hart Stint'
  }
end

.strategy_orderObject



24
25
26
# File 'app/models/staff.rb', line 24

def self.strategy_order
  @@strategy_order ||= ['National Director','Operations','HR','LD','Fund Dev','CFM','FLD','EFM','DES','EPI','ESS','NTN','BRD','WSN','GLM','R&D','SR','SV','SSS','JPO','LHS','']
end

Instance Method Details

#emailObject



86
87
88
# File 'app/models/staff.rb', line 86

def email
  self[:email].present? ? self[:email] : self.person.try(:email)
end

#full_nameObject

“first_name last_name”



91
92
93
# File 'app/models/staff.rb', line 91

def full_name
  firstName.to_s  + " " + lastName.to_s
end

#informal_full_nameObject



95
96
97
# File 'app/models/staff.rb', line 95

def informal_full_name
  nickname.to_s  + " " + lastName.to_s
end

#is_active?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'app/models/staff.rb', line 103

def is_active?
  removedFromPeopleSoft != "Y"
end

#is_director?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'app/models/staff.rb', line 111

def is_director?
  jobTitle && jobTitle.include?("Director")
end

#is_hr?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'app/models/staff.rb', line 107

def is_hr?
  strategy == "HR" || strategy == "LD"
end

#is_hr_director?Boolean

Returns:

  • (Boolean)


115
116
117
# File 'app/models/staff.rb', line 115

def is_hr_director?
  jobTitle && jobTitle.include?("Director (HR)")
end

#is_removed?Boolean

Returns:

  • (Boolean)


119
120
121
# File 'app/models/staff.rb', line 119

def is_removed?
  removedFromPeopleSoft == "Y" ? true : false
end

#nicknameObject



99
100
101
# File 'app/models/staff.rb', line 99

def nickname
  (!preferred_name.to_s.strip.empty?) ? preferred_name : firstName
end