civic311_test3 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/fonts/glyphicons-halflings-regular.eot +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.svg +288 -0
- data/app/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.woff +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.woff2 +0 -0
- data/app/assets/images/.keep +0 -0
- data/app/assets/javascripts/admin.coffee +3 -0
- data/app/assets/javascripts/application.js +17 -0
- data/app/assets/javascripts/bootstrap.js.coffee +4 -0
- data/app/assets/javascripts/custom.js +147 -0
- data/app/assets/stylesheets/admin.scss +3 -0
- data/app/assets/stylesheets/application.css +72 -0
- data/app/assets/stylesheets/bootstrap.min.css +5 -0
- data/app/assets/stylesheets/bootstrap_and_overrides.css.less +34 -0
- data/app/assets/stylesheets/rails_admin.css +69 -0
- data/app/controllers/admin_controller.rb +404 -0
- data/app/controllers/application_controller.rb +5 -0
- data/app/controllers/concerns/.keep +0 -0
- data/app/helpers/admin_helper.rb +2 -0
- data/app/helpers/application_helper.rb +16 -0
- data/app/mailers/.keep +0 -0
- data/app/models/.keep +0 -0
- data/app/models/acceptance.rb +13 -0
- data/app/models/agent.rb +270 -0
- data/app/models/agent_change_info.rb +67 -0
- data/app/models/agent_designation.rb +12 -0
- data/app/models/agent_language.rb +12 -0
- data/app/models/agent_specialty.rb +12 -0
- data/app/models/agent_ticket.rb +12 -0
- data/app/models/agent_zip_code.rb +16 -0
- data/app/models/best_use.rb +4 -0
- data/app/models/buying_wishlist.rb +33 -0
- data/app/models/concerns/.keep +0 -0
- data/app/models/connection.rb +13 -0
- data/app/models/customer.rb +76 -0
- data/app/models/customer_device.rb +248 -0
- data/app/models/customer_location_alert.rb +31 -0
- data/app/models/delayed_job.rb +6 -0
- data/app/models/designation.rb +29 -0
- data/app/models/help.rb +6 -0
- data/app/models/investing_wishlist.rb +18 -0
- data/app/models/investing_wishlist_type.rb +12 -0
- data/app/models/investment_type.rb +13 -0
- data/app/models/issue.rb +9 -0
- data/app/models/language.rb +39 -0
- data/app/models/license.rb +31 -0
- data/app/models/payment_transaction.rb +12 -0
- data/app/models/promotion_code.rb +10 -0
- data/app/models/property_type.rb +15 -0
- data/app/models/question.rb +6 -0
- data/app/models/rating.rb +13 -0
- data/app/models/rating_question.rb +28 -0
- data/app/models/rating_request.rb +8 -0
- data/app/models/renting_wishlist.rb +31 -0
- data/app/models/request_showing.rb +14 -0
- data/app/models/schema_migration.rb +6 -0
- data/app/models/selling_wishlist.rb +28 -0
- data/app/models/setting.rb +6 -0
- data/app/models/sharing.rb +15 -0
- data/app/models/specialty.rb +25 -0
- data/app/models/state.rb +21 -0
- data/app/models/suggestion.rb +10 -0
- data/app/models/user.rb +107 -0
- data/app/models/user_history.rb +6 -0
- data/app/models/wishlist.rb +17 -0
- data/app/views/admin/_form.html.erb +184 -0
- data/app/views/admin/_header.html.erb +58 -0
- data/app/views/admin/dashboard.html.erb +142 -0
- data/app/views/admin/delete.html.erb +0 -0
- data/app/views/admin/edit.html.erb +25 -0
- data/app/views/admin/export.html.erb +64 -0
- data/app/views/admin/index.html.erb +111 -0
- data/app/views/admin/new.html.erb +25 -0
- data/app/views/admin/new.js.erb +1 -0
- data/app/views/admin/show.html.erb +57 -0
- data/app/views/admin/test.html.erb +41 -0
- data/app/views/kaminari/_first_page.html.erb +11 -0
- data/app/views/kaminari/_gap.html.erb +8 -0
- data/app/views/kaminari/_last_page.html.erb +11 -0
- data/app/views/kaminari/_next_page.html.erb +11 -0
- data/app/views/kaminari/_page.html.erb +12 -0
- data/app/views/kaminari/_paginator.html.erb +23 -0
- data/app/views/kaminari/_prev_page.html.erb +11 -0
- data/app/views/layouts/_sidebar.html.erb +10 -0
- data/app/views/layouts/application.html.erb +51 -0
- data/civic311_test3-0.0.1.gem +0 -0
- data/civic311_test3.gemspec +3 -2
- data/config/application.rb +26 -0
- data/config/boot.rb +3 -0
- data/config/database.yml +54 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +41 -0
- data/config/environments/production.rb +79 -0
- data/config/environments/test.rb +42 -0
- data/config/initializers/assets.rb +11 -0
- data/config/initializers/auto_admin.rb +9 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/cookies_serializer.rb +3 -0
- data/config/initializers/filter_parameter_logging.rb +4 -0
- data/config/initializers/inflections.rb +16 -0
- data/config/initializers/mime_types.rb +4 -0
- data/config/initializers/session_store.rb +3 -0
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/en.bootstrap.yml +17 -0
- data/config/locales/en.yml +28 -0
- data/config/routes.rb +71 -0
- data/config/secrets.yml +22 -0
- data/lib/civic311_test3/version.rb +1 -1
- metadata +123 -3
@@ -0,0 +1,33 @@
|
|
1
|
+
class BuyingWishlist < ActiveRecord::Base
|
2
|
+
|
3
|
+
self.table_name = "buying_wishlists"
|
4
|
+
self.primary_key = 'id'
|
5
|
+
|
6
|
+
has_one :wishlist, foreign_key: "id"
|
7
|
+
belongs_to :property_type, :inverse_of => :buying_wishlists
|
8
|
+
|
9
|
+
def show_details
|
10
|
+
{
|
11
|
+
id: self.id,
|
12
|
+
name: self.name,
|
13
|
+
price_range_low: self.price_range_low,
|
14
|
+
price_range_high: self.price_range_high,
|
15
|
+
property_type_id: self.property_type_id,
|
16
|
+
beds_number: self.beds_number,
|
17
|
+
baths_number: self.baths_number,
|
18
|
+
square_footage_low: self.square_footage_low,
|
19
|
+
square_footage_high: self.square_footage_high,
|
20
|
+
built_year_low: self.built_year_low,
|
21
|
+
built_year_high: self.built_year_high,
|
22
|
+
lot_size: self.lot_size,
|
23
|
+
listing_type: self.listing_type.to_s.split(";").join("; "),
|
24
|
+
timeframe: self.timeframe,
|
25
|
+
condition: self.condition,
|
26
|
+
gagrage: self.gagrage,
|
27
|
+
pets: self.pets,
|
28
|
+
view: self.view,
|
29
|
+
pools: self.pools
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Connection < ActiveRecord::Base
|
2
|
+
|
3
|
+
self.table_name = "connections"
|
4
|
+
self.primary_key = 'id'
|
5
|
+
|
6
|
+
belongs_to :agent, foreign_key: "agent_id"
|
7
|
+
belongs_to :customer, foreign_key: "customer_id"
|
8
|
+
belongs_to :sharing, foreign_key: "sharing_id"
|
9
|
+
|
10
|
+
def describe_id
|
11
|
+
"Connection ##{id}"
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
class Customer < ActiveRecord::Base
|
2
|
+
|
3
|
+
self.table_name = "customers"
|
4
|
+
self.primary_key = 'id'
|
5
|
+
|
6
|
+
#reverse_geocoded_by :latitude, :longitude
|
7
|
+
# after_validation :reverse_geocode
|
8
|
+
|
9
|
+
validates :phone_number, uniqueness: true
|
10
|
+
|
11
|
+
# has_many :connections, :dependent => :delete_all
|
12
|
+
has_many :wishlists, :inverse_of => :customer
|
13
|
+
has_many :request_showings, :inverse_of => :customer
|
14
|
+
has_many :ratings, :inverse_of => :agent
|
15
|
+
belongs_to :language1, :class_name => "Language", :foreign_key => "preferred_language_id_1"
|
16
|
+
belongs_to :language2, :class_name => "Language", :foreign_key => "preferred_language_id_2"
|
17
|
+
belongs_to :user, :inverse_of => :customer
|
18
|
+
|
19
|
+
#rails_admin do
|
20
|
+
#configure :connections do
|
21
|
+
#visible(false)
|
22
|
+
#end
|
23
|
+
#end
|
24
|
+
|
25
|
+
def name
|
26
|
+
if first_name.present? && last_name.present?
|
27
|
+
"#{first_name} #{last_name}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def as_json
|
32
|
+
user = User.find_by(id: self.user_id)
|
33
|
+
{
|
34
|
+
authentication_token: user.authentication_token,
|
35
|
+
email: user.email,
|
36
|
+
customer_id: self.id,
|
37
|
+
phone_number: self.phone_number,
|
38
|
+
phone_verified: self.phone_verified,
|
39
|
+
first_name: self.first_name,
|
40
|
+
last_name: self.last_name,
|
41
|
+
inital_contact: self.inital_contact,
|
42
|
+
language_1: self.preferred_language_id_1,
|
43
|
+
language_2: self.preferred_language_id_2
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def as_json2
|
48
|
+
user = User.find_by(id: self.user_id)
|
49
|
+
{
|
50
|
+
authentication_token: user.authentication_token,
|
51
|
+
email: user.email,
|
52
|
+
customer_id: self.id,
|
53
|
+
phone_number: self.phone_number,
|
54
|
+
phone_verified: self.phone_verified,
|
55
|
+
first_name: self.first_name,
|
56
|
+
last_name: self.last_name,
|
57
|
+
inital_contact: self.inital_contact,
|
58
|
+
language_1: self.language1.try(:name),
|
59
|
+
language_2: self.language2.try(:name),
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
# Get rating information
|
64
|
+
def get_rating_information(agent_id)
|
65
|
+
ratings = Rating.where(agent_id: agent_id)
|
66
|
+
numCustomerRates = ratings.distinct.count(:customer_id)
|
67
|
+
avgAll = ratings.average('rate').to_f
|
68
|
+
avgCategory = ratings.joins(:rating_question).group('category').average('rate').map{|category, rate| {category: category, rate: rate}}
|
69
|
+
ratings = ratings.where(customer_id: self.id)
|
70
|
+
avgQuestion = ratings.group('rating_question_id').average('rate').map{|question, rate| {question: question, rate: rate}}
|
71
|
+
|
72
|
+
rating_date = ratings.joins(:rating_question).select('category, CAST(MAX(ratings.updated_at) as date) as date').group('category')
|
73
|
+
|
74
|
+
{numCustomerRates: numCustomerRates, avgAllRates: avgAll, avgCategory: avgCategory, avgQuestion: avgQuestion, rating_date: rating_date}
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,248 @@
|
|
1
|
+
class CustomerDevice < ActiveRecord::Base
|
2
|
+
|
3
|
+
self.table_name = "customer_devices"
|
4
|
+
self.primary_key = 'id'
|
5
|
+
|
6
|
+
belongs_to :user
|
7
|
+
|
8
|
+
def describe_id
|
9
|
+
"CustomerDevice ##{id}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def enpoint_arn_enable?(sns)
|
13
|
+
begin
|
14
|
+
info = sns.get_endpoint_attributes(endpoint_arn: self.endpoint_arn)
|
15
|
+
return info.attributes["Enabled"] == "true" ? true : false
|
16
|
+
rescue Exception => e
|
17
|
+
p "==========="
|
18
|
+
p e
|
19
|
+
return false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def endable_endpoint_arn(sns)
|
24
|
+
begin
|
25
|
+
sns.set_endpoint_attributes(endpoint_arn: self.endpoint_arn,attributes: {Enabled: "true"})
|
26
|
+
return true
|
27
|
+
rescue Exception => e
|
28
|
+
return false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def disable_endpoint_arn(sns)
|
33
|
+
begin
|
34
|
+
sns.set_endpoint_attributes(endpoint_arn: self.endpoint_arn,attributes: {Enabled: "false"})
|
35
|
+
return true
|
36
|
+
rescue Exception => e
|
37
|
+
return false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def remove_endpoint_arn(sns)
|
42
|
+
begin
|
43
|
+
endpoint_arn = self.endpoint_arn
|
44
|
+
self.destroy
|
45
|
+
sns.delete_endpoint(endpoint_arn: endpoint_arn)
|
46
|
+
return true
|
47
|
+
rescue Exception => e
|
48
|
+
p "======="
|
49
|
+
p e
|
50
|
+
return false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def push_notification(message_text)
|
55
|
+
sns = Aws::SNS::Client.new
|
56
|
+
|
57
|
+
enable = self.enpoint_arn_enable?(sns)
|
58
|
+
if enable
|
59
|
+
if self.device_type == "Android"
|
60
|
+
begin
|
61
|
+
p "================publish android"
|
62
|
+
gcm_message = {data: {message: message_text}}
|
63
|
+
message = {"GCM"=> gcm_message.to_json}.to_json
|
64
|
+
resp = sns.publish({
|
65
|
+
target_arn: self.endpoint_arn,
|
66
|
+
message_structure: "json",
|
67
|
+
message: message,})
|
68
|
+
rescue Exception => e
|
69
|
+
p e
|
70
|
+
end
|
71
|
+
elsif self.device_type == "iOS"
|
72
|
+
iphone_notification = {aps: {alert: message_text, sound: "default", badge: 1, extra: {a: 1, b: 2}}}
|
73
|
+
sns_message = {
|
74
|
+
default: "Hi there",
|
75
|
+
APNS_SANDBOX: iphone_notification.to_json,
|
76
|
+
APNS: iphone_notification.to_json
|
77
|
+
}
|
78
|
+
begin
|
79
|
+
resp = sns.publish({
|
80
|
+
target_arn: self.endpoint_arn,
|
81
|
+
message: sns_message.to_json,
|
82
|
+
message_structure:"json"
|
83
|
+
})
|
84
|
+
rescue Exception => e
|
85
|
+
p e
|
86
|
+
end
|
87
|
+
else
|
88
|
+
p "=====Unknown device========"
|
89
|
+
end
|
90
|
+
else
|
91
|
+
self.remove_endpoint_arn(sns)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
def push_notification_all(message_text)
|
99
|
+
sns = Aws::SNS::Client.new
|
100
|
+
|
101
|
+
enable = self.enpoint_arn_enable?(sns)
|
102
|
+
if enable
|
103
|
+
if self.device_type == "Android"
|
104
|
+
begin
|
105
|
+
p "================publish android"
|
106
|
+
gcm_message = {data: message_text}
|
107
|
+
message = {"GCM"=> gcm_message.to_json}.to_json
|
108
|
+
resp = sns.publish({
|
109
|
+
target_arn: self.endpoint_arn,
|
110
|
+
message_structure: "json",
|
111
|
+
message: message,})
|
112
|
+
rescue Exception => e
|
113
|
+
p e
|
114
|
+
end
|
115
|
+
elsif self.device_type == "iOS"
|
116
|
+
iphone_notification = message_text
|
117
|
+
sns_message = {
|
118
|
+
default: "Hi there",
|
119
|
+
APNS_SANDBOX: iphone_notification.to_json,
|
120
|
+
APNS: iphone_notification.to_json
|
121
|
+
}
|
122
|
+
begin
|
123
|
+
resp = sns.publish({
|
124
|
+
target_arn: self.endpoint_arn,
|
125
|
+
message: sns_message.to_json,
|
126
|
+
message_structure:"json"
|
127
|
+
})
|
128
|
+
rescue Exception => e
|
129
|
+
p e
|
130
|
+
end
|
131
|
+
else
|
132
|
+
p "=====Unknown device========"
|
133
|
+
end
|
134
|
+
else
|
135
|
+
self.remove_endpoint_arn(sns)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
def push_notification_change_first_last_name(status,agent_changeinfo)
|
141
|
+
iphone_notification = {}
|
142
|
+
if status == "approved"
|
143
|
+
iphone_notification[:aps] = {:alert=>{:title =>"Update basic profile",:body => "Profile was approved"}}
|
144
|
+
iphone_notification[:type] = "change_basic_info"
|
145
|
+
iphone_notification[:information] ={
|
146
|
+
result: "APPROVED",
|
147
|
+
first_name: agent_changeinfo.first_name_new,
|
148
|
+
last_name: agent_changeinfo.last_name_new
|
149
|
+
}
|
150
|
+
else
|
151
|
+
iphone_notification[:aps] = {:alert=>{:title =>"Update basic profile",:body => "Profile was rejected"}}
|
152
|
+
iphone_notification[:type] = "change_basic_info"
|
153
|
+
iphone_notification[:information] ={
|
154
|
+
result: "REJECT",
|
155
|
+
first_name: agent_changeinfo.first_name_old,
|
156
|
+
last_name: agent_changeinfo.last_name_old
|
157
|
+
}
|
158
|
+
|
159
|
+
end
|
160
|
+
push_notification_all(iphone_notification)
|
161
|
+
end
|
162
|
+
|
163
|
+
def push_notification_agent_online(agent)
|
164
|
+
iphone_notification = {}
|
165
|
+
iphone_notification[:aps] = {:alert=>{:title =>"Agent is online",:body => "Join to get new agents"}}
|
166
|
+
iphone_notification[:type] = "location_agent_online_alert"
|
167
|
+
iphone_notification[:information] ={
|
168
|
+
latitude: agent.latitude,
|
169
|
+
longitude: agent.longitude
|
170
|
+
}
|
171
|
+
|
172
|
+
push_notification_all(iphone_notification)
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
def push_notification_change_company_name(status,agent_changeinfo)
|
177
|
+
iphone_notification = {}
|
178
|
+
if status == "approved"
|
179
|
+
iphone_notification[:aps] = {:alert=>{:title =>"Update company name",:body => "Update company name was approved"}}
|
180
|
+
iphone_notification[:type] = "change_company_name"
|
181
|
+
iphone_notification[:information] ={
|
182
|
+
result: "APPROVED",
|
183
|
+
old_company_name: agent_changeinfo.company_name_old,
|
184
|
+
last_company_name: agent_changeinfo.company_name_new
|
185
|
+
}
|
186
|
+
else
|
187
|
+
iphone_notification[:aps] = {:alert=>{:title =>"Update company name",:body => "Update company name was rejected"}}
|
188
|
+
iphone_notification[:type] = "change_company_name"
|
189
|
+
iphone_notification[:information] ={
|
190
|
+
result: "REJECT",
|
191
|
+
old_company_name: agent_changeinfo.company_name_old,
|
192
|
+
last_company_name: agent_changeinfo.company_name_new
|
193
|
+
}
|
194
|
+
|
195
|
+
end
|
196
|
+
push_notification_all(iphone_notification)
|
197
|
+
end
|
198
|
+
|
199
|
+
def push_notification_change_license(status,agent)
|
200
|
+
iphone_notification = {}
|
201
|
+
if status == "approved"
|
202
|
+
iphone_notification[:aps] = {:alert=>{:title =>"License Info",:body => "License Info was approved"}}
|
203
|
+
iphone_notification[:type] = "change_license_info"
|
204
|
+
iphone_notification[:information] ={
|
205
|
+
result: "APPROVED",
|
206
|
+
license_number: agent.license_number,
|
207
|
+
state_license_issue: agent.license_state_issued,
|
208
|
+
date_license_issue: agent.license_issued_date
|
209
|
+
}
|
210
|
+
else
|
211
|
+
iphone_notification[:aps] = {:alert=>{:title =>"License Info",:body => "License Info was rejected"}}
|
212
|
+
iphone_notification[:type] = "change_license_info"
|
213
|
+
iphone_notification[:information] ={
|
214
|
+
result: "REJECT",
|
215
|
+
license_number: agent.license_number,
|
216
|
+
state_license_issue: agent.license_state_issued,
|
217
|
+
date_license_issue: agent.license_issued_date
|
218
|
+
}
|
219
|
+
|
220
|
+
end
|
221
|
+
push_notification_all(iphone_notification)
|
222
|
+
end
|
223
|
+
|
224
|
+
def push_notification_background(type,agent,customer,sharing)
|
225
|
+
iphone_notification = {}
|
226
|
+
if type == "share_wishlist"
|
227
|
+
iphone_notification[:aps] = {:alert=>{:title =>"Received a Share Wishlist ",:body => "From Customer: #{customer.name}"}}
|
228
|
+
iphone_notification[:type] = "share_wishlist"
|
229
|
+
|
230
|
+
elsif type == "showing_request"
|
231
|
+
iphone_notification[:aps] = {:alert=>{:title =>"Received a Showing Request ",:body => "From Customer: #{customer.name}"}}
|
232
|
+
iphone_notification[:type] = "showing_request"
|
233
|
+
elsif type == "showing_request_plus"
|
234
|
+
iphone_notification[:aps] = {:alert=>{:title =>"Received a Showing Request Plus ",:body => "From Customer: #{customer.name}"}}
|
235
|
+
iphone_notification[:type] = "showing_request_plus"
|
236
|
+
elsif type == "customer_picked_you"
|
237
|
+
iphone_notification[:aps] = {:alert=>{:title =>"Customer has picked you ",:body => "From Customer: #{customer.name}"}}
|
238
|
+
iphone_notification[:type] = "customer_picked_you"
|
239
|
+
|
240
|
+
end
|
241
|
+
iphone_notification[:agent_id] = agent.id
|
242
|
+
iphone_notification[:sharing_id] = sharing.id
|
243
|
+
push_notification_all(iphone_notification)
|
244
|
+
|
245
|
+
end
|
246
|
+
|
247
|
+
|
248
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class CustomerLocationAlert < ActiveRecord::Base
|
2
|
+
|
3
|
+
self.table_name = "customer_location_alerts"
|
4
|
+
self.primary_key = 'id'
|
5
|
+
|
6
|
+
#acts_as_mappable :default_units => :miles,
|
7
|
+
#:lat_column_name => :latitude,
|
8
|
+
#:lng_column_name => :longtitude
|
9
|
+
belongs_to :user
|
10
|
+
validates :longtitude, :latitude, presence: true
|
11
|
+
validate :check_slot_valid
|
12
|
+
|
13
|
+
def describe_id
|
14
|
+
"CustomerLocationAlert ##{id}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def check_slot_valid
|
18
|
+
date = DateTime.now
|
19
|
+
count_data = CustomerLocationAlert.where("time_expired > '#{date}' and user_id=#{self.user_id.to_i}").count
|
20
|
+
|
21
|
+
if count_data >= 10
|
22
|
+
self.errors.add(:base,"Too much alert")
|
23
|
+
return false
|
24
|
+
end
|
25
|
+
return true
|
26
|
+
end
|
27
|
+
|
28
|
+
before_create do
|
29
|
+
self.time_expired = Time.now + 8.hours
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Designation < ActiveRecord::Base
|
2
|
+
|
3
|
+
self.table_name = "designations"
|
4
|
+
self.primary_key = 'id'
|
5
|
+
|
6
|
+
has_many :agent_designations, :inverse_of => :designation
|
7
|
+
|
8
|
+
def name
|
9
|
+
designation
|
10
|
+
end
|
11
|
+
|
12
|
+
# Get All Designations
|
13
|
+
def self.get_all_designations
|
14
|
+
Hash[*Designation.pluck(:id, :designation).flatten]
|
15
|
+
end
|
16
|
+
|
17
|
+
# Get Agent's designations
|
18
|
+
def self.get_agent_designations(agent)
|
19
|
+
Hash[*AgentDesignation.where(agent_id: agent.id).joins(:designation).pluck(:designation_id, :designation).flatten]
|
20
|
+
end
|
21
|
+
|
22
|
+
#rails_admin do
|
23
|
+
|
24
|
+
#configure :agent_designations do
|
25
|
+
#visible(false)
|
26
|
+
#end
|
27
|
+
|
28
|
+
#end
|
29
|
+
end
|