ish_models 0.0.33.129 → 0.0.33.133

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: 9ddb473d3919f9fbd1f3776bac2dbee971c7191428d5bc18fb31c3a3412a73eb
4
- data.tar.gz: 52aea5b794ff6a8f9dae484a7b364aa72df71bcbfb012ab43492d743d4a4badd
3
+ metadata.gz: 2d50f29ed3d0a85e7d16177bd79b9fe6c3271ad17b4cb888c81c44b451a1f28d
4
+ data.tar.gz: 8ab4c58c78a5967a2096d9aacc58a0568442ea1ff3477d353cbe8a42f3ce5ded
5
5
  SHA512:
6
- metadata.gz: cd05ef3be3aa54a2bf92e33aa9404dc654ecb25c288ed728836184d68a53adee5ecc9dc279a3c35b771fa0178f2ae10a9f89006a18c7dd9a50154c332fa34034
7
- data.tar.gz: 9cb96337052e622e4ea2545724fe32241d0949849dd3e09ad79186f3ba3c46bb1df328ec4c8acb5d6a5fc00ed4ec2f7d3390783edcba5a5e0792f0d1506db707
6
+ metadata.gz: 1e53ea5ade3eaec46a41f2469c27ff60bf4feaf8e989cc1091173e16d4788e4f262150f5b84045c3d717fadd4f4fad09e982474d11fddd0b2f7bf5b1a0abeffc
7
+ data.tar.gz: 6c618c59a51c4a05dec7725cf21211bf5ce9b5f35dea634ed83f1f1db98a5252f00199096de651ae75ec1199ae36a0295d2a993fcc564c0a80c8ee3d2ba66d27
data/lib/gameui/map.rb CHANGED
@@ -4,21 +4,42 @@ class ::Gameui::Map
4
4
  include Mongoid::Timestamps
5
5
 
6
6
  has_many :markers, :class_name => '::Gameui::Marker', inverse_of: :map
7
+ has_many :newsitems, inverse_of: :map
7
8
 
8
9
  field :slug
9
10
  validates :slug, uniqueness: true, presence: true
11
+
10
12
  field :parent_slug
13
+ belongs_to :parent, class_name: '::Gameui::Map', inverse_of: :childs, optional: true
14
+ has_many :childs, class_name: '::Gameui::Map', inverse_of: :parent
15
+ has_one :image, class_name: '::Ish::ImageAsset', inverse_of: :location
11
16
 
12
- field :w, type: Integer
13
- validates :w, presence: true
17
+ has_and_belongs_to_many :bookmarked_profiles, class_name: '::IshModels::UserProfile', inverse_of: :bookmarked_location
14
18
 
15
- field :h, type: Integer
16
- validates :h, presence: true
19
+ field :map_slug
20
+ def map
21
+ ::Gameui::Map.where( slug: map_slug ).first
22
+ end
17
23
 
24
+ field :name
18
25
  field :description
19
26
 
27
+ # @deprecated, dont use!
20
28
  field :img_path
21
29
 
30
+ field :w, type: Integer
31
+ validates :w, presence: true
32
+ field :h, type: Integer
33
+ validates :h, presence: true
34
+
35
+ # @TODO: this is shared between map and marker, move to a concern.
36
+ before_validation :compute_w_h
37
+ def compute_w_h
38
+ geo = Paperclip::Geometry.from_file(Paperclip.io_adapters.for(image.image))
39
+ self.w = geo.width
40
+ self.h = geo.height
41
+ end
42
+
22
43
  ORDERING_TYPE_ALPHABETIC = 'alphabetic'
23
44
  ORDERING_TYPE_CUSTOM = 'custom'
24
45
  ORDERING_TYPE_TIMESTAMP = 'timestamp'
@@ -26,5 +47,19 @@ class ::Gameui::Map
26
47
  field :ordering_type, type: String, default: 'custom' # timestamp, alphabetic, custom
27
48
  validates :ordering_type, presence: true
28
49
 
29
-
50
+ def self.list conditions = { is_trash: false }
51
+ out = self.order_by( created_at: :desc )
52
+ [[nil, nil]] + out.map { |item| [ item.name, item.id ] }
53
+ end
54
+
55
+ def breadcrumbs
56
+ out = [{ name: self.name, slug: self.slug, link: false }]
57
+ p = self.parent
58
+ while p
59
+ out.push({ name: p.name, slug: p.slug })
60
+ p = p.parent
61
+ end
62
+ out.reverse
63
+ end
64
+
30
65
  end
@@ -0,0 +1,9 @@
1
+
2
+ class ::Gameui::MapBookmark
3
+ include Mongoid::Document
4
+ include Mongoid::Timestamps
5
+
6
+ belongs_to :profile, class_name: 'IshModels::UserProfile'
7
+ belongs_to :location, class_name: '::Gameui::Map'
8
+
9
+ end
data/lib/gameui/marker.rb CHANGED
@@ -8,21 +8,37 @@ class ::Gameui::Marker
8
8
  field :slug
9
9
  validates :slug, uniqueness: true, presence: true
10
10
 
