ish_models 0.0.33.128 → 0.0.33.132

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5abe58e2f0a85264e21a4e9f29628e9779df734de5853030678582216f8ef46
4
- data.tar.gz: bb3ff694e571ae054038bfb72383c320f4e81feb46036d33f26ef369809758ed
3
+ metadata.gz: 0f281b9e5d6a0adaa051e580294f0159ccf7d6b8f94a30dc8c7c7c5ab867612f
4
+ data.tar.gz: 64c0861c9545bf87e52e035a86d673513a12f9e58eaa6cbdaf17a2c4ad483fd4
5
5
  SHA512:
6
- metadata.gz: c392fd667cbfa30fd5066cb6431b92bc3c775da4a0f15fb0c2948c81f612b6695888f3d76346e9464f8ce32a01ef3017593604c6a14f12339e3f1a46f1dfdf55
7
- data.tar.gz: 3d6d42a6b3624eb87bb165b14bd5e7c20d9ce7ce474ea2ba8f8b63bfa324aa5490b2ea210e0164d0a815a5ad978870ed03396416cf646dbfa436d72b186824bb
6
+ metadata.gz: 0a76dfdda32e3e49560731381aed9158d33473739f6dc155de46b79ea11ca6d0a3f87a4c3e2f08e641aab987ac5770dcdb276edf1a6b0844c2fc5aded7b91c5a
7
+ data.tar.gz: fff054a90f3161234d5c8fd6e4591dd0d0697d6ace50f40a422292517c1e6b09522c0ae2d8b3512be2126f69d54701b2f3e448090aa45824f000fe9f387cdeda
data/lib/gameui/map.rb CHANGED
@@ -4,10 +4,21 @@ 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
+
16
+ field :map_slug
17
+ def map
18
+ ::Gameui::Map.where( slug: map_slug ).first
19
+ end
20
+
21
+ field :name
11
22
 
12
23
  field :w, type: Integer
13
24
  validates :w, presence: true
@@ -26,5 +37,19 @@ class ::Gameui::Map
26
37
  field :ordering_type, type: String, default: 'custom' # timestamp, alphabetic, custom
27
38
  validates :ordering_type, presence: true
28
39
 
29
-
40
+ def self.list conditions = { is_trash: false }
41
+ out = self.order_by( created_at: :desc )
42
+ [['', nil]] + out.map { |item| [ "#{item.created_at.strftime('%Y%m%d')} #{item.name}", item.id ] }
43
+ end
44
+
45
+ def breadcrumbs
46
+ out = [{ name: self.name, slug: self.slug, link: false }]
47
+ p = self.parent
48
+ while p
49
+ out.push({ name: p.name, slug: p.slug })
50
+ p = p.parent
51
+ end
52
+ out.reverse
53
+ end
54
+
30
55
  end
@@ -39,6 +39,9 @@ class IshModels::UserProfile
39
39
  has_and_belongs_to_many :friendeds, :class_name => 'IshModels::UserProfile', :inverse_of => :friends
40
40
 
41
41
  field :n_unlocks, type: Integer, default: 0
42
+ def n_coins
43
+ n_unlocks
44
+ end
42
45
 
43
46
  #
44
47
  # preferences
@@ -72,7 +75,10 @@ class IshModels::UserProfile
72
75
  field :n_stars, type: Integer, default: 0
73
76
  has_many :premium_purchases, :class_name => '::Gameui::PremiumPurchase'
74
77
  def has_premium_purchase item
75
- item.premium_purchases.where( user_profile: self ).exists?
78
+ item.premium_purchases.where( user_profile_id: self.id ).exists?
79
+ end
80
+ def premium_purchases
81
+ ::Gameui::PremiumPurchase.where( user_profile_id: self.id )
76
82
  end
77
83
 
78
84
  end
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.128
4
+ version: 0.0.33.132
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox