wco_models 3.5.0.7 → 3.5.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/wco/main.scss +7 -3
  3. data/app/assets/stylesheets/wco/photos.scss +2 -1
  4. data/app/controllers/wco/office_action_templates_controller.rb +3 -0
  5. data/app/controllers/wco/publishers_controller.rb +6 -16
  6. data/app/controllers/wco/reports_controller.rb +6 -5
  7. data/app/controllers/wco/sitemap_paths_controller.rb +14 -2
  8. data/app/controllers/wco/sites_controller.rb +1 -1
  9. data/app/controllers/wco/tags_controller.rb +1 -1
  10. data/app/models/iro/option.rb +37 -4
  11. data/app/models/iro/priceitem.rb +62 -4
  12. data/app/models/tda/option.rb +39 -41
  13. data/app/models/wco/newspartial.rb +3 -2
  14. data/app/models/wco/publisher.rb +29 -8
  15. data/app/models/wco/publisher_d10.rb +50 -0
  16. data/app/models/wco/report.rb +12 -2
  17. data/app/models/wco/site.rb +1 -67
  18. data/app/models/wco/sitemap_path.rb +19 -13
  19. data/app/models/wco/tag.rb +15 -8
  20. data/app/models/wco/utils.rb +1 -1
  21. data/app/views/wco/api/newsproducer/README.txt +4 -0
  22. data/app/views/wco/api/newsproducer/_studio_blue2.js-bk +606 -0
  23. data/app/views/wco/api/newsproducer/_studio_blue2.js-bk2 +898 -0
  24. data/app/views/wco/api/newsproducer/studio_blue2.html.erb-bk +151 -0
  25. data/app/views/wco/office_action_templates/index.haml +1 -1
  26. data/app/views/wco/office_actions/_actions.haml +1 -1
  27. data/app/views/wco/publishers/_form.haml +11 -2
  28. data/app/views/wco/publishers/_post_with.haml +1 -1
  29. data/app/views/wco/reports/_form.haml +13 -2
  30. data/app/views/wco/reports/_index.haml +18 -11
  31. data/app/views/wco/reports/show.haml +6 -1
  32. data/app/views/wco/sitemap_paths/_index.haml +1 -0
  33. data/app/views/wco/sitemap_paths/show.haml +14 -0
  34. data/app/views/wco/sites/index.haml +6 -0
  35. data/app/views/wco/sites/show.haml +1 -1
  36. data/app/views/wco/tags/_form.haml +3 -0
  37. data/config/routes.rb +3 -3
  38. data/lib/shortcuts.rb +1 -1
  39. data/lib/wco_models.rb +1 -1
  40. metadata +8 -3
  41. data/app/views/wco/sitemap_paths/check.haml +0 -13
@@ -25,14 +25,24 @@ class Wco::Report
25
25
 
26
26
  field :body
27
27
  def body_json
28
- body.gsub(/\r/, '').gsub(/\n\n+/, '<br /><br />').to_json
28
+ out = body
29
+ if FORMAT_PLAINTEXT == body_format
30
+ out = out.gsub(/\r/, '').gsub(/\n\n+/, '<br /><br />')
31
+ end
32
+ out.to_json
29
33
  end
34
+ FORMAT_PLAINTEXT = 'format-plaintext'
35
+ FORMAT_FULLHTML = 'format-fullhtml'
36
+ FORMATS = [ FORMAT_PLAINTEXT, FORMAT_FULLHTML ]
37
+ field :body_format, type: :string, default: FORMAT_PLAINTEXT
30
38
 
31
39
  field :x, :type => Float
32
40
  field :y, :type => Float
33
41
  field :z, :type => Float
42
+ field :source_url, type: :string
43
+ field :summary, type: :string
34
44
 
35
- belongs_to :author, class_name: 'Wco::Profile'
45
+ belongs_to :author, class_name: 'Wco::Profile', optional: true
36
46
 
37
47
  has_one :image_thumb, class_name: 'Wco::Photo', inverse_of: :report, dependent: :destroy
38
48
  accepts_nested_attributes_for :image_thumb
