ish_models 0.0.33.130 → 0.0.33.134

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: 8c34bbd347229cb392198bb194abc4c7d2902cb478aaac34b43b89c2014ab2d3
4
- data.tar.gz: 83c55591061a4ed85905e50f3aaf6fdcae9eed57d25fb4f0f36dd1cbe4d16bbe
3
+ metadata.gz: 3d922df26e696ac770c512266ee8b46206cb27068acba43df008250e3d1f3a62
4
+ data.tar.gz: 3fbc130546d38392d78fef959448eea0642a70cb76cdd9194f3924867877d204
5
5
  SHA512:
6
- metadata.gz: a2e9dc8ad1cd2f1236963b23d8c957c586e9b6736c8477001e393d4cff2fe9033c420752a5ce73e0ff3b18fe8881c647aa15ca447a9b899f3e3fd062aacb588b
7
- data.tar.gz: e4337aed790fc7190cf0341dc158443d459b4aa0b85580594971362d38bef285fa8a6b9cae97e175a0d5f344964bc01a84778c34a042bb67bc364bde586f886e
6
+ metadata.gz: 98cebce56b2f8a979808d1e1e2bff952601fb7322bcbde228d8ec643656da4b665849782a4a1a5e30eabc36c747b70b57d9d950b1cd544d63444bf93ca5d79e9
7
+ data.tar.gz: 73c95a9da8539641a6f5f9d14a2d0c27721f713cad23223727927aa5eb2e422b464007a277810262b20fd6a052882ecd4f79fe1faaf24c83093a7152af198ad2
data/lib/gallery.rb CHANGED
@@ -39,6 +39,9 @@ class Gallery
39
39
 
40
40
  field :galleryname
41
41
  index({ :galleryname => -1 }, { :unique => true })
42
+ def slug
43
+ galleryname
44
+ end
42
45
  embeds_many :gallery_names, :class_name => '::Ish::GalleryName'
43
46
  def self.find_by_slug slug
44
47
  ::Gallery.where( galleryname: slug ).first
data/lib/gameui/map.rb CHANGED
@@ -8,20 +8,37 @@ class ::Gameui::Map
8
8
 
9
9
  field :slug
10
10
  validates :slug, uniqueness: true, presence: true
11
+
11
12
  field :parent_slug
12
- def name
13
- 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
16
+
17
+ has_and_belongs_to_many :bookmarked_profiles, class_name: '::IshModels::UserProfile', inverse_of: :bookmarked_location
18
+
19
+ field :map_slug
20
+ def map
21
+ ::Gameui::Map.where( slug: map_slug ).first
14
22
  end
15
23
 
24
+ field :name
25
+ field :description
26
+
27
+ # @deprecated, dont use!
28
+ field :img_path
29
+
16
30
  field :w, type: Integer
17
31
  validates :w, presence: true
18
-
19
32
  field :h, type: Integer
20
33
  validates :h, presence: true
21
34
 
22
- field :description
23
-
24
- field :img_path
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
25
42
 
26
43
  ORDERING_TYPE_ALPHABETIC = 'alphabetic'
27
44
  ORDERING_TYPE_CUSTOM = 'custom'
@@ -32,7 +49,17 @@ class ::Gameui::Map
32
49
 
33
50
  def self.list conditions = { is_trash: false }
34
51
  out = self.order_by( created_at: :desc )
35
- [['', nil]] + out.map { |item| [ "#{item.created_at.strftime('%Y%m%d')} #{item.name}", item.id ] }
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
36
63
  end
37
64
 
38
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,6 +36,11 @@ 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
 
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'
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.130
4
+ version: 0.0.33.134
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