ish_models 0.0.33.161 → 0.0.33.162

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: 442096ab6ef54689b9a4ca3a16107d1f49f7dd2e0af2eb7b2d79d4bd9706f950
4
- data.tar.gz: 20d4ed02e4eecdcbf558d7cb9dfa5e91cab277e066ecb1bf787287c9829bbd75
3
+ metadata.gz: 5f93305110da30b0f8b78818b77270ecca79a14df58025c32b0c9e43869e40ca
4
+ data.tar.gz: 2e1192839965a31e65256cc0bdee33cfbb0e71c8904c6a2fc1c3ea219e7f96ff
5
5
  SHA512:
6
- metadata.gz: 02af3b69874afdfaf9b78b6c95a3d38319fbbc96513454bbd24e69b5da8b24e6a0dbdd8177291b09ce1927e6dacdf0f6c907f5b776b41f92edf829ed5f50bc59
7
- data.tar.gz: 06d0c1cde0995eb9490a1182cbce13bbc7abe59dc49606d6a213200335e7da6992dab1c557e31fe310225b280c06ff2f345d709c2947d5def30b4af93e8e8534
6
+ metadata.gz: ed34572c3501670602c0af9eced18229f2bd372c1471511eebd856b48ec05df17e7398772d162d9922ba3a1ba530eb9982714633ef730cb3823abc94a689678a
7
+ data.tar.gz: e68451247021b5f7b94eed4e71e4845d124dec0dfc0ac0f6ce0b750f9294edda29bca1d11abf83baf6f46b34894239f9ca0bb2d37b5a61ccc8b68640621d25cc
data/lib/gameui/map.rb CHANGED
@@ -25,6 +25,7 @@ class ::Gameui::Map
25
25
  belongs_to :creator_profile, class_name: '::Ish::UserProfile', inverse_of: :my_maps
26
26
 
27
27
  has_and_belongs_to_many :bookmarked_profiles, class_name: '::Ish::UserProfile', inverse_of: :bookmarked_location
28
+ has_and_belongs_to_many :tags, class_name: 'Tag', inverse_of: :map
28
29
 
29
30
  # shareable, nonpublic
30
31
  field :is_public, type: Boolean, default: true
data/lib/gameui/marker.rb CHANGED
@@ -49,7 +49,21 @@ class ::Gameui::Marker
49
49
  has_and_belongs_to_many :shared_profiles, :class_name => 'Ish::UserProfile', :inverse_of => :shared_markers
50
50
 
51
51
  belongs_to :map, class_name: '::Gameui::Map', inverse_of: :markers
52
+
52
53
  belongs_to :destination, class_name: '::Gameui::Map', inverse_of: :from_markers
54
+ before_validation :set_destination
55
+ def set_destination
56
+ d = Map.where({ slug: slug }).first
57
+
58
+ puts! self, '#set_destination'
59
+
60
+ if !d
61
+ self.errors.add( "Cannot save marker, destination |#{slug}| not found." )
62
+ return
63
+ end
64
+ self.destination_id = d.id
65
+ end
66
+
53
67
  belongs_to :creator_profile, class_name: 'Ish::UserProfile', inverse_of: :my_markers
54
68
 
55
69
  # # @deprecated, don't use!
@@ -61,22 +75,8 @@ class ::Gameui::Marker
61
75
 
62
76
  field :w, type: Integer
63
77
  validates :w, presence: true
64
-
65
78
  field :h, type: Integer
66
79
  validates :h, presence: true
67
-
68
- field :x, type: Integer, default: 0
69
- # validates :x, presence: true
70
-
71
- field :y, type: Integer, default: 0
72
- # validates :y, presence: true
73
-
74
- field :centerOffsetX, type: Integer, default: 0
75
- # validates :centerXOffset, presence: true
76
-
77
- field :centerOffsetY, type: Integer, default: 0
78
- # validates :centerYOffset, presence: true
79
-
80
80
  # @TODO: this is shared between map and marker, move to a concern.