@@ -18,7 +18,7 @@ class Wco::Site
18
18
  has_many :logs, inverse_of: :obj
19
19
  has_many :publishers # , class_name: 'Wco::Publisher'
20
20
  has_many :sitemap_paths, class_name: 'Wco::SitemapPath'
21
- has_many :tags, class_name: 'Wco::Tag'
21
+ has_many :tags, class_name: 'Wco::Tag', inverse_of: :site
22
22
 
23
23
  field :slug
24
24
  validates :slug, presence: true, uniqueness: true
@@ -34,78 +34,12 @@ class Wco::Site
34
34
 
35
35
  def to_s
36
36
  slug
37
- # origin
38
37
  end
39
38
 
40
39
  def self.list
41
40
  [[nil,nil]] + all.map { |s| [ s.slug, s.id ] }
42
41
  end
43
42
 
44
- def body
45
- {
46
- "_links": {
47
- "type":{"href":"http://pi.local/rest/type/node/article"}
48
- },
49
- "title":[{"value":"Node +++ 123 bac +++" }],
50
- "body":[{"value": "<b>hello, wor</b>ld!", "format": "full_html" }],
51
- "type":[{"target_id":"article"}],
52
- "status": [{"value": 1}],
53
- "_embedded": {
54
- "http://pi.local/rest/relation/node/article/field_issue": [
55
- { "uuid": [{ "value": "56229a95-d675-43e1-99b1-f9e11b5579c5" }] }
56
- ],
57
- "http://pi.local/rest/relation/node/article/field_tags": [
58
- { "uuid": [{ "value": "45646a7d-1a16-42e8-b758-f6e1c8d976f7" }] },
59
- { "uuid": [{ "value": "834e34e2-05ae-498d-b876-453798872ce1" }] }
60
- ]
61
- }
62
-
63
- }
64
- end
65
-
66
- def do_post
67
- HTTParty.post( post_url,
68
- body: JSON.generate( body ),
69
- headers: { 'Content-Type' => 'application/hal+json' },
70
- basic_auth: { username: username, password: password },
71
- )
72
- end
73
-
74
- def wp_import
75
- site = self
76
-
77
- root_tag = Wco::Tag.find_or_create_by slug: "#{site.slug}_wp-import", site_id: site.id
78
- url = "#{site.origin}/wp-json/wp/v2/posts"
79
- pi_admin = Wco::Profile.find_or_create_by email: 'admin@piousbox.com'
80
- n_pages = 12
81
- per_page = 100
82
-
83
- (1..n_pages).each do |page|
84
- print "Page #{page}"
85
-
86
- posts = HTTParty.get url, query: { per_page: per_page, page: page }
87
- posts.each do |post|
88
- report = Wco::Report.new({
89
- legacy_id: post['id'],
90
- created_at: post['date'],
91
- slug: post['link'].sub(site.origin, ''),
92
- title: post['title']['rendered'],
93
- subtitle: post['excerpt']['rendered'],
94
- body: post['content']['rendered'],
95
- author: pi_admin,
96
- tag_ids: ( [ root_tag ] + site.tags.where( :legacy_id.in => post['categories'] ) ).map(&:id),
97
- })
98
-
99
- if report.save
100
- print '^'
101
- else
102
- puts report.errors.messages
103
- end
104
- end
105
- end
106
- puts "ok"
107
- end
108
-
109
43
  def check_sitemap
110
44
  @results = []
111
45
  @total_count = 0
@@ -15,9 +15,15 @@ class Wco::SitemapPath
15
15
  field :selectors, type: Array, default: []
16
16
  field :title, type: String
17
17
 
18
- field :results, type: Array, default: []
18
+
19
19
  field :status, type: String
20
20
 
21
+ # field :results, type: Array, default: []
22
+ has_many :logs, inverse_of: :obj
23
+ def results
24
+ logs.map { |log| "#{log.message} [on #{log.created_at.to_s[0...10]}]" }
25
+ end
26
+
21
27
  def check
22
28
  self.status = 'NOT_OK'
