Class: Staff
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Staff
- Defined in:
- app/models/staff.rb
Class Method Summary collapse
- .field_roles ⇒ Object
- .get_roles(region) ⇒ Object
- .get_staff(ssm_id) ⇒ Object
- .staff_positions ⇒ Object
- .strategies ⇒ Object
- .strategy_order ⇒ Object
Instance Method Summary collapse
- #email ⇒ Object
-
#full_name ⇒ Object
“first_name last_name”.
- #informal_full_name ⇒ Object
- #is_active? ⇒ Boolean
- #is_director? ⇒ Boolean
- #is_hr? ⇒ Boolean
- #is_hr_director? ⇒ Boolean
- #is_removed? ⇒ Boolean
- #nickname ⇒ Object
Class Method Details
.field_roles ⇒ Object
18 19 20 |
# File 'app/models/staff.rb', line 18 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
76 77 78 79 80 81 82 |
# File 'app/models/staff.rb', line 76 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
8 9 10 11 12 13 14 15 16 |
# File 'app/models/staff.rb', line 8 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) account_no = profile.accountNo staff = Staff.find_by(accountNo: account_no) end |
.staff_positions ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/models/staff.rb', line 49 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 |
.strategies ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/models/staff.rb', line 26 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_order ⇒ Object
22 23 24 |
# File 'app/models/staff.rb', line 22 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
#email ⇒ Object
84 85 86 |
# File 'app/models/staff.rb', line 84 def email self[:email].present? ? self[:email] : self.person.try(:email) end |
#full_name ⇒ Object
“first_name last_name”
89 90 91 |
# File 'app/models/staff.rb', line 89 def full_name firstName.to_s + " " + lastName.to_s end |
#informal_full_name ⇒ Object
93 94 95 |
# File 'app/models/staff.rb', line 93 def informal_full_name nickname.to_s + " " + lastName.to_s end |
#is_active? ⇒ Boolean
101 102 103 |
# File 'app/models/staff.rb', line 101 def is_active? removedFromPeopleSoft != "Y" end |
#is_director? ⇒ Boolean
109 110 111 |
# File 'app/models/staff.rb', line 109 def is_director? jobTitle && jobTitle.include?("Director") end |
#is_hr? ⇒ Boolean
105 106 107 |
# File 'app/models/staff.rb', line 105 def is_hr? strategy == "HR" || strategy == "LD" end |
#is_hr_director? ⇒ Boolean
113 114 115 |
# File 'app/models/staff.rb', line 113 def is_hr_director? jobTitle && jobTitle.include?("Director (HR)") end |
#is_removed? ⇒ Boolean
117 118 119 |
# File 'app/models/staff.rb', line 117 def is_removed? removedFromPeopleSoft == "Y" ? true : false end |
#nickname ⇒ Object
97 98 99 |
# File 'app/models/staff.rb', line 97 def nickname (!preferred_name.to_s.strip.empty?) ? preferred_name : firstName end |