ish_manager 0.1.8.359 → 0.1.8.360

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2778aa5b7359b1b33f407a45debe6bffbe84cb5edcea5c7cc0b1c85a0dbe5873
4
- data.tar.gz: 6af555152d1c559d8d62e5e61f5501c1e73eec828e2caa88a5876141c6b0245b
3
+ metadata.gz: 211e20f4c15dfe93f4b66d0fe4e75be2409651310f4603d3c51da3f8b31e5f34
4
+ data.tar.gz: 3d407d3048a28347545d1912678ec1107596b1ab95fc902cdadbc38f9085b71b
5
5
  SHA512:
6
- metadata.gz: 70bd2b64afefd8c45d464e6923efde3944fe34fa7748ec1171daee589b03258b0da1ec4d803b2ffc44587e205b5a767d2b22983f6c75a1a3514cf646b0cbe625
7
- data.tar.gz: a0655a973ab4db92bd1c9e1d0e503aad062c2db7212f7755e46a2fd06066957567307dee17446289cc83c8b7d0e7a1da81b9f7cca56a495f184ba4e1b4167e2a
6
+ metadata.gz: 686449e01136c9fbfaefe4e4a1eb890cae44365ea28a9535d61499b56942ca67f8925f8fbf26472104ef91ba0a8b65ec38d14240d66d9c577567b77672725cde
7
+ data.tar.gz: 75e6666c2a18069b36dbe8bb14ca0d62fb77f3d9845cf59adf4b37f908ef6e6dd25fcc73c10df0bfc6fd31dc4ad9142155e7d0cac84ae826a5c2c8255cf70fd0
@@ -9,8 +9,8 @@ class ::IshManager::LeadsController < IshManager::ApplicationController
9
9
 
10
10
  def bulkop
11
11
  authorize! :bulkop, ::Lead
12
- case params[:a]
13
- when 'add_to_campaign'
12
+ case params[:op]
13
+ when Lead::OP_ADD_TO_CAMPAIGN
14
14
  c = EmailCampaign.find params[:email_campaign_id]
15
15
  params[:lead_ids].each do |lead_id|
16
16
  c_lead = EmailCampaignLead.new( lead_id: lead_id, email_campaign_id: c.id )
@@ -21,6 +21,19 @@ class ::IshManager::LeadsController < IshManager::ApplicationController
21
21
  end
22
22
  flash[:notice] = 'Done acted; See logs.'
23
23
  redirect_to action: :index
24
+
25
+ when Lead::OP_DELETE
26
+ outs = []
27
+ params[:lead_ids].each do |lead_id|
28
+ lead = Lead.find( lead_id )
29
+ outs.push lead.discard
30
+ end
31
+ flash[:notice] = "Outcomes: #{outs.inspect}."
32
+ redirect_to action: :index
33
+
34
+ else
35
+ throw "Unknown op: #{params[:op]}."
36
+
24
37
  end
25
38
  end
26
39
 
@@ -40,38 +53,48 @@ class ::IshManager::LeadsController < IshManager::ApplicationController
40
53
  authorize! :edit, @lead
41
54
  end
42
55
 
43
- ## 0 1 2 3 4 5 6 7 8
44
- ## fields: id, date, name, email, company url, source tag, phone, linkedin, comment
56
+ ## 0 1 2 3 4 5 6 7
57
+ ## Fields: id, date, name, email, tag, phone, linkedin, comment
45
58
  def import
46
59
  authorize! :import, ::Lead
47
- file = params[:csv_file]
48
- flags = []
60
+ file = params[:csv_file]
61
+ flags = []
49
62
  errors = []
50
63
  CSV.read(file.path, headers: true).each do |row|
