ish_models 0.0.33.304 → 3.1.0.0

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 (73) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +28 -0
  4. data/Rakefile +15 -0
  5. data/app/assets/config/ish_models_manifest.js +1 -0
  6. data/app/assets/stylesheets/ish_models/application.css +15 -0
  7. data/app/controllers/ish_models/application_controller.rb +4 -0
  8. data/app/helpers/ish_models/application_helper.rb +4 -0
  9. data/app/jobs/ish_models/application_job.rb +4 -0
  10. data/app/mailers/ish_models/application_mailer.rb +6 -0
  11. data/app/models/ish_models/application_record.rb +5 -0
  12. data/app/views/layouts/ish_models/application.html.erb +15 -0
  13. data/config/routes.rb +2 -0
  14. data/lib/ish_models/engine.rb +5 -0
  15. data/lib/ish_models/version.rb +3 -0
  16. data/lib/ish_models.rb +4 -89
  17. data/lib/tasks/ish_models_tasks.rake +4 -0
  18. data/lib/{office/admin_message.rb → wco/profile.rb} +2 -5
  19. metadata +32 -221
  20. data/lib/address.rb +0 -20
  21. data/lib/feature.rb +0 -32
  22. data/lib/gallery.rb +0 -66
  23. data/lib/gameui/asset3d.rb +0 -35
  24. data/lib/gameui/map.rb +0 -260
  25. data/lib/gameui/map_bookmark.rb +0 -9
  26. data/lib/gameui/marker.rb +0 -128
  27. data/lib/iro/alert.rb-bk +0 -72
  28. data/lib/ish/cache_key.rb +0 -14
  29. data/lib/ish/configuration.rb +0 -11
  30. data/lib/ish/crawler.rb +0 -26
  31. data/lib/ish/email_campaign.rb +0 -55
  32. data/lib/ish/email_context.rb +0 -113
  33. data/lib/ish/email_template.rb +0 -115
  34. data/lib/ish/email_unsubscribe.rb +0 -19
  35. data/lib/ish/event.rb +0 -20
  36. data/lib/ish/image_asset.rb +0 -38
  37. data/lib/ish/invoice.rb +0 -130
  38. data/lib/ish/lorem_ipsum.rb +0 -30
  39. data/lib/ish/meeting.rb +0 -31
  40. data/lib/ish/payment.rb +0 -29
  41. data/lib/ish/premium_item.rb +0 -13
  42. data/lib/ish/railtie.rb +0 -8
  43. data/lib/ish/user_profile.rb +0 -146
  44. data/lib/ish/utils.rb +0 -45
  45. data/lib/mongoid/votable.rb +0 -247
  46. data/lib/mongoid/voter.rb +0 -96
  47. data/lib/newsitem.rb +0 -94
  48. data/lib/office/action.rb +0 -32
  49. data/lib/office/action_tie.rb +0 -16
  50. data/lib/office/directmail_envelope.rb +0 -51
  51. data/lib/office/email_action.rb +0 -34
  52. data/lib/office/email_action_tie.rb +0 -18
  53. data/lib/office/email_attachment.rb +0 -12
  54. data/lib/office/email_conversation.rb +0 -86
  55. data/lib/office/email_conversation_lead.rb +0 -11
  56. data/lib/office/email_conversation_tag.rb +0 -14
  57. data/lib/office/email_filter.rb +0 -45
  58. data/lib/office/email_message.rb +0 -229
  59. data/lib/office/email_message_stub.rb +0 -22
  60. data/lib/office/lead_action.rb +0 -24
  61. data/lib/office/lead_action_template.rb +0 -47
  62. data/lib/office/obfuscated_redirect.rb +0 -12
  63. data/lib/office/scheduled_email_action.rb +0 -62
  64. data/lib/photo.rb +0 -87
  65. data/lib/report.rb +0 -65
  66. data/lib/video.rb +0 -91
  67. data/lib/wco/appliance.rb +0 -43
  68. data/lib/wco/appliance_tmpl.rb +0 -36
  69. data/lib/wco/leadset.rb +0 -17
  70. data/lib/wco/price.rb +0 -30
  71. data/lib/wco/product.rb +0 -35
  72. data/lib/wco/serverhost.rb +0 -100
  73. data/lib/wco/subscription.rb +0 -25