23
29
  skip_rest = false
@@ -26,26 +32,26 @@ class Wco::SitemapPath
26
32
  begin
27
33
  body = HTTParty.get( "#{site.origin}#{self[:path]}" ).body
28
34
  rescue OpenSSL::SSL::SSLError => err
29
- results.push "NOT OK [ssl-exception] #{self[:path]}" # .red
35
+ log = Wco::Log.create obj: self, message: "NOT OK [ssl-exception] #{self[:path]}" # .red
30
36
  return
31
37
  end
32
38
  doc = Nokogiri::HTML( body )
33
39
  out = doc.search self[:selector]
34
40
  if out.present?
35
- results.push "OK #{self[:path]}"
41
+ log = Wco::Log.create obj: self, message: "OK #{self[:path]}"
36
42
  self.status = 'OK'
37
43
  else
38
- results.push "NOT OK [selector-missing] #{self[:path]}" # .red
44
+ log = Wco::Log.create obj: self, message: "NOT OK [selector-missing] #{self[:path]}" # .red
39
45
  end
40
46
 
41
47
  elsif self[:redirect_to].present?
42
48
  out = HTTParty.get( "#{site.origin}#{self[:path]}", follow_redirects: false )
43
49
  if( out.headers[:location] == self[:redirect_to] ||
44
50
  out.headers[:location] == "#{site.origin}#{self[:redirect_to]}" )
45
- results.push "OK #{self[:path]}"
51
+ log = Wco::Log.create obj: self, message: "OK #{self[:path]}"
46
52
  self.status = 'OK'
47
53
  else
48
- results.push "NOT OK [redirect-missing] #{self[:path]}" # .red
54
+ log = Wco::Log.create obj: self, message: "NOT OK [redirect-missing] #{self[:path]}" # .red
49
55
 
50
56
  puts!( out.response, 'response' ) if DEBUG
51
57
  # puts!( out.body, 'body' ) if DEBUG
@@ -56,7 +62,7 @@ class Wco::SitemapPath
56
62
  end
57
63
  skip_rest = true
58
64
  else
59
- results.push "SKIP #{self[:path]}"
65
+ log = Wco::Log.create obj: self, message: "SKIP #{self[:path]}"
60
66
  self.status = 'OK'
61
67
  skip_rest = true
62
68
  end
@@ -66,10 +72,10 @@ class Wco::SitemapPath
66
72
  if self[:meta_description].present?
67
73
  out = doc.search( 'head meta[name="description"]' )[0]['content']
68
74
  if out.include?( self[:meta_description] )
69
- results.push "OK #{self[:path]} meta_description"
75
+ log = Wco::Log.create obj: self, message: "OK #{self[:path]} meta_description"
70
76
  else
71
77
  self.status = 'NOT_OK'
72
- results.push "NOT OK [meta-description-no-contain] #{self[:path]}" # .red
78
+ log = Wco::Log.create obj: self, message: "NOT OK [meta-description-no-contain] #{self[:path]}" # .red
73
79
  end
74
80
  end
75
81
 
@@ -77,10 +83,10 @@ class Wco::SitemapPath
77
83
  self[:selectors].each do |selector|
78
84
  out = doc.search selector
79
85
  if out.present?
80
- results.push "OK #{self[:path]} selectors:#{selector}"
86
+ log = Wco::Log.create obj: self, message: "OK #{self[:path]} selectors:#{selector}"
81
87
  else
82
88
  self.status = 'NOT_OK'
83
- results.push "NOT OK [selectors-missing:#{selector}] #{self[:path]}" # .red
89
+ log = Wco::Log.create obj: self, message: "NOT OK [selectors-missing:#{selector}] #{self[:path]}" # .red
84
90
  end
85
91
  end
86
92
  end
@@ -88,10 +94,10 @@ class Wco::SitemapPath
88
94
  if self[:title].present?
89
95
  out = doc.search( 'head title' )[0].text
90
96
  if out.include?( self[:title] )
91
- results.push "OK #{self[:path]} title"
97
+ log = Wco::Log.create obj: self, message: "OK #{self[:path]} title"
92
98
  else