81
81
  before_validation :compute_w_h
82
82
  def compute_w_h
@@ -84,7 +84,6 @@ class ::Gameui::Marker
84
84
  self.h = self.w = 0
85
85
  return
86
86
  end
87
-
88
87
  begin
89
88
  geo = Paperclip::Geometry.from_file(Paperclip.io_adapters.for(image.image))
90
89
  self.w = geo.width
@@ -95,6 +94,20 @@ class ::Gameui::Marker
95
94
  end
96
95
  end
97
96
 
97
+ field :x, type: Integer, default: 0
98
+ # validates :x, presence: true
99
+
100
+ field :y, type: Integer, default: 0
101
+ # validates :y, presence: true
102
+
103
+ field :centerOffsetX, type: Integer, default: 0
104
+ # validates :centerXOffset, presence: true
105
+
106
+ field :centerOffsetY, type: Integer, default: 0
107
+ # validates :centerYOffset, presence: true
108
+
109
+
110
+
98
111
  def export_fields
99
112
  %w|
100
113
  centerOffsetX centerOffsetY creator_profile_id
data/lib/newsitem.rb CHANGED
@@ -11,7 +11,7 @@ class Newsitem
11
11
  def gallery
12
12
  self.gallery_id ? Gallery.unscoped.find( self.gallery_id ) : nil
13
13
  end
14
- belongs_to :map, optional: true, class_name: '::Gameui::Map'
14
+ belongs_to :map, optional: true, class_name: '::Gameui::Map'
15
15
  belongs_to :profile, optional: true, class_name: 'Ish::UserProfile'
16
16
  belongs_to :photo, optional: true
17
17
  belongs_to :report, optional: true
@@ -37,6 +37,18 @@ class Newsitem
37
37
  field :downvoting_users, :type => Array, :default => []
38
38
  field :is_feature, :type => Boolean, :default => false
39
39
 
40
+ TYPE_GALLERY = :type_gallery
41
+ TYPE_PHOTO = :type_photo
42
+ TYPE_REPORT = :type_report
43
+ TYPE_VIDEO = :type_video
44
+ def item_type
45
+ return TYPE_GALLERY if gallery_id
46
+ return TYPE_PHOTO if photo_id
47
+ return TYPE_REPORT if report_id
48
+ return TYPE_VIDEO if video_id
49
+ end
50
+
51
+
40
52
  PER_PAGE = 6
41
53
 
42
54
  default_scope ->{ order_by({ :created_at => :desc }) }
data/lib/tag.rb CHANGED
@@ -4,15 +4,15 @@ class Tag
4
4
  include Ish::Utils
5
5
 
6
6
  field :name, :type => String
7
- # validates :name, :uniqueness => true, :allow_nil => false
7
+ validates :name, :uniqueness => true, :allow_nil => false
8
8
 
9
9
  field :slug
10
10
  validates :slug, :uniqueness => true, presence: true, allow_nil: false
11
11
 
12
12
  field :descr, :type => String, :default => ''
13
13
 
14
- field :is_public, :type => Boolean, :default => true
15
- field :is_trash, :type => Boolean, :default => false
14
+ field :is_public, :type => Boolean, :default => true
15
+ field :is_trash, :type => Boolean, :default => false
16
16
  field :is_feature, :type => Boolean, :default => false
17
17
 
18
18
  field :weight, :type => Integer, :default => 10
@@ -31,10 +31,7 @@ class Tag
31
31
  has_and_belongs_to_many :galleries
32
32
  has_and_belongs_to_many :reports
33
33
  has_and_belongs_to_many :videos
34
-
35
- default_scope ->{
36
- where({ :is_public => true, :is_trash => false }).order_by({ :name => :asc })
37
- }
34
+ has_and_belongs_to_many :maps, class_name: 'Gameui::Map'
38
35
 
39
36
  before_validation :set_slug
40
37
 
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.161
4
+ version: 0.0.33.162
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox