ish_models 0.0.33.222 → 0.0.33.225

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: b562a6867b92d564d8d4df8f8179a58e6892e56854a7de8d8958a80a7c1c1bed
4
- data.tar.gz: 1cdd3a6792562f562809b22cf24b681da0c56cb8fa9fca1482bdf20c571b98d4
3
+ metadata.gz: dcf6779d3d2bafd20719969eb3a2c13681784ce9a6486e444fd8407299b68b10
4
+ data.tar.gz: 5a0de640fd761b5af8709aae17be40572284c3462fb214849b26dfb440595d7e
5
5
  SHA512:
6
- metadata.gz: 63d0c5e0238065956ed91e7e16ee7579d38e9aa77e5dfe2615495b47bcee5a4295ff18f90345dcc264b7ef0d8cc343aeb08abf46fb37f0790e891e308f13b614
7
- data.tar.gz: c5c9244893ebf49c9614b76e685e0dcd7c03da8ea62d4daa4103a3baf0cf8b2f3fe685db597da0be0a45ffba17258732aa85f72be744f22b6a60544c401f155b
6
+ metadata.gz: bb445008b52c1d966e8b190241ff6621e3799d0a242221c0b618d1cbd24a75a6f8ddfac7f3f3f39e0815b0dbc849c02d8f107bb16ce915786afd18f3adbaa129
7
+ data.tar.gz: a6d9882e974666522ec2358b443f0c4deac2fda3b20ac0a8b68f9adabf606fcc02264b5876003f803129a69a609c1cd758d644dfb83e2050eca6f959a8d13014
data/lib/gallery.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  class Gallery
3
3
  include ::Mongoid::Document
4
4
  include ::Mongoid::Timestamps
5
+ include Ish::PremiumItem
5
6
  include Ish::Utils
6
7
 
7
8
  PER_PAGE = 6
@@ -17,13 +18,6 @@ class Gallery
17
18
  field :is_trash, type: Boolean, default: false
18
19
  field :is_done, type: Boolean, default: false
19
20
 
20
- field :premium_tier, type: Integer, default: 0 # how many stars need to spend, to get access? 0 = free
21
- def is_premium
22
- premium_tier > 0
23
- end
24
- def premium?; is_premium; end
25
- has_many :premium_purchases, class_name: '::Gameui::PremiumPurchase', as: :item
26
-
27
21
  default_scope ->{ where({ :is_public => true, :is_trash => false }).order_by({ :created_at => :desc }) }
28
22
 
29
23
  field :x, :type => Float
data/lib/ish/payment.rb CHANGED
@@ -1,11 +1,11 @@
1
1
 
2
-
3
2
  class Ish::Payment
4
3
  include Mongoid::Document
5
4
  include Mongoid::Timestamps
6
5
 
7
- belongs_to :invoice, :class_name => 'Ish::Invoice', optional: true
8
- belongs_to :profile, :class_name => 'Ish::UserProfile' # , :optional => true
6
+ belongs_to :invoice, class_name: 'Ish::Invoice', optional: true
7
+ belongs_to :profile, class_name: 'Ish::UserProfile'
8
+ belongs_to :item, polymorphic: true
9
9
 
10
10
  field :amount, :type => Integer # in cents
11
11
  field :charge, :type => Hash
@@ -14,16 +14,15 @@ class Ish::Payment
14
14
  field :client_secret
15
15
  field :payment_intent_id
16
16
 
17
- field :status, type: Symbol
17
+ STATUS_CONFIRMED = 'confirmed'
18
+ STATUS_PENDING = 'pending'
19
+ STATUSES = %w| active pending |
20
+ field :status, type: Symbol, default: STATUS_PENDING
21
+ scope :confirmed, ->{ where( status: STATUS_CONFIRMED ) }
18
22
 
19
23
  after_create :compute_paid_invoice_amount
20
-
21
- protected
22
-
23
24
  def compute_paid_invoice_amount
24
- if self.invoice
25
- self.invoice.update_attributes :paid_amount => self.invoice.paid_amount + self.amount
26
- end
25
+ self.invoice&.update_attributes({ paid_amount: self.invoice.paid_amount + self.amount })
27
26
  end
28
27
 
29
28
  end
@@ -2,13 +2,12 @@
2
2
  module Ish::PremiumItem
3
3
 
4
4
  def self.included base
5
- base.send :field, :premium_tier, type: Integer, default: 0 # how many stars need to spend, to get access? 0 = free
6
- base.send :has_many, :premium_purchases, class_name: '::Gameui::PremiumPurchase', as: :item
5
+ base.send :field, :premium_tier, type: Integer, default: 0 # how many unlocks are need, to get access? 0 = free
6
+ base.send :has_many, :premium_purchases, class_name: '::Ish::Payment', as: :item
7
7
  end
8
8
 
9
9
  def is_premium
10
10
  premium_tier > 0
11
11
  end
12
- def premium?; is_premium; end
13
12
 
14
13
  end
