Class: IshModels::UserProfile

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/ish_models/user_profile.rb

Constant Summary collapse

ROLES =
[ :admin, :manager, :guy ]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.listObject

manager uses it. @TODO: check this, this is shit. vp 20170527


54
55
56
57
# File 'lib/ish_models/user_profile.rb', line 54

def self.list
  out = self.all.order_by( :domain => :asc, :lang => :asc )
  [['', nil]] + out.map { |item| [ item.name, item.id ] }
end

Instance Method Details

#current_orderObject


65
66
67
# File 'lib/ish_models/user_profile.rb', line 65

def current_order
  self.orders.where( :submitted_at => nil ).first || CoTailors::Order.create( :profile => self )
end

#has_premium_purchase(item) ⇒ Object


74
75
76
# File 'lib/ish_models/user_profile.rb', line 74

def has_premium_purchase item
  item.premium_purchases.where( user_profile: self ).exists?
end

#sudoer?Boolean

Returns:

  • (Boolean)

48
49
50
# File 'lib/ish_models/user_profile.rb', line 48

def sudoer?
  %w( [email protected] [email protected] ).include?( self.user.email ) ? true : false
end