93
99
  self.status = 'NOT_OK'
94
- results.push "NOT OK [title-no-contain] #{self[:path]}" # .red
100
+ log = Wco::Log.create obj: self, message: "NOT OK [title-no-contain] #{self[:path]}" # .red
95
101
  end
96
102
  end
97
103
 
@@ -5,19 +5,21 @@ class Wco::Tag
5
5
  store_in collection: 'wco_tags'
6
6
 
7
7
  field :slug
8
- validates :slug, presence: true, uniqueness: true
8
+ validates :slug, presence: true, uniqueness: { scope: :site_id }
9
9
  index({ slug: -1 })
10
10
 
11
11
  field :weight, type: :string, default: 'jjj'
12
+ field :external_id, type: :string
13
+ def eid; external_id; end
12
14
 
13
15
  belongs_to :parent, class_name: '::Wco::Tag', inverse_of: :sons, optional: true
14
16
  has_many :sons, class_name: '::Wco::Tag', inverse_of: :parent
15
17
 
16
- belongs_to :site, class_name: '::Wco::Site', optional: true
17
- belongs_to :sidebar_profile, class_name: 'Wco::Profile', optional: true
18
- has_many :email_filters, class_name: '::WcoEmail::EmailFilter', inverse_of: :tag
19
- has_many :email_templates, class_name: '::WcoEmail::EmailTemplate', inverse_of: :tag
20
- has_many :ajects, class_name: '::WcoEmail::EmailFilterAction', inverse_of: :aject
18
+ belongs_to :site, class_name: '::Wco::Site', optional: true, inverse_of: :tags
19
+ belongs_to :sidebar_profile, class_name: 'Wco::Profile', optional: true
20
+ has_many :email_filters, class_name: '::WcoEmail::EmailFilter', inverse_of: :tag
21
+ has_many :email_templates, class_name: '::WcoEmail::EmailTemplate', inverse_of: :tag
22
+ has_many :ajects, class_name: '::WcoEmail::EmailFilterAction', inverse_of: :aject
21
23
 
22
24
  has_and_belongs_to_many :conversations, class_name: '::WcoEmail::Conversation', index: true
23
25
  has_and_belongs_to_many :galleries, class_name: '::Wco::Gallery'
@@ -27,6 +29,7 @@ class Wco::Tag
27
29
  has_and_belongs_to_many :message_stubs, class_name: '::WcoEmail::MessageStub'
28
30
  has_and_belongs_to_many :newsvideos, class_name: '::Wco::Newsvideo'
29
31
  has_and_belongs_to_many :reports, class_name: '::Wco::Report'
32
+ has_and_belongs_to_many :publishers, class_name: '::Wco::Publisher'
30
33
  has_and_belongs_to_many :videos, class_name: '::Wco::Video'
31
34
 
32
35
 
@@ -71,9 +74,13 @@ class Wco::Tag
71
74
 
72
75
 
73
76
  def to_s
74
- slug
77
+ if site
78
+ "#{slug}@#{site}"
79
+ else
80
+ slug
81
+ end
75
82
  end
76
83
  def self.list
77
- [[nil,nil]] + all.order_by( slug: :asc ).map { |p| [ p.slug, p.id ] }
84
+ [[nil,nil]] + all.includes(:site).order_by( slug: :asc ).map { |t| [ t.to_s, t.id.to_s ] }
78
85
  end
79
86
  end
@@ -50,7 +50,7 @@ module Wco::Utils
50
50
  def set_slug
51
51
  return if !slug.blank?
52
52
  if defined? name
53
- new_slug = name.downcase.gsub(/[^a-z0-9\s]/i, '').gsub(' ', '-')
53
+ new_slug = name.downcase.gsub(/[^a-z0-9\s_-]/i, '').gsub(' ', '-')
54
54
  else
55
55
  new_slug = '1'
56
56
  end
@@ -0,0 +1,4 @@
1
+
2
+ studio_fps is current, studio_blue2 is old.
3
+
4
+ actually, i still need studio_blue2, it seems.