11
+ field :description
12
+
13
+ has_one :image, class_name: '::Ish::ImageAsset', inverse_of: :marker_image
14
+ has_one :title_image, class_name: '::Ish::ImageAsset', inverse_of: :marker_title_image
15
+
16
+
17
+ # @deprecated, don't use!
18
+ # _vp_ 2021-09-23
19
+ field :img_path
20
+ # validates :img_path, presence: true
21
+ field :title_img_path
22
+ # validates :title_img_path, presence: true
11
23
  field :w, type: Integer
12
24
  validates :w, presence: true
13
25
  field :h, type: Integer
14
26
  validates :h, presence: true
15
- field :x, type: Integer
16
- validates :x, presence: true
17
- field :y, type: Integer
18
- validates :y, presence: true
19
-
20
- field :img_path
21
- validates :img_path, presence: true
22
- field :title_img_path
23
- validates :title_img_path, presence: true
24
-
25
- field :description
27
+ field :x, type: Integer, default: 0
28
+ # validates :x, presence: true
29
+ field :y, type: Integer, default: 0
30
+ # validates :y, presence: true
31
+ field :centerOffsetX, type: Integer, default: 0
32
+ # validates :centerXOffset, presence: true
33
+ field :centerOffsetY, type: Integer, default: 0
34
+ # validates :centerYOffset, presence: true
35
+
36
+ before_validation :compute_w_h
37
+ def compute_w_h
38
+ geo = Paperclip::Geometry.from_file(Paperclip.io_adapters.for(image.image))
39
+ self.w = geo.width
40
+ self.h = geo.height
41
+ end
26
42
 
27
43
  field :is_active, type: Boolean, default: true
28
44
  field :deleted_at, type: Time, default: nil
@@ -38,6 +54,7 @@ class ::Gameui::Marker
38
54
  field :item_type, type: String
39
55
  validates :item_type, presence: true
40
56
 
57
+ field :url
41
58
 
42
59
  end
43
60
 
@@ -0,0 +1,27 @@
1
+ class Ish::ImageAsset
2
+ require 'aws-sdk'
3
+
4
+ include Mongoid::Document
5
+ include Mongoid::Timestamps
6
+ include Mongoid::Paperclip
7
+
8
+ belongs_to :location, class_name: 'Gameui::Map', inverse_of: :image, optional: true
9
+ belongs_to :marker_image, class_name: 'Gameui::Map', inverse_of: :image, optional: true
10
+ belongs_to :marker_title_image, class_name: 'Gameui::Map', inverse_of: :title_image, optional: true
11
+
12
+ has_mongoid_attached_file :image,
13
+ :styles => {
14
+ :thumb => "100x100#",
15
+ },
16
+ :storage => :s3,
17
+ :s3_credentials => ::S3_CREDENTIALS,
18
+ :path => "image_assets/:style/:id/:filename",
19
+ :s3_protocol => 'https',
20
+ :validate_media_type => false,
21
+ s3_region: ::S3_CREDENTIALS[:region]
22
+
23
+ validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif", 'application/octet-stream' ]
24
+
25
+ end
26
+
27
+
@@ -10,6 +10,7 @@ class IshModels::UserProfile
10
10
  field :email
11
11
  # validates_format_of :email, :with => ::Devise::email_regexp
12
12
  validates_format_of :email,:with => /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/
13
+ validates_uniqueness_of :email
13
14
 
14
15
  field :fb_access_token
15
16
  field :fb_long_access_token
@@ -35,10 +36,18 @@ class IshModels::UserProfile
35
36
  has_many :videos, :inverse_of => :user_profile
36
37
  has_many :newsitems, inverse_of: :user_profile
37
38
 
39
+ has_and_belongs_to_many :bookmarked_locations, class_name: '::Gameui::Map', inverse_of: :bookmarked_profile
40
+ def bookmarks
41
+ bookmarked_locations
42
+ end
43
+
38
44
  has_and_belongs_to_many :friends, :class_name => 'IshModels::UserProfile', :inverse_of => :friendeds
39
45
  has_and_belongs_to_many :friendeds, :class_name => 'IshModels::UserProfile', :inverse_of => :friends
40
46
 
41
47
  field :n_unlocks, type: Integer, default: 0
48
+ def n_coins
49
+ n_unlocks
50
+ end
42
51
 
43
52
  #
44
53
  # preferences
@@ -72,7 +81,10 @@ class IshModels::UserProfile
72
81
  field :n_stars, type: Integer, default: 0
73
82
  has_many :premium_purchases, :class_name => '::Gameui::PremiumPurchase'
74
83
  def has_premium_purchase item
75
- item.premium_purchases.where( user_profile: self ).exists?
84
+ item.premium_purchases.where( user_profile_id: self.id ).exists?
85
+ end
86
+ def premium_purchases
87
+ ::Gameui::PremiumPurchase.where( user_profile_id: self.id )
76
88
  end
77
89
 
78
90
  end
data/lib/ish_models.rb CHANGED
@@ -30,6 +30,7 @@ require 'co_tailors/address.rb'
30
30
 
31
31
  require 'gameui'
32
32
  require 'gameui/map.rb'
