wco_models 3.1.0.82 → 3.1.0.85

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: cd7385bbbad06fcc84a31720f2f549a80703b2740d2031115b2479579c47a1d3
4
- data.tar.gz: 6c19ad0bc735c05ebd457870aff9ca5e6b9368dbabd71cab789aa2bbadc8a06b
3
+ metadata.gz: e35d2da6576585f442b86b8ab7589e6338a8c621659f1cb3fbc9f83135c9803e
4
+ data.tar.gz: 2640b0995ab53af533155910cd90d607188754e87e6d58898eed2a1a3c98354e
5
5
  SHA512:
6
- metadata.gz: f94c696a9048b71fa7497ec41033d74515d7136dbf342fa1c5c61c1430ef26c9ca4bad59b66b825a3ec3e11de3865a552ee0702c063bcde7aa40950dd6e7ead9
7
- data.tar.gz: 9701df840501d675f1a6607fbb97dc7a7c0536052f490b29c902eee1e21f8f9fd038ec13bb7a2b7a28c90862cfd0170b083214997a7104fc53ba75d072f5e83b
6
+ metadata.gz: 0f55ff4f412e168ba9a2e715afd3e90abd8e44f5d209f544beec59e0d1e9125be0fe1e25763b62e14b131e9c986fb633594d974cedda643ceb8601c74f4b2c18
7
+ data.tar.gz: ee4b6abe4d93e40dabd416046b23fce7fea9a2596283fdcce523419eb33941c83855799b8201b32be22c21c554aed0212a50033ee45be56d91da197c8685c8aa
@@ -62,6 +62,14 @@ table.bordered {
62
62
 
63
63
  /* C */
64
64
 
65
+ .Card {
66
+ border: 1px solid gray;
67
+ border-radius: 5px;
68
+
69
+ padding: 0.5em;
70
+ margin: 0 0.5em 0.5em 0;
71
+ }
72
+
65
73
  .code,
66
74
  .mono,
67
75
  .monospace {
@@ -149,3 +157,16 @@ h5.title {
149
157
  word-break: break-word;
150
158
  }
151
159
 
160
+ /* W */
161
+
162
+ .w-300px {
163
+ width: 300px;
164
+ }
165
+
166
+ .w-400px {
167
+ width: 400px;
168
+ }
169
+
170
+ .w-500px {
171
+ width: 500px;
172
+ }
@@ -20,7 +20,9 @@ class Wco::PublishersController < Wco::ApplicationController
20
20
  @publisher = Wco::Publisher.find params[:id]
21
21
  authorize! :do_run, @publisher
22
22
 
23
- @publisher.do_run binding
23
+ @publisher.props = OpenStruct.new( JSON.parse params[:publisher][:props] )
24
+ # @publisher.do_run binding
25
+ @publisher.do_run
24
26
 
25
27
  flash_notice "Probably ok"
26
28
 
@@ -12,7 +12,8 @@ class Wco::Headline
12
12
  field :name
13
13
  validates :name, presence: true, uniqueness: true
14
14
 
15
- belongs_to :site, class_name: 'Wco::Site'
15
+ ## @TODO: remove this entirely. 2024-01-16
16
+ belongs_to :site, class_name: 'Wco::Site', optional: true
16
17
 
17
18
  has_and_belongs_to_many :tags, class_name: 'Wco::Tag'
18
19
 
@@ -23,9 +23,25 @@ class Wco::OfficeAction
23
23
 
24
24
  field :perform_at, type: :time
25
25
 
26
+ def do_run
27
+ sch = self
28
+ sch.update!({ status: STATUS_INACTIVE })
29
+
30
+ eval( sch.tmpl.action_exe )
31
+
32
+ # schedule next actions & update the action
33
+ sch.tmpl.ties.each do |tie|
34
+ next_sch = self.class.find_or_initialize_by({
35
+ office_action_template_id: tie.next_tmpl.id,
36
+ })
37
+ next_sch.perform_at = eval(tie.next_at_exe)
38
+ next_sch.status = STATUS_ACTIVE
39
+ next_sch.save!
40
+ end
41
+ end
42
+
26
43
  def to_s
27
44
  slug
28
45
  end
29
-
30
46
  end
31
47
 
@@ -7,10 +7,10 @@ class Wco::OfficeActionTemplateTie
7
7
  attr_accessor :to_delete
8
8
 
9
9
  belongs_to :office_action_template, class_name: 'OfficeActionTemplate', inverse_of: :ties
10
- def oat; office_action_template; end
10
+ def tmpl; office_action_template; end
11
11
 
12
12
  belongs_to :next_office_action_template, class_name: 'OfficeActionTemplate', inverse_of: :prev_ties
13
- def next_oat; next_office_action_template; end
13
+ def next_tmpl; next_office_action_template; end
14
14
  # def tmpl; next_office_action_template; end
15
15
 
16
16
 
@@ -17,14 +17,17 @@ class Wco::Publisher
17
17
  field :context_eval
18
18
  field :after_eval
19
19
  field :post_body_tmpl
20
+ field :post_path
20
21
 
21
22
  has_many :oats, class_name: 'Wco::OfficeActionTemplate'
22
23
 
23
- ## @TODO: move to PublisherDrupal
24
+ attr_accessor :props
25
+
24
26
  def do_run
25
- @report = report
27
+ @site = site
28
+ @headers = {}
29
+ @ctx = OpenStruct.new
26
30
 
27
- @ctx = OpenStruct.new
28
31
  eval( context_eval )
29
32
  puts! @ctx, '@ctx'
30
33
 
@@ -32,14 +35,9 @@ class Wco::Publisher
32
35
  body = JSON.parse tmpl.result(binding)
33
36
  puts! body, 'body'
34
37
 
35
- headers = {}
36
- if Wco::Site::KIND_DRUPAL == site.kind
37
- headers['Content-Type'] = 'application/hal+json'
38
- end
39
-
40
- out = Wco::HTTParty.post( "#{site.origin}#{site.post_path}", {
38
+ out = Wco::HTTParty.post( "#{@site.origin}#{post_path}", {
41
39
  body: body.to_json,
42
- headers: headers,
40
+ headers: @headers,
43
41
  basic_auth: { username: site.username, password: site.password },
44
42
  })
45
43
  puts! out.response, 'out'
@@ -47,33 +45,6 @@ class Wco::Publisher
47
45
  eval( after_eval )
48
46
  end
49
47
 
50
- def publish_report report
51
- @report = report
52
- @site = site
53
-
54
- @ctx = OpenStruct.new
55
- eval( context_eval )
56
- puts! @ctx, '@ctx'
57
-
58
-
59
- tmpl = ERB.new post_body_tmpl
60
- body = JSON.parse tmpl.result(binding)
61
- puts! body, 'body'
62
-
63
- headers = {}
64
- if Wco::Site::KIND_DRUPAL == site.kind
65
- headers['Content-Type'] = 'application/hal+json'
66
- end
67
-
68
- out = Wco::HTTParty.post( "#{site.origin}#{site.post_path}", {
69
- body: body.to_json,
70
- headers: headers,
71
- basic_auth: { username: site.username, password: site.password },
72
- })
73
- puts! out.response, 'out'
74
-
75
- eval( after_eval )
76
- end
77
48
 
78
49
  def to_s
79
50
  "#{slug}: #{kind} => #{site}"
@@ -82,7 +53,6 @@ class Wco::Publisher
82
53
  def self.list
83
54
  [[nil,nil]] + all.map { |p| [p, p.id] }
84
55
  end
85
-
86
56
  end
87
57
 
88
58
  =begin
@@ -13,14 +13,14 @@
13
13
  %label action_exe
14
14
  = f.text_area :action_exe, class: :monospace
15
15
 
16
- .field.flex-row
17
- %label From
18
- = f.select :from_type, options_for_select( @from_types_list, selected: params[:from_type] || oat.from_type )
19
- = f.select :from_id, options_for_select( @from_ids_list ), {}, class: 'select2'
20
-
21
- .field.flex-row
22
- %label Publisher
23
- = f.select :publisher, options_for_select( @publishers_list, selected: oat.publisher ), {}, class: 'select2'
16
+ -# .field.flex-row
17
+ -# %label From
18
+ -# = f.select :from_type, options_for_select( @from_types_list, selected: params[:from_type] || oat.from_type )
19
+ -# = f.select :from_id, options_for_select( @from_ids_list ), {}, class: 'select2'
20
+
21
+ -# .field.flex-row
22
+ -# %label Publisher
23
+ -# = f.select :publisher, options_for_select( @publishers_list, selected: oat.publisher ), {}, class: 'select2'
24
24
 
25
25
  .row
26
26
  .col-md-4
@@ -1,5 +1,5 @@
1
1
 
2
- - oat ||= nil
2
+ - tmpl ||= nil
3
3
  - depth ||= 5
4
4
  - depth = depth - 1
5
5
 
@@ -10,9 +10,9 @@
10
10
  %li
11
11
  = tie.next_at_exe
12
12
  %br
13
- = link_to '[~]', edit_office_action_template_path(tie.next_oat)
14
- = link_to tie.next_oat, office_action_template_path(tie.next_oat)
15
- - if tie.next_oat == oat
13
+ = link_to '[~]', edit_office_action_template_path(tie.next_tmpl)
14
+ = link_to tie.next_tmpl, office_action_template_path(tie.next_tmpl)
15
+ - if tie.next_tmpl == tmpl
16
16
  <b>[Same]</b>
17
- - elsif tie.next_oat.ties.present?
18
- = render '/wco/office_action_templates/ties', ties: tie.next_oat.ties, depth: depth, oat: tie.next_oat
17
+ - elsif tie.next_tmpl.ties.present?
18
+ = render '/wco/office_action_templates/ties', ties: tie.next_tmpl.ties, depth: depth, tmpl: tie.next_tmpl
@@ -7,6 +7,8 @@
7
7
  &nbsp;
8
8
  = link_to oa.slug, office_action_path(oa)
9
9
  %ul
10
+ %li
11
+ .gray.mini= oa.id
10
12
  %li <b>status:</b> #{oa.status}
11
13
  %li
12
14
  <b>tmpl:</b>
@@ -1,9 +1,11 @@
1
1
 
2
2
  .publishers--form
3
3
  = form_for publisher do |f|
4
- .field
4
+ .actions
5
+ = f.submit
6
+ .d-flex
5
7
  = f.label :slug
6
- = f.text_field :slug
8
+ = f.text_field :slug, class: 'w-100'
7
9
 
8
10
  -## this is unnecessary b/c I use eval() :
9
11
  -# .field
@@ -12,9 +14,12 @@
12
14
  -# = f.label :from_gallery
13
15
  -# = f.select :from_gallery, options_for_select( @galleries_list, selected: publisher.from_gallery ), class: 'select2'
14
16
 
15
- .field
17
+ .d-flex
16
18
  %label site
17
19
  = f.select :site, options_for_select( @sites_list, selected: publisher.site_id ), {}, class: 'select2'
20
+ .d-flex
21
+ %label post_path
22
+ = f.text_field :post_path, class: 'w-100'
18
23
  .field
19
24
  %label.d-block context_eval
20
25
  = f.text_area :context_eval, class: 'monospace'
@@ -1,5 +1,5 @@
1
1
 
2
- .publishers-index.padded
2
+ .publishers-index.maxwidth
3
3
  %h5
4
4
  Publishers
5
5
  = link_to '[+]', wco.new_publisher_path
@@ -9,29 +9,26 @@
9
9
  %th &nbsp;
10
10
  %th
11
11
  slug
12
- %br
12
+ %th
13
13
  site
14
14
  %th
15
- context_eval
16
- %br
17
- post_body_eval
15
+ Run
18
16
  - @publishers.each do |item|
19
17
  %tr
20
18
  %td
21
19
  .flex-row
22
- = button_to '[x]', wco.publisher_path(item), method: :delete, data: { confirm: 'Are you sure?' }
20
+ = button_to 'x', wco.publisher_path(item), method: :delete, data: { confirm: 'Are you sure?' }
23
21
  = link_to '[~]', wco.edit_publisher_path(item)
24
- = button_to '[run]', wco.do_run_publisher_path( item ), data: { confirm: 'Are you sure?' }
25
22
  %td
23
+ -# = link_to item.slug, publisher_path(item)
26
24
  = item.slug
27
- %hr
28
- = item.site.origin
29
25
  %td
30
- %pre.monospace
31
- = item.context_eval
32
- %hr
33
- %pre.monospace
34
- = item.post_body_tmpl
35
- %hr
36
- %pre.monospace
37
- = item.after_eval
26
+ = link_to '[~]', edit_site_path(item.site)
27
+ -# = link_to item.site.origin, site_path(item.site)
28
+ = item.site
29
+ %td
30
+ .Card
31
+ = form_for item, url: wco.run_publisher_path( item ), method: :post do |f|
32
+ %label props
33
+ = f.text_field :props, class: 'w-400px'
34
+ = f.submit 'run', data: { confirm: 'Are you sure?' }
@@ -17,7 +17,7 @@
17
17
 
18
18
  .field
19
19
  %label Body
20
- = f.text_area :body, class: 'p-2'
20
+ = f.text_area :body, class: 'tinymce'
21
21
 
22
22
  .field
23
23
  %label Tags (#{report.tags.length}):
@@ -6,12 +6,16 @@
6
6
 
7
7
  %ul
8
8
  - @reports.each do |ttt|
9
- %li
9
+ %li.Card
10
10
  .flex-row
11
11
  = button_to '[x]', report_path(ttt), method: :delete, data: { confirm: 'Are you sure?' }
12
12
  = link_to '[~]', edit_report_path(ttt)
13
- = link_to ttt.slug, report_path(ttt)
13
+ .a
14
+ = link_to ttt.title, report_path(ttt)
15
+ %br
16
+ `#{ttt.slug}`
17
+ .gray.mini= ttt.id
14
18
  .flex-row
15
- <b>Tags (#{ttt.tags.length}):</b>&nbsp;
19
+
16
20
  = render '/wco/tags/index_inline', tags: ttt.tags
17
21
 
@@ -1,6 +1,11 @@
1
1
 
2
2
  .reports-show.maxwidth
3
- %h5 Report `#{@report.slug}`
3
+ %h5
4
+ = link_to '[~]', edit_report_path(@report)
5
+ Report #{link_to @report.title, report_path(@report)}
6
+ %br
7
+ `#{@report.slug}`
8
+ .gray.mini= @report.id
4
9
 
5
10
  .descr= raw @report.body
6
11
  -# %pre.descr= raw @report.body
@@ -1,17 +1,20 @@
1
1
 
2
2
  .sites--form
3
3
  = form_for site do |f|
4
+ .actions
5
+ = f.submit
4
6
  .field
5
7
  %label Slug
6
8
  = f.text_field :slug
7
9
 
8
- = f.label :kind
9
- = f.select :kind, options_for_select( Wco::Site.kinds_list, selected: site.kind )
10
+ -# = f.label :kind
11
+ -# = f.select :kind, options_for_select( Wco::Site.kinds_list, selected: site.kind )
12
+
10
13
  .field
11
14
  = f.label :origin
12
15
  = f.text_field :origin
13
- = f.label :post_path
14
- = f.text_field :post_path
16
+ -# = f.label :post_path
17
+ -# = f.text_field :post_path
15
18
  .field
16
19
  = f.label :username
17
20
  = f.text_field :username
@@ -1,5 +1,5 @@
1
1
 
2
- .sites-index.padded
2
+ .sites-index.flexwidth
3
3
  %h5
4
4
  Sites
5
5
  = link_to '[+]', new_site_path
@@ -8,17 +8,17 @@
8
8
  %tr
9
9
  %th &nbsp;
10
10
  %th slug
11
- %th kind
11
+ -# %th kind
12
12
  %th origin
13
- %th post_path
13
+ -# %th post_path
14
14
  - @sites.each do |ttt|
15
15
  %tr
16
16
  %td
17
17
  .flex-row
18
18
  = button_to '[x]', site_path(ttt), method: :delete, data: { confirm: 'Are you sure?' }
19
19
  = link_to '[~]', edit_site_path(ttt)
20
- = ttt.id
20
+ .gray.mini= ttt.id
21
21
  %td= ttt.slug
22
- %td= ttt.kind
22
+ -# %td= ttt.kind
23
23
  %td= ttt.origin
24
- %td= ttt.post_path
24
+ -# %td= ttt.post_path
@@ -3,6 +3,7 @@
3
3
  %ul
4
4
  - tags.each do |tag|
5
5
  %li
6
+ = link_to '[~]', edit_tag_path(tag)
6
7
  = link_to tag.slug, tag_path(tag)
7
8
  <b>N headlines:</b> #{tag.headlines.length}
8
9
  <b>N reports:</b> #{tag.reports.length}
@@ -1,7 +1,7 @@
1
1
 
2
2
 
3
3
  .tags--index-inline
4
- <b>Tags:</b>
4
+ <b>Tags (#{tags.length}):</b>
5
5
  - tags.each_with_index do |tag, idx|
6
6
  = link_to tag.slug, tag_path(tag)
7
7
  - if idx+1 != tags.length
@@ -0,0 +1,4 @@
1
+
2
+ .tags-edit.maxwidth
3
+
4
+ = render 'form', tag: @tag
data/config/routes.rb CHANGED
@@ -37,7 +37,7 @@ Wco::Engine.routes.draw do
37
37
  resources :prices
38
38
  resources :products
39
39
  resources :profiles
40
- post 'publishers/:id/do-run', to: 'publishers#do_run', as: :do_run_publisher
40
+ post 'publishers/:id/do-run', to: 'publishers#do_run', as: :run_publisher
41
41
  resources :publishers
42
42
  resources :photos
43
43
 
@@ -2,34 +2,26 @@
2
2
  require 'business_time'
3
3
  require 'httparty'
4
4
 
5
- namespace :office do
5
+ namespace :wco do
6
6
 
7
- desc 'run_office_actions'
7
+
8
+ desc 'run office actions'
8
9
  task run_office_actions: :environment do
10
+ puts! "Starting wco_email:run_office_actions..."
9
11
  while true do
10
12
 
11
- OA = Wco::OfficeAction
12
- OAT = Wco::OfficeActionTemplate
13
-
14
- OA.active.where( :perform_at.lte => Time.now ).each do |oa|
15
- puts "+++ +++ Office Action: #{oa}"
13
+ schs = Wco::OfficeAction.active.where({ :perform_at.lte => Time.now })
14
+ print "[#{schs.length}]" if schs.length != 0
15
+ schs.each do |sch|
16
16
 
17
- oa.update({ status: INACTIVE })
18
- oa.tmpl.do_run
19
- oa.tmpl.ties.each do |tie|
20
- next_oa = OA.find_or_initialize_by({
21
- office_action_template_id: tie.next_oat.id,
22
- })
23
- next_oa.perform_at = eval( tie.next_at_exe )
24
- next_oa.status = ACTIVE
25
- next_oa.save!
26
- end
17
+ sch.do_run
27
18
 
28
- print '^'
19
+ print "[#{sch.id}]^"
20
+ sleep 15
29
21
  end
30
22
 
31
23
  print '.'
32
- sleep Rails.env.production? ? 60 : 5 # seconds
24
+ sleep 15
33
25
  end
34
26
  end
35
27
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.82
4
+ version: 3.1.0.85
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev