portal-template/app/models/portal_setting.rb

24 lines
634 B
Ruby

class PortalSetting
include Mongoid::Document
include Mongoid::Timestamps
field :offerer_role, :type => BSON::ObjectId
field :applicant_role, :type => BSON::ObjectId
def self.get_offerer_role
ps = self.first
return Role.find(ps.offerer_role).title rescue nil
end
def self.get_applicant_role
ps = self.first
return Role.find(ps.applicant_role).title rescue nil
end
def self.get_member_type(member)
member_roles = member.roles.pluck(:id)
return "offerer" if member_roles.include?(self.first.offerer_role)
return "applicant" if member_roles.include?(self.first.applicant_role)
end
end