wco_models 3.1.0.91 → 3.1.0.93
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/wco/leads_controller.rb +17 -2
- data/app/models/wco/lead.rb +18 -0
- data/app/models/wco_email/message_stub.rb +4 -10
- data/app/views/wco/leads/_form.haml +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ce69cb552cc8f072d6cab730355f2680f5080773b5ba38f15cb45827c1d69ce
|
4
|
+
data.tar.gz: df88159670a5a92bade97d647c652bbd11b5d8e7a7d630b8ff4837fd878fc8d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cccea65fbae4e19a976408913ae73f9fe602019ae1ed4d1314a61b6ea3bb2a1c70333b9eb84ff39152f0a8d361c730d9922c77bdb7b60a07670f9be9ce6c282
|
7
|
+
data.tar.gz: 89592dfbb1197a866983d79573cae2d61109cf7d635a06e4b9609edb0e615108d3f8f1f2181934fdadb8ff90f11a7bc33160e35306127e111798361160c22dc0
|
@@ -8,7 +8,7 @@ class Wco::LeadsController < Wco::ApplicationController
|
|
8
8
|
params[:lead][:leadset] = nil if params[:lead][:leadset].blank?
|
9
9
|
|
10
10
|
@lead = Wco::Lead.new params[:lead].permit!
|
11
|
-
authorize! :
|
11
|
+
authorize! :create, @lead
|
12
12
|
if @lead.save
|
13
13
|
flash_notice 'ok'
|
14
14
|
else
|
@@ -17,6 +17,11 @@ class Wco::LeadsController < Wco::ApplicationController
|
|
17
17
|
redirect_to action: :index
|
18
18
|
end
|
19
19
|
|
20
|
+
def edit
|
21
|
+
authorize! :edit, Wco::Lead
|
22
|
+
@lead = Wco::Lead.find params[:id]
|
23
|
+
end
|
24
|
+
|
20
25
|
def index
|
21
26
|
authorize! :index, Wco::Lead
|
22
27
|
@leads = Wco::Lead.all
|
@@ -64,7 +69,17 @@ class Wco::LeadsController < Wco::ApplicationController
|
|
64
69
|
end
|
65
70
|
|
66
71
|
def update
|
67
|
-
params[:tags].delete ''
|
72
|
+
params[:lead][:tags].delete ''
|
73
|
+
params[:lead][:leadset] = nil if params[:lead][:leadset].blank?
|
74
|
+
|
75
|
+
@lead = Wco::Lead.new params[:lead].permit!
|
76
|
+
authorize! :update, @lead
|
77
|
+
if @lead.save
|
78
|
+
flash_notice 'ok'
|
79
|
+
else
|
80
|
+
flash_alert @lead
|
81
|
+
end
|
82
|
+
redirect_to action: :show, id: @lead.id
|
68
83
|
end
|
69
84
|
|
70
85
|
##
|
data/app/models/wco/lead.rb
CHANGED
@@ -28,6 +28,24 @@ class Wco::Lead
|
|
28
28
|
self[:email] = a
|
29
29
|
end
|
30
30
|
end
|
31
|
+
def self.normalize_email a
|
32
|
+
a = a.downcase
|
33
|
+
if a.index('+')
|
34
|
+
a.slice!( a[a.index('+')...a.index('@')] )
|
35
|
+
end
|
36
|
+
return a
|
37
|
+
end
|
38
|
+
def self.find_or_create_by_email email
|
39
|
+
email = self.normalize_email email
|
40
|
+
out = where( email: email ).first
|
41
|
+
if !out
|
42
|
+
domain = email.split('@')[1]
|
43
|
+
leadset = Wco::Leadset.where( company_url: domain ).first
|
44
|
+
leadset ||= Wco::Leadset.create( company_url: domain, email: email )
|
45
|
+
out = create!( email: email, leadset: leadset )
|
46
|
+
end
|
47
|
+
return out
|
48
|
+
end
|
31
49
|
|
32
50
|
|
33
51
|
has_one :photo, class_name: 'Wco::Photo'
|
@@ -86,17 +86,13 @@ class WcoEmail::MessageStub
|
|
86
86
|
|
87
87
|
## Leadset, Lead
|
88
88
|
from = the_mail.from ? the_mail.from[0] : "nobody@unknown-doma.in"
|
89
|
-
|
90
|
-
leadset = Wco::Leadset.where( company_url: domain.downcase ).first
|
91
|
-
leadset ||= Wco::Leadset.create( company_url: domain.downcase, email: from.downcase )
|
92
|
-
lead = Wco::Lead.find_or_create_by( email: from, leadset: leadset )
|
93
|
-
|
89
|
+
lead = Wco::Lead.find_or_create_by_email( from )
|
94
90
|
|
95
91
|
message = WcoEmail::Message.unscoped.where( message_id: message_id ).first
|
96
92
|
if message
|
97
93
|
message.message_id = "#{Time.now.strftime('%Y%m%d')}-trash-#{message.message_id}"
|
98
94
|
message.object_key = "#{Time.now.strftime('%Y%m%d')}-trash-#{message.object_key}"
|
99
|
-
message.save
|
95
|
+
message.save( validate: false )
|
100
96
|
message.delete
|
101
97
|
end
|
102
98
|
|
@@ -119,7 +115,7 @@ class WcoEmail::MessageStub
|
|
119
115
|
tos: the_mail.to,
|
120
116
|
|
121
117
|
cc: the_mail.cc ? the_mail.cc[0] : nil,
|
122
|
-
ccs:
|
118
|
+
ccs: the_mail.cc,
|
123
119
|
})
|
124
120
|
puts! @message, '@message'
|
125
121
|
|
@@ -156,9 +152,7 @@ class WcoEmail::MessageStub
|
|
156
152
|
conv.save
|
157
153
|
|
158
154
|
the_mail.cc&.each do |cc|
|
159
|
-
|
160
|
-
leadset = Wco::Leadset.find_or_create_by( company_url: domain )
|
161
|
-
Wco::Lead.find_or_create_by( email: cc, leadset: leadset )
|
155
|
+
Wco::Lead.find_or_create_by_email( cc )
|
162
156
|
end
|
163
157
|
|
164
158
|
conv.update_attributes({
|
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
.field
|
21
21
|
= f.label "Leadset (company)"
|
22
|
-
= f.select :leadset, options_for_select(@leadsets_list, selected: lead.leadset_id), { class: :select2 }
|
22
|
+
= f.select :leadset, options_for_select(@leadsets_list, selected: lead.leadset_id), {}, { class: :select2 }
|
23
23
|
|
24
24
|
-# .field
|
25
25
|
-# %label Rating
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wco_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.0.
|
4
|
+
version: 3.1.0.93
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Pudeyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|