@@ -2,7 +2,9 @@
2
2
  require 'ish/utils'
3
3
  require 'mongoid/votable'
4
4
 
5
- ## @TODO: rename to Ish::Profile
5
+ ##
6
+ ## It explicitly doesn't have a relation to user! Use email as key.
7
+ ##
6
8
  class Ish::UserProfile
7
9
  include Mongoid::Document
8
10
  include Mongoid::Timestamps
@@ -38,48 +40,18 @@ class Ish::UserProfile
38
40
  ROLE_ADMIN = :admin
39
41
  field :role_name, :type => Symbol, default: :guy
40
42
 
41
- has_one :profile_photo, :class_name => 'Photo', :inverse_of => :profile_city
42
-
43
- # belongs_to :user
44
- # validates_presence_of :user
45
-
46
- belongs_to :current_city, :class_name => 'City', :inverse_of => :current_users, :optional => true
47
- belongs_to :guide_city, :class_name => 'City', :inverse_of => :guide, :optional => true
48
-
49
- has_many :galleries, :inverse_of => :user_profile
50
- has_and_belongs_to_many :shared_galleries, :inverse_of => :shared_profiles, class_name: 'Gallery'
51
- has_and_belongs_to_many :shared_markers, :inverse_of => :shared_profiles, class_name: 'Gameui::Marker'
52
- has_many :my_markers, :inverse_of => :creator_profile, class_name: 'Gameui::Marker'
53
- has_and_belongs_to_many :shared_locations, :inverse_of => :shared_profiles, class_name: 'Gameui::Map'
54
- has_many :my_maps, :inverse_of => :creator_profile, class_name: 'Gameui::Map'
55
-
56
- has_many :invoices, :class_name => '::Ish::Invoice'
43
+ has_one :profile_photo, inverse_of: :profile_city, class_name: 'Photo'
44
+ has_many :galleries, inverse_of: :user_profile
45
+ has_and_belongs_to_many :shared_galleries, inverse_of: :shared_profiles, class_name: 'Gallery'
46
+ has_and_belongs_to_many :shared_markers, inverse_of: :shared_profiles, class_name: 'Gameui::Marker'
47
+ has_and_belongs_to_many :shared_locations, inverse_of: :shared_profiles, class_name: 'Gameui::Map'
48
+ has_many :my_markers, inverse_of: :creator_profile, class_name: 'Gameui::Marker'
49
+ has_many :my_locations, inverse_of: :creator_profile, class_name: 'Gameui::Map'
50
+ has_many :invoices, class_name: '::Ish::Invoice'
57
51
  has_many :photos
58
- has_many :reports, inverse_of: :user_profile
59
-
60
- ## @TODO: do something about this.
61
- # has_many :stock_watches, class_name: 'IronWarbler::StockWatch'
62
- # has_many :option_watches, class_name: 'IronWarbler::OptionWatch'
63
-
52
+ has_many :reports, inverse_of: :user_profile
64
53
  has_many :videos, inverse_of: :user_profile
65
- has_many :newsitems, inverse_of: :profile # @TODO: remove? denorm handle over here?
66
-
67
- has_and_belongs_to_many :bookmarked_locations, class_name: '::Gameui::Map', inverse_of: :bookmarked_profile
68
- def bookmarks
69
- bookmarked_locations
70
- end
71
-
72
- has_and_belongs_to_many :friends, :class_name => '::Ish::UserProfile', :inverse_of => :friendeds
73
- has_and_belongs_to_many :friendeds, :class_name => '::Ish::UserProfile', :inverse_of => :friends
74
-
75
- field :n_unlocks, type: Integer, default: 0
76
- def n_coins # @deprecated, do not use
77
- n_unlocks
78
- end
79
-
80
- ## preferences
81
- ## @TODO: better naming convention, or remove this
82
- field :videos_embed, :type => Boolean, :default => false
54
+ has_many :newsitems, inverse_of: :profile
83
55
 
84
56
  def sudoer?
85
57
  %w( piousbox@gmail.com victor@wasya.co ).include?( self.email )
@@ -89,22 +61,22 @@ class Ish::UserProfile
89
61
  ## @TODO: check this, this is shit. _vp_ 20170527
90
62
  def self.list
91
63
  out = self.all.order_by( :domain => :asc, :lang => :asc )
92
- [['', nil]] + out.map { |item| [ item.name, item.id ] }
64
+ [['', nil]] + out.map { |item| [ "#{item.email} :: #{item.name}", item.id ] }
93
65
  end
94
66
 
95
- ##
96
- ## GameUI
97
- ##
98
- field :n_stars, type: Integer, default: 0
99
- has_many :premium_purchases, :class_name => '::Gameui::PremiumPurchase'
67
+ field :n_unlocks, type: Integer, default: 0
68
+
69
+ has_many :payments, :class_name => '::Ish::Payment'
70
+
100
71
  def has_premium_purchase item
