ish_models 0.0.33.159 → 0.0.33.162

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: 4818a5c5ecf9cc130dc740dbfb83814696043157259c9230003c797fcf655097
4
- data.tar.gz: 4ef6186e998a49f0700fe6e1b277943b2ada98d20d9b4cc93ad6dbc3bb668c92
3
+ metadata.gz: 5f93305110da30b0f8b78818b77270ecca79a14df58025c32b0c9e43869e40ca
4
+ data.tar.gz: 2e1192839965a31e65256cc0bdee33cfbb0e71c8904c6a2fc1c3ea219e7f96ff
5
5
  SHA512:
6
- metadata.gz: e99049e74cbf10218f4640fbe9fa47430a87433561ddce5aa6e3ada55a563d1aa7e0b5378bb1f3a1ba05fd63f13b892b956aaa920932378fab11467089697c3a
7
- data.tar.gz: c33bd4286fb568296e618c3882db078f0dc4f2239fcf2307368c4431640c15d74733cd66c6d93a5c1f4b5da9663aecb32a05a2dd1345af35ad3b19083f1d742c
6
+ metadata.gz: ed34572c3501670602c0af9eced18229f2bd372c1471511eebd856b48ec05df17e7398772d162d9922ba3a1ba530eb9982714633ef730cb3823abc94a689678a
7
+ data.tar.gz: e68451247021b5f7b94eed4e71e4845d124dec0dfc0ac0f6ce0b750f9294edda29bca1d11abf83baf6f46b34894239f9ca0bb2d37b5a61ccc8b68640621d25cc
data/lib/gallery.rb CHANGED
@@ -48,7 +48,7 @@ class Gallery
48
48
 
49
49
  has_and_belongs_to_many :tags
50
50
 
51
- has_many :newsitems
51
+ has_many :newsitems # seems correct. _vp_ 2022-03-21
52
52
  has_many :photos
53
53
 
54
54
  belongs_to :city, :optional => true
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
@@ -13,10 +13,7 @@ class Ish::UserProfile
13
13
  validates_format_of :email,:with => /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/
14
14
  validates_uniqueness_of :email
15
15
 
16
- ## @TODO: remove this alias
17
- def name
18
- email
19
- end
16
+ field :name
20
17
 
21
18
  def export_fields
22
19
  %w|
@@ -25,7 +22,7 @@ class Ish::UserProfile
25
22
  |
26
23
  end
27
24
 
28
- field :scratchpad
25
+ field :scratchpad, default: ''
29
26
 
30
27
  field :fb_access_token
31
28
  field :fb_long_access_token
@@ -59,7 +56,7 @@ class Ish::UserProfile
59
56
  # has_many :option_watches, class_name: 'IronWarbler::OptionWatch'
60
57
 
61
58
  has_many :videos, inverse_of: :user_profile
62
- has_many :newsitems, inverse_of: :user_profile ## @TODO: remove?!
59
+ has_many :newsitems, inverse_of: :profile # @TODO: remove? denorm handle over here?
63
60
 
64
61
  has_and_belongs_to_many :bookmarked_locations, class_name: '::Gameui::Map', inverse_of: :bookmarked_profile
65
62
  def bookmarks
data/lib/newsitem.rb CHANGED
@@ -6,22 +6,19 @@ class Newsitem
6
6
  include Mongoid::Timestamps
7
7
  include Ish::Utils
8
8
 
9
- belongs_to :site, optional: true
10
- belongs_to :tag, optional: true
11
9
  belongs_to :city, optional: true
12
- belongs_to :report, optional: true
13
- belongs_to :user_profile, class_name: 'Ish::UserProfile', optional: true
14
- belongs_to :map, class_name: '::Gameui::Map', optional: true
15
-
16
- belongs_to :gallery, optional: true
10
+ belongs_to :gallery, optional: true # seems correct. _vp_ 2022-03-21
17
11
  def gallery
18
12
  self.gallery_id ? Gallery.unscoped.find( self.gallery_id ) : nil
19
13
  end
20
-
14
+ belongs_to :map, optional: true, class_name: '::Gameui::Map'
15
+ belongs_to :profile, optional: true, class_name: 'Ish::UserProfile'
16
+ belongs_to :photo, optional: true
17
+ belongs_to :report, optional: true
18
+ belongs_to :site, optional: true
19
+ belongs_to :tag, optional: true
21
20
  belongs_to :video, optional: true
22
21
 
23
- has_one :photo
24
-
25
22
  field :name
26
23
  field :descr
27
24
  def description
@@ -40,6 +37,18 @@ class Newsitem
40
37
  field :downvoting_users, :type => Array, :default => []
41
38
  field :is_feature, :type => Boolean, :default => false
42
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
+
43
52
  PER_PAGE = 6
44
53
 
45
54
  default_scope ->{ order_by({ :created_at => :desc }) }
data/lib/photo.rb CHANGED
@@ -62,7 +62,7 @@ class Photo
62
62
  |
63
63
  end
64
64
 
65
- validates_attachment_content_type :photo, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif", 'application/octet-stream' ]
65
+ validates_attachment_content_type :photo, :content_type => ["image/webp", "image/jpg", "image/jpeg", "image/png", "image/gif", 'application/octet-stream' ]
66
66
 
67
67
  end
68
68
 
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.159
4
+ version: 0.0.33.162
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox