Sha256: 8a1139527ef66553795eb0ea8f6fe2d3c65a510840adbb59ef6e1c68df8bfd7d
Contents?: true
Size: 1.48 KB
Versions: 17
Compression:
Stored size: 1.48 KB
Contents
class User < ActiveRecord::Base model_stamper stampable acts_as_authentic do |c| c.transition_from_restful_authentication = true c.logged_in_timeout = Alchemy::Config.get(:auto_logout_time).minutes end has_many :folded_pages before_destroy :unlock_pages scope :admins, where(:role => 'admin') ROLES = Alchemy::Config.get(:user_roles) def role_symbols [role.to_sym] end def is_admin? true if self.role == "admin" end alias :admin? :is_admin? def unlock_pages for page in pages_locked_by_me page.unlock end end def pages_locked_by_me Page.where(:locked => true).where(:locked_by => self.id).order(:updated_at) end # Returns the firstname and lastname as a string # If both are blank, returns the login # options # :flipped=false : returns "lastname, firstname" def fullname(options = {}) unless(self.lastname.blank? && self.firstname.blank?) options = (default_options = { :flipped => false }.merge(options)) options[:flipped] ? "#{self.lastname}, #{self.firstname}".squeeze(" ") : "#{self.firstname} #{self.lastname}".squeeze(" ") else self.login end end alias :name :fullname def self.human_rolename(role) I18n.t("alchemy.user_roles.#{role}") end def self.genders_for_select [ [_('male'), 'male'], [_('female'), 'female'] ] end def self.all_online User.logged_in end def self.all_others_online User.logged_in.to_a.delete(self) end end
Version data entries
17 entries across 17 versions & 1 rubygems