33
+ require 'gameui/map_bookmark.rb'
33
34
  require 'gameui/marker.rb'
34
35
  require 'gameui/premium_purchase.rb'
35
36
 
@@ -37,6 +38,7 @@ require 'ish/ameritrade'
37
38
  require 'ish/covered_call'
38
39
  require 'ish/crawler.rb'
39
40
  require 'ish/gallery_name.rb'
41
+ require 'ish/image_asset.rb'
40
42
  require 'ish/input_error.rb'
41
43
  require 'ish/iron_condor.rb'
42
44
  require 'ish/iron_condor_watcher.rb'
data/lib/newsitem.rb CHANGED
@@ -7,7 +7,8 @@ class Newsitem
7
7
  belongs_to :city, :optional => true
8
8
  belongs_to :report, :optional => true
9
9
  belongs_to :user_profile, class_name: 'IshModels::UserProfile', optional: true
10
-
10
+ belongs_to :map, class_name: '::Gameui::Map', optional: true
11
+
11
12
  belongs_to :gallery, :optional => true
12
13
  def gallery
13
14
  self.gallery_id ? Gallery.unscoped.find( self.gallery_id ) : nil
@@ -43,7 +44,7 @@ class Newsitem
43
44
  unless item[:report_id].blank?
44
45
  n.report = Report.find item[:report_id]
45
46
  end
46
-
47
+
47
48
  unless item[:gallery_id].blank?
48
49
  n.gallery = Gallery.find item[:gallery_id]
49
50
  end
@@ -52,5 +53,5 @@ class Newsitem
52
53
 
53
54
  return n
54
55
  end
55
-
56
+
56
57
  end
data/lib/photo.rb CHANGED
@@ -10,37 +10,36 @@ class Photo
10
10
  # field :username, :type => String
11
11
 
12
12
  has_and_belongs_to_many :viewers, :class_name => 'User', :inverse_of => :viewable_photos
13
-
13
+
14
14
  belongs_to :user_profile, :class_name => 'IshModels::UserProfile', :optional => true
15
15
  def user; user_profile; end
16
16
  belongs_to :profile_city, :class_name => 'City', :inverse_of => :profile_photo, :optional => true
17
17
  belongs_to :profile_venue, :class_name => 'Venue', :inverse_of => :profile_photo, :optional => true
18
18
  belongs_to :profile_event, :class_name => 'Event', :inverse_of => :profile_photo, :optional => true
19
-
19
+
20
20
  belongs_to :report, :optional => true
21
21
  belongs_to :venue, :optional => true
22
22
  belongs_to :event, :optional => true
23
23
  belongs_to :feature, :optional => true
24
24
  belongs_to :gallery, :optional => true
25
25
  belongs_to :newsitem, :optional => true
26
-
26
+
27
27
  field :name, :type => String
28
28
  field :descr, :type => String
29
29
  field :weight, :type => Integer, :default => 10
30
-
30
+
31
31
  field :is_public, :type => Boolean, :default => true
32
32
 
33
33
  # @TODO: nuke this boolean _vp_ 20170515
34
34
  field :is_trash, :type => Boolean, :default => false
35
35
  default_scope ->{ where({ :is_trash => false }) }
36
36
 
37
- has_mongoid_attached_file :photo,
37
+ has_mongoid_attached_file :photo,
38
38
  :styles => {
39
39
  :mini => '20x20#',
40
40
  :thumb => "100x100#",
41
41
  :thumb2 => "200x200#",
42
42
  :s169 => "640x360#",
43
- # :s43 => "640x480#",
44
43
  :small => "400x400>",
45
44
  :large => '950x650>',
46
45
  },
@@ -48,14 +47,15 @@ class Photo
48
47
  :s3_credentials => ::S3_CREDENTIALS,
49
48
  :path => "photos/:style/:id/:filename",
50
49
  :s3_protocol => 'https',
51
- :validate_media_type => false
52
-
50
+ :validate_media_type => false,
51
+ s3_region: ::S3_CREDENTIALS[:region]
52
+
53
53
  def self.n_per_manager_gallery
54
54
  25
55
55
  end
56
56
 
57
57
  validates_attachment_content_type :photo, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif", 'application/octet-stream' ]
58
-
58
+
59
59
  end
60
60
 
61
61
 
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.129
4
+ version: 0.0.33.133
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
@@ -116,6 +116,7 @@ files:
116
116
  - lib/gallery.rb
117
117
  - lib/gameui.rb
118
118
  - lib/gameui/map.rb
119
+ - lib/gameui/map_bookmark.rb
119
120
  - lib/gameui/marker.rb
120
121
  - lib/gameui/premium_purchase.rb
121
122
  - lib/ish/alphavantage_stockwatcher.rb
@@ -125,6 +126,7 @@ files:
125
126
  - lib/ish/covered_call_watcher.rb
126
127
  - lib/ish/crawler.rb
127
128
  - lib/ish/gallery_name.rb
129
+ - lib/ish/image_asset.rb
128
130
  - lib/ish/input_error.rb
129
131
  - lib/ish/invoice.rb
130
132
  - lib/ish/iron_condor.rb