101
- item.premium_purchases.where( user_profile_id: self.id ).exists?
102
- end
103
- def premium_purchases
104
- ::Gameui::PremiumPurchase.where( user_profile_id: self.id )
72
+ payments.confirmed.where( item: item ).exists?
105
73
  end
74
+
106
75
  field :is_purchasing, type: Boolean, default: false
107
76
 
77
+ has_and_belongs_to_many :friends, :class_name => '::Ish::UserProfile', inverse_of: :friendeds
78
+ has_and_belongs_to_many :friendeds, :class_name => '::Ish::UserProfile', inverse_of: :friends
79
+
108
80
  # used in rake tasks
109
81
  def self.generate delta
110
82
  email = delta[:email]
@@ -113,7 +85,6 @@ class Ish::UserProfile
113
85
 
114
86
  profile = Ish::UserProfile.where( email: email ).first
115
87
  if profile
116
- puts!( profile, "UserProfile#generate, already exists" ) if !Rails.env.test?
117
88
  return
118
89
  end
119
90
 
data/lib/ish_models.rb CHANGED
@@ -8,6 +8,9 @@ require 'kaminari/mongoid'
8
8
 
9
9
  class Gameui; end
10
10
 
11
+ class Iro; end
12
+ class Iro::OptionPriceItem; end
13
+
11
14
  module Ish; end
12
15
  class Ish::InputError < RuntimeError; end
13
16
 
@@ -39,12 +42,11 @@ require 'mongoid/voter'
39
42
 
40
43
  require 'gameui/asset3d'
41
44
  require 'gameui/map'
42
- require 'gameui/map_bookmark'
43
45
  require 'gameui/marker'
44
- require 'gameui/premium_purchase'
45
46
 
46
47
  # require 'iro/option_price_item'
47
48
 
49
+
48
50
  require 'ish/cache_key'
49
51
  require 'ish/crawler'
50
52
  require 'ish/email_campaign'
@@ -20,4 +20,4 @@ class Office::EmailMessageStub
20
20
  field :wp_term_ids, type: :array, default: []
21
21
 
22
22
  end
23
- EMS = Office::EmailMessageStub
23
+ MsgStub = EMS = Office::EmailMessageStub
data/lib/report.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  class Report
2
2
  include ::Mongoid::Document
3
3
  include ::Mongoid::Timestamps
4
+ include Ish::PremiumItem
4
5
  include Ish::Utils
5
6
 
6
7
  field :name, :type => String
@@ -83,14 +84,6 @@ class Report
83
84
  end
84
85
  end
85
86
 
86
- ## copy-paste
87
- field :premium_tier, type: Integer, default: 0 # how many stars need to spend, to get access? 0 = free
88
- def is_premium
89
- premium_tier > 0
90
- end
91
- def premium?; is_premium; end
92
- has_many :premium_purchases, class_name: '::Gameui::PremiumPurchase', as: :item
93
-
94
87
  def export_fields
95
88
  %w| name descr |
96
89
  end
data/lib/video.rb CHANGED
@@ -7,6 +7,7 @@ class Video
7
7
  include Mongoid::Timestamps
8
8
  include Mongoid::Paperclip
9
9
  include Mongoid::Paranoia
10
+ include Ish::PremiumItem
10
11
  include Ish::Utils
11
12
 
12
13
  include Mongoid::Votable
@@ -75,26 +76,8 @@ class Video
75
76
  s3_region: ::S3_CREDENTIALS[:region]
76
77
  validates_attachment_content_type :thumb, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif", 'application/octet-stream' ]
77
78
 
78
- ## copy-paste
79
- field :premium_tier, type: Integer, default: 0 # how many stars need to spend, to get access? 0 = free
80
- def is_premium
81
- premium_tier > 0
82
- end
83
- def premium?; is_premium; end
84
- has_many :premium_purchases, class_name: '::Gameui::PremiumPurchase', as: :item
85
-
86
79
  def export_fields
87
80
  %w| name descr |
88
81
  end
89
82
 
90
-
91
-
92
83
  end
93
-
94
-
95
- =begin
96
- field :issue
97
-
98
- field :is_feature, :type => Boolean, :default => false
99
- field :lang, :type => String, :default => 'en'
100
- =end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33.222
4
+ version: 0.0.33.225
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
@@ -135,7 +135,6 @@ files:
135
135
  - lib/gameui/map.rb
136
136
  - lib/gameui/map_bookmark.rb
137
137
  - lib/gameui/marker.rb
138
- - lib/gameui/premium_purchase.rb
139
138
  - lib/ish/cache_key.rb
140
139
  - lib/ish/configuration.rb
141
140
  - lib/ish/crawler.rb
@@ -1,11 +0,0 @@
1
-
2
- class ::Gameui::PremiumPurchase
3
- include Mongoid::Document
4
- include Mongoid::Timestamps
5
-
6
- belongs_to :user_profile, :class_name => '::Ish::UserProfile'
7
- belongs_to :item, polymorphic: true
8
-
9
- end
10
-
11
- ::Purchase = ::Gameui::PremiumPurchase