data/lib/photo.rb DELETED
@@ -1,87 +0,0 @@
1
-
2
- # require 'aws-sdk'
3
- require 'mongoid_paperclip'
4
-
5
- class Photo
6
- include Mongoid::Document
7
- include Mongoid::Timestamps
8
- include Mongoid::Paperclip
9
- include Ish::Utils
10
-
11
- belongs_to :user_profile, :optional => true, :class_name => 'Ish::UserProfile'
12
- belongs_to :user_profile, :optional => true, :class_name => 'Ish::UserProfile', :inverse_of => :profile_photo
13
- belongs_to :email_message, :optional => true, :class_name => 'Office::EmailMessage'
14
- belongs_to :report, :optional => true
15
- belongs_to :gallery, :optional => true
16
- belongs_to :newsitem, :optional => true
17
-
18
- # photo.photo.to_s.split('/').last.split('?').first
19
- field :name, :type => String
20
- def name
21
- return self[:name] if self[:name]
22
- update_attribute(:name, self.photo.to_s.split('/').last.split('?').first)
23
- name
24
- end
25
-
26
- field :ordering, type: :integer
27
- index({ ordering: -1 })
28
-
29
- field :descr, :type => String
30
- field :subhead
31
- field :weight, :type => Integer, :default => 10
32
-
33
- field :is_public, :type => Boolean, :default => true
34
- field :is_trash, :type => Boolean, :default => false # @TODO: nuke this boolean _vp_ 20170515
35
- default_scope ->{ where({ :is_trash => false }) }
36
-
37
- has_mongoid_attached_file :photo,
38
- :styles => {
39
- :mini => '20x20#',
40
- :thumb => "100x100#",
41
- :thumb2 => "200x200#",
42
- :s169 => "640x360#",
43
- :small => "400x400>",
44
- :large => '950x650>',
45
- },
46
- :storage => :s3,
47
- :s3_credentials => ::S3_CREDENTIALS,
48
- :path => "photos/:style/:id/:filename",
49
- :s3_protocol => 'https',
50
- :validate_media_type => false,
51
- s3_region: ::S3_CREDENTIALS[:region]
52
- validates_attachment_content_type :photo, :content_type => ["image/webp", "image/jpg", "image/jpeg", "image/png", "image/gif", 'application/octet-stream' ]
53
-
54
- def self.n_per_manager_gallery
55
- 25
56
- end
57
-
58
- def export_fields
59
- %w|
60
- gallery_id
61
- name descr weight is_public is_trash
62
-
63
- photo_file_name photo_content_type photo_file_size photo_updated_at photo_fingerprint
64
- |
65
- end
66
-
67
- ## From: https://gist.github.com/WizardOfOgz/1012107?permalink_comment_id=1442486
68
- attr_accessor :content_type, :image_data, :original_filename
69
- def decode_base64_image
70
- if image_data && content_type && original_filename
71
- decoded_data = Base64.decode64(image_data)
72
-
73
- data = StringIO.new(decoded_data)
74
- data.class_eval do
75
- attr_accessor :content_type, :original_filename
76
- end
77
-
78
- data.content_type = content_type
79
- data.original_filename = File.basename(original_filename)
80
-
81
- self.photo = data
82
- end
83
- end
84
-
85
- end
86
-
87
-
data/lib/report.rb DELETED
@@ -1,65 +0,0 @@
1
- class Report
2
- include ::Mongoid::Document
3
- include ::Mongoid::Timestamps
4
- include Ish::PremiumItem
5
- include Ish::Utils
6
-
7
- field :name, :type => String
8
- validates :name, :presence => true
9
- index({ :name => 1, :is_trash => 1 })
10
-
11
- field :slug
12
- validates :slug, :uniqueness => true, :presence => true
13
- index({ :slug => 1 }, { :unique => true })
14
- before_validation :set_slug, :on => :create
15
-
16
- field :subhead
17
-
18
- ## Can be one of: default (nil), longscroll,
19
- ## wordpress e.g. https://piousbox.com/wp-json/wp/v2/posts?slug=intro
20
- # ITEM_TYPES = %w| longscroll wordpress |
21
- field :item_type, type: String
22
-
23
- field :descr, :type => String
24
- field :raw_json
25
-
26
- field :is_trash, :type => Boolean, :default => false
27
- index({ :is_trash => 1, :is_public => 1 })
28
-
29
- field :is_public, :type => Boolean, :default => true
30
- index({ :is_public => 1 })
31
- scope :public, ->{ where({ is_public: true }) }
32
-
33
- field :x, :type => Float
34
- field :y, :type => Float
35
- field :z, :type => Float
36
-
37
- belongs_to :user_profile, :optional => true, :class_name => 'Ish::UserProfile'
38
- has_and_belongs_to_many :shared_profiles, :class_name => 'Ish::UserProfile', :inverse_of => :shared_reports
39
-
40
- has_one :photo
41
-
42
- has_many :newsitems
43
-
44
- ## @TODO: trash, remove
45
- def self.list conditions = { :is_trash => false }
46
- out = self.where( conditions ).order_by( :name => :asc ).limit( 100 )
47
- [['', nil]] + out.map { |item| [ item.name, item.id ] }
48
- end
49
-
50
- PER_PAGE = 10
51
- def self.paginates_per
52
- self::PER_PAGE
53
- end
54
-
55
- def self.clear
56
- if Rails.env.test?
57
- self.unscoped.each { |r| r.remove }
58
- end
59
- end
60
-
61
- def export_fields
62
- %w| name descr |
63
- end
64
-
65
- end
data/lib/video.rb DELETED
@@ -1,91 +0,0 @@
1
- require 'mongoid/paranoia'
2
- require 'mongoid_paperclip'
3
- require_relative './mongoid/votable.rb'
4
-
5
- class Video
6
- include Mongoid::Document
7
- include Mongoid::Timestamps
8
- include Mongoid::Paperclip
9
- include Mongoid::Paranoia
10
- include Ish::PremiumItem
11
- include Ish::Utils
12
-
13
- include Mongoid::Votable
14
- vote_point self, :up => +1, :down => -1
15
-
16
- PER_PAGE = 6
17
-
18
- field :name, :type => String
19
- field :descr, :type => String, :as => :description
20
- field :subhead ## still need it... 2023-03-24
21
-
22
- field :is_trash, :type => Boolean, :default => false
23
- def is_trash
24
- if deleted_at
25
- true
26
- else
27
- self[:is_trash]
28
- end
29
- end
30
-
31
- field :is_public, :type => Boolean, :default => false
32
-
33
- def published
34
- where({ :is_public => true, :is_trash => false }).order_by({ :created_at => :desc })
35
- end
36
-
37
- field :lead_id, type: :integer
38
-
39
- field :x, type: Float
40
- field :y, type: Float
41
- field :z, type: Float
42
-
43
- field :youtube_id
44
- validates_uniqueness_of :youtube_id, allow_blank: true, case_sensitive: false
45
- before_save { youtube_id.present? || youtube_id = nil }
46
-
47
- belongs_to :user_profile, :class_name => 'Ish::UserProfile', :inverse_of => :videos
48
- has_and_belongs_to_many :shared_profiles, :class_name => 'Ish::UserProfile', :inverse_of => :shared_videos
49
-
50
-
51
- index({ is_trash: 1, user_profile_id: 1, created_at: 1 }, { name: 'idx1' })
52
-
53
- def self.list
54
- [['', nil]] + Video.unscoped.order_by( :created_at => :desc ).map { |item| [ "#{item.created_at.strftime('%Y%m%d')} #{item.name}", item.id ] }
55
- end
56
-
57
- has_mongoid_attached_file :video,
58
- # styles: { :thumb => { geometry: '192x108', format: 'jpeg' }, },
59
- # processors: [ :transcoder ],
60
- :storage => :s3,
61
- :s3_credentials => ::S3_CREDENTIALS,
62
- :path => "videos/:style/:id/:filename",
63
- :s3_protocol => 'https',
64
- :s3_permissions => 'public-read',
65
- :validate_media_type => false,
66
- s3_region: ::S3_CREDENTIALS[:region]
67
- validates_attachment_content_type :video, content_type: /\Avideo\/.*\Z/
68
-
69
- has_mongoid_attached_file :thumb,
70
- :styles => {
71
- :mini => '20x20#',
72
- :thumb => "100x100#",
73
- :thumb2 => "200x200#",
74
- :s169 => "640x360#",
75
- # :s43 => "640x480#",
76
- :small => "400x400>",
77
- :large => '950x650>',
78
- },
79
- :storage => :s3,
80
- :s3_credentials => ::S3_CREDENTIALS,
81
- :path => "videos/:style/:id/thumb_:filename",
82
- :s3_protocol => 'https',
83
- :validate_media_type => false,
84
- s3_region: ::S3_CREDENTIALS[:region]
85
- validates_attachment_content_type :thumb, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif", 'application/octet-stream' ]
86
-
87
- def export_fields
88
- %w| name descr |
89
- end
90
-
91
- end
data/lib/wco/appliance.rb DELETED
@@ -1,43 +0,0 @@
1
-
2
- class Wco::Appliance
3
- include Mongoid::Document
4
- include Mongoid::Timestamps
5
-
6
- field :name
7
- validates :name, uniqueness: { scope: :leadset_id }, presence: true
8
-
9
- field :kind
10
-
11
- field :service_name
12
- field :environment
13
-
14
- field :subdomain
15
- field :domain
16
- def host
17
- "#{subdomain}.#{domain}"
18
- end
19
-
20
- field :leadset_id
21
- def leadset
22
- Leadset.find leadset_id
23
- end
24
-
25
- belongs_to :appliance_tmpl, class_name: 'Wco::ApplianceTmpl'
26
- def tmpl
27
- appliance_tmpl
28
- end
29
-
30
- belongs_to :serverhost, class_name: 'Wco::Serverhost'
31
- belongs_to :wco_leadset, class_name: 'Wco::Leadset', inverse_of: :appliances
32
-
33
- # field :ip
34
- field :port
35
-
36
- STATE_PENDING = 'state-pending'
37
- STATE_LIVE = 'state-live'
38
- STATE_TERM = 'state-term'
39
- field :state, default: STATE_PENDING
40
-
41
- end
42
-
43
-
@@ -1,36 +0,0 @@
1
-
2
- class Wco::ApplianceTmpl
3
- include Mongoid::Document
4
- include Mongoid::Timestamps
5
-
6
- field :kind
7
- validates :kind, uniqueness: { scope: :version }, presence: true
8
-
9
- field :version, type: :string, default: '0.0.0'
10
- validates :version, uniqueness: { scope: :kind }, presence: true
11
- index({ kind: -1, version: -1 }, { name: :kind_version })
12
-
13
- field :descr, type: :string
14
-
15
- field :image
16
- validates :image, presence: true
17
-
18
- field :volume_zip
19
- validates :volume_zip, presence: true
20
-
21
- KIND_CORPHOME1 = 'corphome1'
22
- KIND_DRUPAL = 'drupal'
23
- KIND_HELLOWORLD = 'helloworld'
24
- # KINDS = [ 'smt', 'emailcrm', KIND_CORPHOME1, KIND_HELLOWORLD, KIND_DRUPAL,
25
- # 'mautic', 'matomo',
26
- # 'irowor', 'eCommerce' ]
27
- KINDS = [ KIND_HELLOWORLD ]
28
-
29
- has_many :appliances, class_name: 'Wco::Appliance'
30
-
31
- def self.latest_of kind
32
- where({ kind: kind }).order_by({ version: :desc }).first
33
- end
34
-
35
- end
36
- AppTmpl = Wco::ApplianceTmpl
data/lib/wco/leadset.rb DELETED
@@ -1,17 +0,0 @@
1
-
2
- class Wco::Leadset
3
- include Mongoid::Document
4
- include Mongoid::Timestamps
5
-
6
- field :name
7
-
8
- field :domains, type: :string, default: 'orbital.city'
9
-
10
- has_many :serverhosts, class_name: 'Wco::Serverhost', inverse_of: :wco_leadset
11
- def next_serverhost
12
- serverhosts.first
13
- end
14
-
15
- has_many :appliances, class_name: 'Wco::Appliance', inverse_of: :wco_leadset
16
-
17
- end
data/lib/wco/price.rb DELETED
@@ -1,30 +0,0 @@
1
-
2
- ##
3
- ## Not used. _vp_ 2023-09-07
4
- ## Just replicating the Stripe structure.
5
- ##
6
- class Wco::Price
7
- include Mongoid::Document
8
- include Mongoid::Timestamps
9
-
10
- belongs_to :product, class_name: '::Wco::Product', inverse_of: :prices
11
-
12
- has_many :subscriptions, class_name: '::Wco::Subscription', inverse_of: :price, foreign_key: :wco_price_id
13
-
14
- field :amount_cents, type: Integer
15
-
16
- INTERVALS = [ nil, 'day', 'week', 'month', 'year' ]
17
- field :interval, type: String
18
-
19
- field :price_id # stripe
20
-
21
- def name
22
- "$#{ amount_cents.to_f/100 } / #{interval}"
23
- end
24
- def name_simple
25
- "$#{ amount_cents.to_f/100 }"
26
- end
27
-
28
- end
29
-
30
-
data/lib/wco/product.rb DELETED
@@ -1,35 +0,0 @@
1
-
2
- class Wco::Product
3
- include Mongoid::Document
4
- include Mongoid::Timestamps
5
-
6
- field :name
7
-
8
- field :product_id # stripe
9
-
10
- ## @TODO: remove, interval makes no sense on product! replace with Wco::Price . _vp_ 2023-09-07
11
- # has_many :subscriptions, class_name: '::Wco::Subscription', inverse_of: :subscription
12
-
13
- has_many :prices, class_name: '::Wco::Price', inverse_of: :product
14
-
15
- def self.list
16
- [ [nil,nil] ] + self.all.order_by({ name: :asc }).map { |i| [i.name, i.id] }
17
- end
18
-
19
- end
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
- ## @TODO: remove, interval makes no sense on product! replace with Wco::Price . _vp_ 2023-09-07
30
- # INTERVALS = [ nil, 'day', 'week', 'month', 'year' ]
31
- # field :interval, type: String
32
- ## @TODO: remove, interval makes no sense on product! replace with Wco::Price . _vp_ 2023-09-07
33
- # field :price_id # stripe
34
- ## @TODO: remove, interval makes no sense on product! replace with Wco::Price . _vp_ 2023-09-07
35
- # field :price_cents, type: Integer
@@ -1,100 +0,0 @@
1
-
2
- require 'net/scp'
3
-
4
- class Wco::Serverhost
5
- include Mongoid::Document
6
- include Mongoid::Timestamps
7
- # include Mongoid::Autoinc
8
-
9
- field :name, type: :string
10
- # validates :name, uniqueness: { scope: :leadset_id }, presence: true
11
- validates :name, uniqueness: { scope: :wco_leadset }, presence: true
12
-
13
- # field :leadset_id, type: :integer
14
- # has_and_belongs_to_many :leadsets, class_name: 'Wco::Leadset', inverse_of: :serverhosts
15
- belongs_to :wco_leadset, class_name: 'Wco::Leadset'
16
-
17
- field :next_port, type: :integer, default: 8000
18
-
19
- ## net-ssh, sshkit
20
- field :ssh_host
21
- # field :ssh_username
22
- # field :ssh_key
23
- field :nginx_root, default: '/opt/nginx'
24
-
25
- has_many :appliances, class_name: 'Wco::Appliance'
26
-
27
- # def nginx_add_site rendered_str=nil, config={}
28
- # # puts! config, '#nginx_add_site'
29
- # File.write( "/usr/local/etc/nginx/sites-available/#{config[:service_name]}", rendered_str )
30
- # out = `sudo nginx enable-site #{config[:service_name]} ; \
31
- # nginx -s reload ; \
32
- # echo ok
33
- # `;
34
- # puts! out, 'out'
35
- # end
36
-
37
- def nginx_add_site rendered_str=nil, config={}
38
- puts! rendered_str, '#nginx_add_site // rendered_str'
39
- puts! config, '#nginx_add_site // config'
40
-
41
- File.write( "tmp/#{config[:service_name]}", rendered_str )
42
- Net::SSH.start( ssh_host, ssh_username, keys: ssh_key ) do |ssh|
43
-
44
- out = ssh.scp.upload! "tmp/#{config[:service_name]}", "#{nginx_root}/conf/sites-available/"
45
- puts! out, 'out'
46
-
47
- out = ssh.exec! "#{nginx_root}/nginx enable-site #{config[:service_name]} ; #{nginx_root}/nginx -s reload"
48
- puts! out, 'out'
49
-
50
- end
51
-
52
- end
53
-
54
- WORKDIR = "/opt/projects/docker"
55
-
56
- def add_docker_service app={}
57
- puts! app, '#add_docker_service'
58
-
59
- ac = ActionController::Base.new
60
- ac.instance_variable_set( :@app, app )
61
- ac.instance_variable_set( :@workdir, WORKDIR )
62
- rendered_str = ac.render_to_string("docker-compose/dc-#{app[:kind]}")
63
- puts '+++ add_docker_service rendered_str:'
64
- print rendered_str
65
-
66
- file = Tempfile.new('prefix')
67
- file.write rendered_str
68
- file.close
69
- puts! file.path, 'file.path'
70
-
71
- `scp #{file.path} #{ssh_host}:#{WORKDIR}/dc-#{app[:service_name]}.yml`
72
- `ssh #{ssh_host} 'cd #{WORKDIR} ; \
73
- docker compose -f dc-#{app[:service_name]}.yml up -d #{app[:service_name]} ; \
74
- echo ok #add_docker_service ' `
75
- end
76
-
77
- def create_volume app={}
78
- # puts! app, '#create_volume'
79
-
80
- ac = ActionController::Base.new
81
- ac.instance_variable_set( :@app, app )
82
- ac.instance_variable_set( :@workdir, WORKDIR )
83
- rendered_str = ac.render_to_string("scripts/create_volume")
84
- # puts '+++ create_volume rendered_str:'
85
- # print rendered_str
86
-
87
- file = Tempfile.new('prefix')
88
- file.write rendered_str
89
- file.close
90
- # puts! file.path, 'file.path'
91
-
92
- `scp #{file.path} #{ssh_host}:#{WORKDIR}/scripts/create_volume`
93
- `ssh #{ssh_host} 'chmod a+x #{WORKDIR}/scripts/create_volume ; \
94
- #{WORKDIR}/scripts/create_volume ' `
95
- end
96
- # alias_method :create_volume, :create_volume_2
97
-
98
-
99
- end
100
-
@@ -1,25 +0,0 @@
1
-
2
- class Wco::Subscription
3
- include Mongoid::Document
4
- include Mongoid::Timestamps
5
-
6
- field :customer_id, type: :string # stripe
7
- field :price_id, type: :string # stripe
8
-
9
- field :leadset_id
10
- def leadset
11
- Leadset.find leadset_id
12
- end
13
-
14
- field :quantity, type: :integer
15
-
16
- belongs_to :product, class_name: '::Wco::Product', inverse_of: :subscriptions
17
- belongs_to :price, class_name: '::Wco::Price', inverse_of: :subscriptions, foreign_key: :wco_price_id
18
-
19
- ## This was for ACL on wco dashboard? Should that be the same class?
20
- ## @TODO: optional ?!
21
- belongs_to :profile, class_name: '::Ish::UserProfile', inverse_of: :subscriptions, optional: true
22
-
23
- end
24
-
25
-