wco_models 3.1.0.164 → 3.1.0.165

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: 2c87e9885f96f8af28fb6dfe8b42737feebd4ea51fe9930a1644aabb6b3cb13b
4
- data.tar.gz: addac291921ea6de9403cc874433454bca207c10873e440c9e32c130801fd917
3
+ metadata.gz: d059af3c4e01c289a5ba3b64d0c0386bc80e10b08130757803241ba632a6939f
4
+ data.tar.gz: fbbbdf08c1c68e2353084bfc58fcde7fe347965661608e6e380aa2c6f6fffd17
5
5
  SHA512:
6
- metadata.gz: 7f82577f7d2deec1559c9680a9ca112297f2707b9eb67dfb6e21d619fa56d9aedab23c6f14b2681e78d06e50ad4585c268217d0a0bd8088acf253c46facc0594
7
- data.tar.gz: e7649c671c0071be4e81ef15d0f67a2bdf70d6cbda15d8928f08fdc190fbf78376734df98d8b30314f95e90e28c27c51e4f6ead4b94ac1198b3ef23859a735ae
6
+ metadata.gz: 45fd16609314de919c87614096d413ed3747f6869a31ce5fb663a339acd19f3255def7a9e944670889e7e1f86f59ec9974eece881a854b0cf46455e6445232b6
7
+ data.tar.gz: 65794d13831944bde63214fb38c5187b3b4a548dda37afab193d1e33c404bae36275c67a0e02d75dc46cf5a1d88d8d4b89cd70476f287af617fc5cc76ab02624
@@ -0,0 +1,13 @@
1
+
2
+ .Leads {
3
+ border: 1px solid var(--wco-color-2);
4
+ border-radius: .5em;
5
+ padding: 0.5em;
6
+ }
7
+
8
+
9
+ .Leadsets {
10
+ border: 1px solid var(--wco-color-2);
11
+ border-radius: .5em;
12
+ padding: 0.5em;
13
+ }
@@ -0,0 +1,7 @@
1
+
2
+ .office-actions--actions {
3
+ h5 {
4
+ font-size: 1em;
5
+ padding-right: 0.5em;
6
+ }
7
+ }
@@ -194,6 +194,10 @@ textarea.monospace {
194
194
 
195
195
  /* R */
196
196
 
197
+ .red {
198
+ color: red;
199
+ }
200
+
197
201
  label.required {
198
202
  &:after {
199
203
  content: ' *';
@@ -22,6 +22,14 @@ class Wco::OfficeActionTemplatesController < Wco::ApplicationController
22
22
  authorize! :new, @oat
23
23
  end
24
24
 
25
+ def perform
26
+ @oat = OAT.find params[:id]
27
+ authorize! :run, @oat
28
+ @conversations = WcoEmail::Conversation.find( params[:conversation_ids] )
29
+ out = eval( @oat.action_exe )
30
+ flash_notice out
31
+ end
32
+
25
33
  def show
26
34
  @oat = OAT.find params[:id]
27
35
  authorize! :show, @oat
@@ -0,0 +1,25 @@
1
+
2
+ class Wco::SitemapPathsController < Wco::ApplicationController
3
+
4
+ def edit
5
+ @spath = Wco::SitemapPath.find params[:id]
6
+ authorize! :edit, @spath
7
+ end
8
+
9
+ def update
10
+ @spath = Wco::SitemapPath.find params[:id]
11
+ authorize! :update, @spath
12
+ flag = @spath.update params[:sitemap_path].permit!
13
+ if flag
14
+ flash_notice 'Success'
15
+ redirect_to site_path(@spath.site)
16
+ else
17
+ flash_alert 'No luck.'
18
+ render action: 'edit'
19
+ end
20
+
21
+ end
22
+
23
+
24
+ end
25
+
@@ -4,8 +4,11 @@ class Wco::SitesController < Wco::ApplicationController
4
4
  def check_sitemap
5
5
  @site = Wco::Site.find params[:id]
6
6
  authorize! :check_sitemap, @site
7
- @site.check_sitemap
8
- redirect_to request.referrer
7
+ out = @site.check_sitemap
8
+ @results = out[:results]
9
+ @total_count = out[:total_count]
10
+ @error_count = out[:error_count]
11
+ # redirect_to request.referrer
9
12
  end
10
13
 
11
14
  def create
@@ -12,6 +12,20 @@ class Wco::Leadset
12
12
  def normalize_company_url
13
13
  company_url.downcase!
14
14
  end
15
+ def domain; company_url; end # for anti-spam
16
+ def self.from_email email
17
+ _domain = email.split('@')[1]
18
+ words = _domain.split('.')
19
+ if %w| com net gov org |.include?( words[-2] )
20
+ words = words[-3, 3]
21
+ else
22
+ words = words[-2, 2]
23
+ end
24
+ _domain = words.join('.')
25
+ find_or_create_by( company_url: _domain )
26
+ end
27
+
28
+
15
29
 
16
30
  field :email
17
31
  index({ email: 1 }, { name: 'email' })
@@ -20,6 +34,7 @@ class Wco::Leadset
20
34
 
21
35
  has_many :appliances, class_name: '::WcoHosting::Appliance', inverse_of: :leadset
22
36
  has_many :appliance_tmpl_prices, class_name: 'Wco::Price'
37
+
23
38
  has_many :environments, class_name: '::WcoHosting::Environment', inverse_of: :leadset
24
39
  has_many :invoices, class_name: 'Wco::Invoice'
25
40
  has_many :leads, class_name: 'Wco::Lead'
@@ -27,7 +42,10 @@ class Wco::Leadset
27
42
 
28
43
  has_many :profiles, class_name: 'Wco::Profile', inverse_of: :leadset
29
44
  has_many :subscriptions, class_name: 'Wco::Subscription', inverse_of: :leadset
30
- has_and_belongs_to_many :tags, class_name: 'Wco::Tag'
45
+ has_and_belongs_to_many :conversations, class_name: '::WcoEmail::Conversation', index: true
46
+ def convs; conversations; end
47
+ has_and_belongs_to_many :tags, class_name: 'Wco::Tag'
48
+ has_and_belongs_to_many :email_filters, class_name: 'WcoEmail::EmailFilter'
31
49
 
32
50
 
33
51
  field :next_invoice_number, type: :integer, default: 100
@@ -105,19 +105,19 @@ class Wco::Site
105
105
  end
106
106
 
107
107
  def check_sitemap
108
- results = []
109
- total_count = 0
110
- error_count = 0
108
+ @results = []
109
+ @total_count = 0
110
+ @error_count = 0
111
111
 
112
112
  sitemap_paths.each do |check|
113
- total_count += 1
113
+ @total_count += 1
114
114
 
115
- # puts "Checking #{check[:path]}:"
116
- if check[:selector]
115
+ puts "Checking #{check[:path]}:"
116
+ if check[:selector].present?
117
117
  begin
118
118
  body = HTTParty.get( "#{origin}#{check[:path]}" ).body
119
119
  rescue OpenSSL::SSL::SSLError => err
120
- results.push "NOT OK [ssl-exception] #{check[:path]}".red
120
+ @results.push "NOT OK [ssl-exception] #{check[:path]}".red
121
121
  logg "NOT OK [ssl-exception] #{check[:path]}"
122
122
  check.update status: 'NOT OK'
123
123
 
@@ -126,71 +126,71 @@ class Wco::Site
126
126
  doc = Nokogiri::HTML( body )
127
127
  out = doc.search check[:selector]
128
128
  if out.present?
129
- results.push "OK #{check[:path]}"
129
+ @results.push "OK #{check[:path]}"
130
130
  logg "OK #{check[:path]}"
131
131
  check.update status: 'OK'
132
132
  else
133
- results.push "NOT OK [selector-missing] #{check[:path]}".red
133
+ @results.push "NOT OK [selector-missing] #{check[:path]}".red
134
134
  logg "NOT OK [selector-missing] #{check[:path]}"
135
135
  check.update status: 'NOT OK'
136
- error_count += 1
136
+ @error_count += 1
137
137
  end
138
138
 
139
139
  if check[:meta_description]
140
140
  out = doc.search( 'head meta[name="description"]' )[0]['content']
141
141
  if check[:meta_description] == out
142
- results.push "OK #{check[:path]} meta_description"
142
+ @results.push "OK #{check[:path]} meta_description"
143
143
  logg "OK #{check[:path]} meta_description"
144
144
  check.update status: 'OK'
145
145
  else
146
- results.push "NOT OK [meta-description-missing] #{check[:path]}".red
146
+ @results.push "NOT OK [meta-description-missing] #{check[:path]}".red
147
147
  logg "NOT OK [meta-description-missing] #{check[:path]}"
148
148
  check.update status: 'NOT OK'
149
- error_count += 1
149
+ @error_count += 1
150
150
  end
151
151
  end
152
152
 
153
- elsif check[:redirect_to]
153
+ elsif check[:redirect_to].present?
154
154
  out = HTTParty.get( "#{origin}#{check[:path]}", follow_redirects: false )
155
155
  if( out.headers[:location] == check[:redirect_to] ||
156
156
  out.headers[:location] == "#{origin}#{check[:redirect_to]}" )
157
- results.push "OK #{check[:path]}"
157
+ @results.push "OK #{check[:path]}"
158
158
  logg "OK #{check[:path]}"
159
159
  check.update status: 'OK'
160
160
  else
161
- results.push "NOT OK [redirect-missing] #{check[:path]}".red
161
+ @results.push "NOT OK [redirect-missing] #{check[:path]}".red
162
162
  logg "NOT OK [redirect-missing] #{check[:path]}"
163
163
  check.update status: 'NOT OK'
164
164
 
165
165
  puts!( out.response, 'response' ) if DEBUG
166
166
  # puts!( out.body, 'body' ) if DEBUG
167
167
 
168
- error_count += 1
168
+ @error_count += 1
169
169
 
170
170
  puts "NOT OK #{check[:path]}".red
171
171
  puts out.headers[:location]
172
172
  puts check[:redirect_to]
173
173
  end
174
174
  else
175
- results.push "SKIP #{check[:path]}"
175
+ @results.push "SKIP #{check[:path]}"
176
176
  logg "SKIP #{check[:path]}"
177
177
  check.update status: 'SKIP'
178
178
  end
179
179
 
180
- if check[:selectors]
180
+ if check[:selectors]&[0]
181
181
  check[:selectors].each do |selector|
182
182
  body = HTTParty.get( "#{origin}#{check[:path]}" ).body
183
183
  doc = Nokogiri::HTML( body )
184
184
  out = doc.search selector
185
185
  if out.present?
186
- results.push "OK #{check[:path]} selectors:#{selector}"
186
+ @results.push "OK #{check[:path]} selectors:#{selector}"
187
187
  logg "OK #{check[:path]} selectors:#{selector}"
188
188
  check.update status: 'OK'
189
189
  else
190
- results.push "NOT OK [selectors-missing:#{selector}] #{check[:path]}".red
190
+ @results.push "NOT OK [selectors-missing:#{selector}] #{check[:path]}".red
191
191
  logg "NOT OK [selectors-missing:#{selector}] #{check[:path]}"
192
192
  check.update status: 'NOT OK'
193
- error_count += 1
193
+ @error_count += 1
194
194
  end
195
195
  end
196
196
  end
@@ -198,11 +198,12 @@ class Wco::Site
198
198
  end
199
199
 
200
200
  puts "Results:".green
201
- results.each do |r|
201
+ @results.each do |r|
202
202
  puts r
203
203
  end
204
- puts "Total count: #{total_count}"
205
- puts "Error count: #{error_count}"
204
+ puts "Total count: #{@total_count}"
205
+ puts "Error count: #{@error_count}"
206
+ return { total_count: @total_count, error_count: @error_count, results: @results }
206
207
  end
207
208
 
208
209
  def logg msg
@@ -27,8 +27,9 @@ class WcoEmail::Conversation
27
27
 
28
28
  has_many :messages, class_name: '::WcoEmail::Message'
29
29
 
30
- has_and_belongs_to_many :tags, class_name: 'Wco::Tag', index: true
31
- has_and_belongs_to_many :leads, class_name: 'Wco::Lead', index: true
30
+ has_and_belongs_to_many :tags, class_name: 'Wco::Tag', index: true
31
+ has_and_belongs_to_many :leadsets, class_name: 'Wco::Leadset', index: true
32
+ has_and_belongs_to_many :leads, class_name: 'Wco::Lead', index: true
32
33
 
33
34
  belongs_to :filter, class_name: 'WcoEmail::EmailFilter', inverse_of: :conversations, optional: true
34
35
 
@@ -25,7 +25,9 @@ class WcoEmail::EmailFilter
25
25
 
26
26
  has_many :email_filter_conditions
27
27
  has_many :email_filter_skip_conditions, class_name: 'WcoEmail::EmailFilterCondition'
28
+
28
29
  has_and_belongs_to_many :action_tmpls, class_name: 'Wco::OfficeActionTemplate'
30
+ has_and_belongs_to_many :leadsets, class_name: 'Wco::Leadset'
29
31
 
30
32
  belongs_to :tag, class_name: 'Wco::Tag', inverse_of: :email_filters, optional: true
31
33
 
@@ -88,6 +88,10 @@ class WcoEmail::MessageStub
88
88
  ## Leadset, Lead
89
89
  from = the_mail.from ? the_mail.from[0] : "nobody@unknown-doma.in"
90
90
  lead = Wco::Lead.find_or_create_by_email( from )
91
+ conv.leads.push lead
92
+ leadset = Wco::Leadset.from_email from
93
+ conv.leadsets.push leadset
94
+ # conv.save
91
95
 
92
96
  message = WcoEmail::Message.unscoped.where( message_id: message_id ).first
93
97
  if message
@@ -150,9 +154,6 @@ class WcoEmail::MessageStub
150
154
  puts! @message.errors.full_messages.join(", "), "Could not save @message"
151
155
  end
152
156
 
153
- conv.leads.push lead
154
- conv.save
155
-
156
157
  the_mail.cc&.each do |cc|
157
158
  Wco::Lead.find_or_create_by_email( cc )
158
159
  end
@@ -0,0 +1,5 @@
1
+
2
+ .Leads.mb-2
3
+ .d-inline <b>Leads:</b>
4
+ - leads.each do |lead|
5
+ .Chip= link_to lead.email, wco.lead_path( lead )
@@ -0,0 +1,5 @@
1
+
2
+ .Leadsets.mb-2
3
+ .d-inline <b>Leadsets:</b>
4
+ - leadsets.each do |ls|
5
+ .Chip= link_to ls.company_url, wco.leadset_path( ls )
@@ -0,0 +1,7 @@
1
+
2
+ .office-actions--actions.Card.d-flex
3
+ %h5 Office Action
4
+ .d-inline-block
5
+ = select_tag :office_action_template, options_for_select(@office_action_templates_list), class: 'select2'
6
+ %a.btn.office-action-templates-perform-btn{ href: "javascript: void(0)", data: { url: wco.office_action_templates_perform_path } }
7
+ Perform
@@ -1,6 +1,11 @@
1
1
 
2
+ - if spath.new_record?
3
+ - url = spaths_path
4
+ - else
5
+ - url = spath_path(spath)
6
+
2
7
  .sitemap-paths--form
3
- = form_for spath do |f|
8
+ = form_for spath, url: url do |f|
4
9
  = hidden_field_tag :site_id, spath[:site_id] || params[:site_id]
5
10
 
6
11
  .d-flex
@@ -3,13 +3,19 @@
3
3
  %table.bordered.data-table
4
4
  %thead
5
5
  %td Path
6
- %td Redirect To
7
- %td Selector
6
+ -# %td Redirect To
7
+ -# %td Selector
8
8
  %td Status
9
9
  %tbody
10
10
  - spaths.each do |spath|
11
11
  %tr
12
- %td= spath.path
13
- %td= spath.redirect_to
14
- %td= spath.selector
12
+ %td
13
+ = link_to '[~]', edit_spath_path(spath)
14
+ = spath.path
15
+ - if spath.redirect_to
16
+ %div
17
+ \-> &nbsp;
18
+ = spath.redirect_to
19
+ - if spath.selector
20
+ .green.ml-5= spath.selector
15
21
  %td= spath.status
@@ -0,0 +1,5 @@
1
+
2
+ .sitemap-paths-edit.maxwidth
3
+ .header
4
+ %h3.title Edit spath
5
+ = render 'form', spath: @spath
@@ -0,0 +1,15 @@
1
+
2
+ .sites-check-sitemap.padded
3
+ .header
4
+ %h3.title Checked sitemap
5
+
6
+ %ul
7
+ %li
8
+ Total count: #{@total_count}
9
+ %li
10
+ Error count: #{@error_count}
11
+
12
+ %ul
13
+ - @results.each do |r|
14
+ %li= r
15
+
@@ -9,8 +9,8 @@
9
9
  = render '/wco/tags/index', tags: @site.tags
10
10
 
11
11
  %h5.d-flex
12
- Sitemap Paths&nbsp;
13
- = link_to '[+]', new_sitemap_path_path( site_id: @site.id )
12
+ Sitemap Paths &nbsp;
13
+ = link_to '[+]', new_spath_path( site_id: @site.id )
14
14
  &nbsp;
15
15
  = button_to 'check', check_sitemap_path( site: @site ), data: { confirm: 'Are you sure?' }
16
16
  = render '/wco/sitemap_paths/form', spath: @new_sitemap_path
@@ -4,7 +4,10 @@
4
4
  %thead
5
5
  %th.select-all.nosort
6
6
  = render '/wco/select_all'
7
- %th.leads leads
7
+ %th.leads
8
+ leadsets
9
+ %span.red /
10
+ leads
8
11
  %th.subject subject, preview
9
12
  %th.tags Tags
10
13
  %th.latest-at latest_at
@@ -15,11 +18,13 @@
15
18
  .gray= idx+1
16
19
  = check_box_tag 'conversation_ids[]', conv.id.to_s, nil, { class: 'i-sel' }
17
20
  %td.leads.mini
18
- -# - conv.from_emails.each do |from|
19
- -# = link_to from, wco.lead_path( from )
20
- -# %hr
21
- - conv.leads.each do |lead|
22
- = link_to lead.email, wco.lead_path( lead )
21
+ %ul.m-0.p-0
22
+ - conv.leadsets.each do |ls|
23
+ %li= ls.company_url
24
+ %hr
25
+ %ul.m-0.p-0
26
+ - conv.leads.each do |lead|
27
+ %li= link_to lead.email, wco.lead_path( lead )
23
28
  %td.subject
24
29
  - if conv.unread?
25
30
  <b>#{link_to conv.subject, wco_email.conversation_path(conv)}</b>
data/config/routes.rb CHANGED
@@ -41,7 +41,8 @@ Wco::Engine.routes.draw do
41
41
 
42
42
  resources :obfuscated_redirects
43
43
 
44
- post 'office_action_templates', to: 'office_action_templates#update'
44
+ post 'office_action_templates', to: 'office_action_templates#update'
45
+ post 'office_action_templates/perform', to: 'office_action_templates#perform', as: :office_action_templates_perform
45
46
  resources :office_action_templates
46
47
  resources :office_actions
47
48
 
@@ -61,7 +62,7 @@ Wco::Engine.routes.draw do
61
62
 
62
63
  post 'sites/:id/check_sitemap', to: 'sites#check_sitemap', as: :check_sitemap
63
64
  resources :sites
64
- resources :sitemap_paths
65
+ resources :sitemap_paths, as: :spaths
65
66
  resources :subscriptions
66
67
 
67
68
  delete 'tags/remove/:id/from/:resource/:resource_id', to: 'tags#remove_from', as: :remove_tag_from
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.164
4
+ version: 3.1.0.165
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-06-19 00:00:00.000000000 Z
11
+ date: 2024-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ahoy_matey
@@ -419,7 +419,8 @@ files:
419
419
  - app/assets/stylesheets/wco/chip.scss
420
420
  - app/assets/stylesheets/wco/conversations.scss
421
421
  - app/assets/stylesheets/wco/galleries.scss
422
- - app/assets/stylesheets/wco/leads.scss
422
+ - app/assets/stylesheets/wco/leads_leadsets.scss
423
+ - app/assets/stylesheets/wco/office_action_templates.scss
423
424
  - app/assets/stylesheets/wco/pagination.scss
424
425
  - app/assets/stylesheets/wco/photos.scss
425
426
  - app/assets/stylesheets/wco/utils.scss
@@ -443,6 +444,7 @@ files:
443
444
  - app/controllers/wco/profiles_controller.rb
444
445
  - app/controllers/wco/publishers_controller.rb
445
446
  - app/controllers/wco/reports_controller.rb
447
+ - app/controllers/wco/sitemap_paths_controller.rb
446
448
  - app/controllers/wco/sites_controller.rb
447
449
  - app/controllers/wco/subscriptions_controller.rb
448
450
  - app/controllers/wco/tags_controller.rb
@@ -553,6 +555,7 @@ files:
553
555
  - app/views/wco/leads/_form_import.haml
554
556
  - app/views/wco/leads/_header.haml
555
557
  - app/views/wco/leads/_index.haml
558
+ - app/views/wco/leads/_index_chips.haml
556
559
  - app/views/wco/leads/_table.haml
557
560
  - app/views/wco/leads/edit.haml
558
561
  - app/views/wco/leads/index.haml
@@ -560,6 +563,7 @@ files:
560
563
  - app/views/wco/leads/show.haml
561
564
  - app/views/wco/leadsets/_form.haml
562
565
  - app/views/wco/leadsets/_header.haml
566
+ - app/views/wco/leadsets/_index_chips.haml
563
567
  - app/views/wco/leadsets/edit.haml
564
568
  - app/views/wco/leadsets/index.haml
565
569
  - app/views/wco/leadsets/index_dataTables.haml
@@ -582,6 +586,7 @@ files:
582
586
  - app/views/wco/office_action_templates/index.haml
583
587
  - app/views/wco/office_action_templates/new.haml
584
588
  - app/views/wco/office_action_templates/show.haml
589
+ - app/views/wco/office_actions/_actions.haml
585
590
  - app/views/wco/office_actions/_form.haml
586
591
  - app/views/wco/office_actions/_header.haml
587
592
  - app/views/wco/office_actions/_index.haml
@@ -629,8 +634,10 @@ files:
629
634
  - app/views/wco/reports/show.haml
630
635
  - app/views/wco/sitemap_paths/_form.haml
631
636
  - app/views/wco/sitemap_paths/_index.haml
637
+ - app/views/wco/sitemap_paths/edit.haml
632
638
  - app/views/wco/sites/_form.haml
633
639
  - app/views/wco/sites/_header.haml
640
+ - app/views/wco/sites/check_sitemap.haml
634
641
  - app/views/wco/sites/edit.haml
635
642
  - app/views/wco/sites/index.haml
636
643
  - app/views/wco/sites/new.haml
@@ -1,6 +0,0 @@
1
-
2
- .Leads {
3
- border: 1px solid var(--wco-color-2);
4
- border-radius: .5em;
5
- padding: 0.5em;
6
- }