51
- company_url = row[4].presence
52
- company_url ||= "https://#{row[3].split('@')[1]}"
53
- company = ::Leadset.find_or_create_by({ company_url: company_url })
64
+
65
+ leadset = ::Leadset.find_or_create_by({ company_url: row[3].split('@')[1] })
54
66
  lead = ::Lead.new({
55
- name: row[2] || 'there',
56
- full_name: row[2] || 'there',
67
+ name: row[2].presence || row[3].split('@')[0],
68
+ full_name: row[2].presence || row[3].split('@')[0],
57
69
  email: row[3],
58
- m3_leadset_id: company.id,
59
- phone: row[6],
70
+ m3_leadset_id: leadset.id,
71
+ phone: row[5],
60
72
  })
61
73
  flag = lead.save
62
74
  flags << flag
63
75
  if !flag
64
76
  errors << lead.errors.full_messages.join(", ")
65
77
  end
78
+
79
+ if row[4].present?
80
+ tags = row[4].split(",").map do |tag_name|
81
+ WpTag.my_find_or_create({ name: tag_name })
82
+ end
83
+ puts! tags, 'tags'
84
+ tags.each do |tag|
85
+ LeadTag.create({ wp_tag: tag, lead: lead })
86
+ end
87
+ end
88
+
66
89
  end
67
- flash[:notice] = "Result: #{flags.inspect} ."
90
+ flash[:notice] = "Result: #{flags.inspect}."
68
91
  flash[:alert] = errors
69
92
  redirect_to action: 'new'
70
93
  end
71
94
 
72
95
  def index
73
96
  authorize! :index, ::Lead
74
- @leads = ::Lead.all # .includes( :leadset, :email_campaign_leads )
97
+ @leads = ::Lead.kept.includes( :company )
75
98
  lead_emails = @leads.map( &:email ).compact.reject(&:empty?)
76
99
 
77
100
  map = %Q{
@@ -2,18 +2,10 @@
2
2
  = form_tag leads_import_path, multipart: true do
3
3
  .doc
4
4
  %ul
5
- %li v1 fields: id, date, name, email, company url, source tag, phone, linkedin, comment
5
+ %li Fields: id, date, name, email, tag, phone, linkedin, comment
6
6
  .field
7
7
  %label File
8
8
  = file_field_tag :csv_file
9
9
 
10
- -# .field
11
- -# %label Leadset
12
- -# = select_tag :leadset_id, options_for_select(@leadsets_list), class: 'select2'
13
-
14
- -# .field
15
- -# %label Campaign
16
- -# = select_tag :email_campaign_id, options_for_select(@email_campaigns_list), class: 'select2'
17
-
18
10
  .actions
19
11
  = submit_tag 'Submit'
@@ -2,12 +2,12 @@
2
2
  .leads-index
3
3
  .header
4
4
  %h2.title
5
- #{link_to 'Leads', leads_path} (#{::Lead.all.count})
5
+ #{link_to 'Kept Leads', leads_path} (#{::Lead.kept.count}, #{::Lead.all.count})
6
6
  = link_to raw("<i class='fa fa-plus-square'></i>"), new_lead_path
7
7
 
8
8
  = form_tag leads_bulkop_path do
9
9
  = label_tag 'Act on Selected:'
10
- = select_tag :a, options_for_select( %w| delete add_to_campaign | )
10
+ = select_tag :op, options_for_select( [[nil,nil]] + Lead::OPS )
11
11
  -# = select_tag :email_campaign_id, options_for_select( @email_campaigns_list )
12
12
  = submit_tag 'Go'
13
13
 
@@ -27,7 +27,7 @@
27
27
  %tr
28
28
  %td= check_box_tag 'lead_ids[]', lead.id
29
29
  %td= link_to "#{lead.name} <#{lead.email}>", lead_path( lead )
30
- %td= lead.leadsets.first&.name
30
+ %td= lead.company.company_url
31
31
  %td= lead.wp_tags.map(&:name).join(", ")
32
32
  %td= lead.created_at.to_s[0..10]
33
33
  %td #{lead.email_campaign_leads.count || '-'}, #{@email_contexts[lead.email] || '-'}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8.359
4
+ version: 0.1.8.360
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox