Class: Ish::UserProfile
Overview
It explicitly doesn’t have a relation to user! Use email as key.
Constant Summary
collapse
- ROLE_GUY =
:guy
- ROLE_MANAGER =
:manager
- ROLE_ADMIN =
:admin
- ROLES =
[ :guy, :manager, :admin ]
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Utils
#export
#unvote, #vote, #vote_value, #voted?, #votees
Class Method Details
.generate(delta) ⇒ Object
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/ish/user_profile.rb', line 115
def self.generate delta
email = delta[:email]
password = delta[:password]
role_name = delta[:role_name]
profile = Ish::UserProfile.where( email: email ).first
if profile
return
end
user = User.where( email: email ).first
if !user
user = User.new({ email: email, password: password })
end
profile = Ish::UserProfile.new({
email: email,
role_name: role_name,
})
profile.save
if profile.persisted?
;
else
puts! profile.errors.full_messages, "Cannot save profile"
end
end
|
.list ⇒ Object
76
77
78
79
|
# File 'lib/ish/user_profile.rb', line 76
def self.list
out = self.all
[['', nil]] + out.map { |item| [ item.email, item.id ] }
end
|
.list_lg ⇒ Object
80
81
82
83
|
# File 'lib/ish/user_profile.rb', line 80
def self.list_lg
out = self.all
[['', nil]] + out.map { |item| [ "#{item.email} :: #{item.name}", item.id ] }
end
|
Instance Method Details
#customer_id ⇒ Object
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/ish/user_profile.rb', line 98
def customer_id
if !self[:customer_id]
existing = Stripe::Customer.search({ query: "email: '#{email}'" })
if existing.data.present?
update_attributes( customer_id: existing.data[0][:id] )
else
customer = Stripe::Customer.create({ email: email })
update_attributes( customer_id: customer[:id] )
end
end
self[:customer_id]
end
|
#export_fields ⇒ Object
22
23
24
25
26
27
|
# File 'lib/ish/user_profile.rb', line 22
def export_fields
%w|
email
role_name
|
end
|
#has_premium_purchase(item) ⇒ Object
90
91
92
|
# File 'lib/ish/user_profile.rb', line 90
def has_premium_purchase item
payments.confirmed.where( item: item ).exists?
end
|
#next_serverhost ⇒ Object
def leadset
::Leadset.find( leadset_id )
end @TODO: change vp 2023-08-21
45
46
47
|
# File 'lib/ish/user_profile.rb', line 45
def next_serverhost
Wco::Serverhost.where({ leadset_id: leadset_id }).first
end
|
#organization_name ⇒ Object
37
38
39
40
|
# File 'lib/ish/user_profile.rb', line 37
def organization_name
'Some Org'
end
|