ish_models 0.0.33.158 → 0.0.33.159

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: 816be3e6b1853627b099bf336f71c7e659ecf6c11212f3b6621e37a383cd5a93
4
- data.tar.gz: d2647b19c20457cc1b0acb4b65e0ac2d34882971ebea4d79c0c80e2964f453c8
3
+ metadata.gz: 4818a5c5ecf9cc130dc740dbfb83814696043157259c9230003c797fcf655097
4
+ data.tar.gz: 4ef6186e998a49f0700fe6e1b277943b2ada98d20d9b4cc93ad6dbc3bb668c92
5
5
  SHA512:
6
- metadata.gz: f2b2321a05df9b2dba8e93b4263d6021cba2e30fc9342c6abb3590e057f6f21b66dd47bc077757d09cb65593991e2e89617c66c7f6b6c57e5785b4195b724284
7
- data.tar.gz: 66de3bffbe36f1516c3a006a06c7bb382fd09a8bc27b16a96bdcff7d48ea5627b64e96ae7d4796d87027aeb579d2c23bbe45f965301bdceca3d354a625ab44bc
6
+ metadata.gz: e99049e74cbf10218f4640fbe9fa47430a87433561ddce5aa6e3ada55a563d1aa7e0b5378bb1f3a1ba05fd63f13b892b956aaa920932378fab11467089697c3a
7
+ data.tar.gz: c33bd4286fb568296e618c3882db078f0dc4f2239fcf2307368c4431640c15d74733cd66c6d93a5c1f4b5da9663aecb32a05a2dd1345af35ad3b19083f1d742c
data/lib/gallery.rb CHANGED
@@ -114,5 +114,9 @@ class Gallery
114
114
  Site.update_all updated_at: Time.now
115
115
  end
116
116
 
117
+ def export_fields
118
+ %w| name descr |
119
+ end
120
+
117
121
  end
118
122
 
data/lib/gameui/map.rb CHANGED
@@ -1,11 +1,14 @@
1
1
  require 'ish/premium_item'
2
+ require 'ish/utils'
2
3
 
3
4
  class ::Gameui::Map
4
5
  include Mongoid::Document
5
6
  include Mongoid::Timestamps
6
7
  include Ish::PremiumItem
8
+ include Ish::Utils
7
9
 
8
- has_many :markers, :class_name => '::Gameui::Marker', inverse_of: :map
10
+ has_many :markers, :class_name => '::Gameui::Marker', inverse_of: :map
11
+ has_many :from_markers, :class_name => '::Gameui::Marker', inverse_of: :destination
9
12
 
10
13
  has_many :newsitems, inverse_of: :map, order: :created_at.desc
11
14
 
@@ -15,9 +18,11 @@ class ::Gameui::Map
15
18
  validates :slug, uniqueness: true, presence: true
16
19
 
17
20
  field :parent_slug
21
+
18
22
  belongs_to :parent, class_name: '::Gameui::Map', inverse_of: :childs, optional: true
19
23
  has_many :childs, class_name: '::Gameui::Map', inverse_of: :parent
20
24
  has_one :image, class_name: '::Ish::ImageAsset', inverse_of: :location
25
+ belongs_to :creator_profile, class_name: '::Ish::UserProfile', inverse_of: :my_maps
21
26
 
22
27
  has_and_belongs_to_many :bookmarked_profiles, class_name: '::Ish::UserProfile', inverse_of: :bookmarked_location
23
28
 
@@ -25,7 +30,9 @@ class ::Gameui::Map
25
30
  field :is_public, type: Boolean, default: true
26
31
  has_and_belongs_to_many :shared_profiles, :class_name => 'Ish::UserProfile', :inverse_of => :shared_locations
27
32
 
33
+ field :version, type: String, default: '0.0.0'
28
34
 
35
+ ## @TODO: what is this?
29
36
  field :map_slug
30
37
  def map
31
38
  ::Gameui::Map.where( slug: map_slug ).first
@@ -54,9 +61,16 @@ class ::Gameui::Map
54
61
  # @TODO: this is shared between map and marker, move to a concern.
55
62
  before_validation :compute_w_h
56
63
  def compute_w_h
57
- geo = Paperclip::Geometry.from_file(Paperclip.io_adapters.for(image.image))
58
- self.w = geo.width
59
- self.h = geo.height
64
+ return if !image ## @TODO: test this
65
+
66
+ begin
67
+ geo = Paperclip::Geometry.from_file(Paperclip.io_adapters.for(image.image))
68
+ self.w = geo.width
69
+ self.h = geo.height
70
+ rescue Paperclip::Errors::NotIdentifiedByImageMagickError => e
71
+ puts! e, 'Could not #compute_w_h'
72
+ # @TODO: do something with this
73
+ end
60
74
  end
61
75
 
62
76
  ORDERING_TYPE_ALPHABETIC = 'alphabetic'
@@ -81,6 +95,134 @@ class ::Gameui::Map
81
95
  out.reverse
82
96
  end
83
97
 
98
+ def empty_export
99
+ return {
100
+ galleries: {},
101
+ image_assets: {},
102
+ maps: {}, markers: {},
103
+ newsitems: {},
104
+ photos: {}, profiles: {},
105
+ reports: {},
106
+ videos: {},
107
+ }
108
+ end
109
+ def self.empty_export; Gameui::Map.new.empty_export; end
110
+
111
+ def empty_export_arr
112
+ return {
113
+ galleries: [],
114
+ image_assets: [],
115
+ maps: [], markers: [],
116
+ newsitems: [],
117
+ photos: [], profiles: [],
118
+ reports: [],
119
+ videos: [],
120
+ }
121
+ end
122
+ def self.export_key_to_class
123
+ Map.new.export_key_to_class
124
+ end
125
+ def export_key_to_class
126
+ return {
127
+ galleries: 'Gallery',
128
+ image_assets: 'Ish::ImageAsset',
129
+ maps: 'Gameui::Map',
130
+ markers: 'Gameui::Marker',
131
+ newsitems: 'Newsitem',
132
+ photos: 'Photo',
133
+ profiles: 'Ish::UserProfile',
134
+ reports: 'Report',
135
+ videos: 'Video',
136
+ # 'galleries' => 'Gallery',
137
+ # 'image_assets' => 'Ish::ImageAsset',
138
+ # 'maps' => 'Gameui::Map',
139
+ # 'markers' => 'Gameui::Marker',
140
+ # 'newsitems' => 'Newsitem',
141
+ # 'photos' => 'Photo',
142
+ # 'profiles' => 'Ish::UserProfile',
143
+ # 'reports' => 'Report',
144
+ # 'videos' => 'Video',
145
+ }.with_indifferent_access
146
+ end
147
+
148
+ def export_fields
149
+ %w|
150
+ creator_profile_id config
151
+ deleted_at description
152
+ h
153
+ is_public
154
+ labels
155
+ map_slug
156
+ name
157
+ ordering_type
158
+ parent_slug
159
+ rated
160
+ slug
161
+ version
162
+ w
163
+ |
164
+ end
165
+
166
+ ## This is the starting point _vp_ 2022-03-12
167
+ ##
168
+ def export_subtree
169
+ collected = collect(empty_export)
170
+ exportable = empty_export_arr
171
+ collected.map do |k, v|
172
+ if v.present?
173
+ v.map do |id|
174
+ id = id[0]
175
+ item = export_key_to_class[k].constantize.unscoped.find id
176
+ export = item.export
177
+ exportable[k].push( export )
178
+ end
179
+ end
180
+ end
181
+ JSON.pretty_generate exportable
182
+ end
183
+
184
+ def collect export_object
185
+ map = self
186
+ export_object[:maps][map.id.to_s] = map.id.to_s
187
+
188
+ if map.markers.present?
189
+ map.markers.map do |marker|
190
+ id = marker.id.to_s
191
+ if !export_object[:markers][id]
192
+ marker.collect( export_object )
193
+ end
194
+ export_object[:markers][id] = id
195
+ end
196
+ end
197
+
198
+ if map.newsitems.present?
199
+ map.newsitems.map do |newsitem|
200
+ id = newsitem.id.to_s
201
+ export_object[:newsitems][id] = id
202
+ newsitem.collect export_object
203
+ end
204
+ end
205
+
206
+ ## @TODO: maybe implement this later, maybe not. _vp_ 2022-03-12
207
+ # if map.childs.present?
208
+ # export_object[:maps].push( map.childs.map &:id )
209
+ # map.childs.map do |child|
210
+ # child.collect export_object
211
+ # end
212
+ # end
213
+
214
+ if map.creator_profile.present?
215
+ export_object[:profiles][map.creator_profile.id.to_s] = map.creator_profile.id.to_s
216
+ end
217
+
218
+ if map.image.present?
219
+ export_object[:image_assets][map.image.id.to_s] = map.image.id.to_s
220
+ end
221
+
222
+ export_object
223
+ end
224
+
84
225
  end
85
226
 
86
227
  Location = ::Gameui::Map
228
+ Map = Gameui::Map
data/lib/gameui/marker.rb CHANGED
@@ -2,70 +2,131 @@
2
2
  class ::Gameui::Marker
3
3
  include Mongoid::Document
4
4
  include Mongoid::Timestamps
5
-
5
+ include Ish::Utils
6
6
 
7
7
  field :slug
8
8
  ## @TODO: probably remove this, no reason not to have two markers to the same slug (destination)
9
9
  validates_uniqueness_of :slug, scope: :map_id
10
10
  validates_presence_of :slug
11
11
 
12
+ field :name, type: String
13
+ validates :name, presence: true
14
+
15
+ field :ordering, type: String, default: 'jjj'
16
+
17
+ ITEM_TYPE_LOCATION = '::Gameui::Map' # @TODO: this used to be gameui-location . How is this different from gameui-map ?
18
+ ITEM_TYPE_MAP = 'gameui-map'
19
+ ITEM_TYPE_OBJ = 'gameui-obj'
20
+ ITEM_TYPES = [ ITEM_TYPE_LOCATION, ITEM_TYPE_MAP, ITEM_TYPE_OBJ ]
21
+ field :item_type, type: String
22
+ validates :item_type, presence: true
23
+
24
+ field :url
25
+ field :version, type: String, default: '0.0.0'
12
26
  field :description
13
27
 
14
- has_one :image, class_name: '::Ish::ImageAsset', inverse_of: :marker_image
15
- has_one :title_image, class_name: '::Ish::ImageAsset', inverse_of: :marker_title_image
28
+ has_one :image, class_name: '::Ish::ImageAsset', inverse_of: :marker
29
+ has_one :title_image, class_name: '::Ish::ImageAsset', inverse_of: :marker_title
16
30
 
17
- field :deleted_at, type: Time, default: nil
31
+ field :deleted_at, type: Time, default: nil # @TODO: replace with paranoia
18
32
 
19
- # shareable, nonpublic
20
33
  field :is_public, type: Boolean, default: true
34
+ def self.public
35
+ where( is_public: true )
36
+ end
37
+ ## Active AND [ mine, shared, or public ]
38
+ def self.permitted_to profile
39
+ active.any_of( {is_public: true},
40
+ {:shared_profile_ids => profile.id},
41
+ {creator_profile_id: profile.id} )
42
+ end
43
+
44
+ field :is_active, type: Boolean, default: true
45
+ def self.active
46
+ where( is_active: true )
47
+ end
48
+
21
49
  has_and_belongs_to_many :shared_profiles, :class_name => 'Ish::UserProfile', :inverse_of => :shared_markers
22
- default_scope ->{ where({ is_public: true, deleted_at: nil }).order_by({ slug: :desc }) }
23
- ## @TODO: index default scope, maybe instead of HABTM, use :thru for shared profiles. Make is poly anyway?
24
50
 
25
- belongs_to :map, :class_name => '::Gameui::Map'
51
+ belongs_to :map, class_name: '::Gameui::Map', inverse_of: :markers
52
+ belongs_to :destination, class_name: '::Gameui::Map', inverse_of: :from_markers
53
+ belongs_to :creator_profile, class_name: 'Ish::UserProfile', inverse_of: :my_markers
26
54
 
55
+ # # @deprecated, don't use!
56
+ # # _vp_ 2021-09-23
57
+ # field :img_path
58
+ # # validates :img_path, presence: true
59
+ # field :title_img_path
60
+ # # validates :title_img_path, presence: true
27
61
 
28
- # @deprecated, don't use!
29
- # _vp_ 2021-09-23
30
- field :img_path
31
- # validates :img_path, presence: true
32
- field :title_img_path
33
- # validates :title_img_path, presence: true
34
62
  field :w, type: Integer
35
63
  validates :w, presence: true
64
+
36
65
  field :h, type: Integer
37
66
  validates :h, presence: true
67
+
38
68
  field :x, type: Integer, default: 0
39
69
  # validates :x, presence: true
70
+
40
71
  field :y, type: Integer, default: 0
41
72
  # validates :y, presence: true
73
+
42
74
  field :centerOffsetX, type: Integer, default: 0
43
75
  # validates :centerXOffset, presence: true
76
+
44
77
  field :centerOffsetY, type: Integer, default: 0
45
78
  # validates :centerYOffset, presence: true
46
79
 
80
+ # @TODO: this is shared between map and marker, move to a concern.
47
81
  before_validation :compute_w_h
48
82
  def compute_w_h
49
- geo = Paperclip::Geometry.from_file(Paperclip.io_adapters.for(image.image))
50
- self.w = geo.width
51
- self.h = geo.height
83
+ if !image # @TODO: think about this
84
+ self.h = self.w = 0
85
+ return
86
+ end
87
+
88
+ begin
89
+ geo = Paperclip::Geometry.from_file(Paperclip.io_adapters.for(image.image))
90
+ self.w = geo.width
91
+ self.h = geo.height
92
+ rescue Paperclip::Errors::NotIdentifiedByImageMagickError => e
93
+ puts! e, 'Could not #compute_w_h'
94
+ # @TODO: do something with this
95
+ end
52
96
  end
53
97
 
54
- field :is_active, type: Boolean, default: true
55
-
56
- field :name, type: String
57
- validates :name, presence: true
58
-
59
- field :ordering, type: String, default: 'jjj'
60
-
61
- ITEM_TYPE_LOCATION = 'gameui-location'
62
- ITEM_TYPE_MAP = 'gameui-map'
63
- ITEM_TYPE_OBJ = 'gameui-obj'
64
- ITEM_TYPES = [ ITEM_TYPE_LOCATION, ITEM_TYPE_MAP, ITEM_TYPE_OBJ ]
65
- field :item_type, type: String
66
- validates :item_type, presence: true
98
+ def export_fields
99
+ %w|
100
+ centerOffsetX centerOffsetY creator_profile_id
101
+ deleted_at description destination_id
102
+ h
103
+ is_active is_public item_type
104
+ map_id
105
+ name
106
+ ordering
107
+ slug
108
+ url
109
+ version
110
+ w
111
+ x
112
+ y
113
+ |
114
+ end
67
115
 
68
- field :url
116
+ def collect export_object
117
+ puts! export_object, "collecting in marker: |#{slug}|."
118
+
119
+ if image
120
+ export_object[:image_assets][image.id.to_s] = image.id.to_s
121
+ end
122
+ if title_image
123
+ export_object[:image_assets][title_image.id.to_s] = title_image.id.to_s
124
+ end
125
+ if !export_object[:maps][destination.id.to_s]
126
+ destination.collect export_object
127
+ end
128
+ end
69
129
 
70
130
  end
71
131
 
132
+ Marker = Gameui::Marker
@@ -1,14 +1,15 @@
1
1
 
2
- class Ish::ImageAsset
3
- require 'aws-sdk'
2
+ require 'aws-sdk'
4
3
 
4
+ class Ish::ImageAsset
5
5
  include Mongoid::Document
6
6
  include Mongoid::Timestamps
7
7
  include Mongoid::Paperclip
8
+ include Ish::Utils
8
9
 
9
- belongs_to :location, class_name: 'Gameui::Map', inverse_of: :image, optional: true
10
- belongs_to :marker_image, class_name: 'Gameui::Map', inverse_of: :image, optional: true
11
- belongs_to :marker_title_image, class_name: 'Gameui::Map', inverse_of: :title_image, optional: true
10
+ belongs_to :location, class_name: 'Gameui::Map', inverse_of: :image, optional: true
11
+ belongs_to :marker, class_name: 'Gameui::Marker', inverse_of: :image, optional: true
12
+ belongs_to :marker_title, class_name: 'Gameui::Marker', inverse_of: :title_image, optional: true
12
13
 
13
14
  has_mongoid_attached_file :image,
14
15
  :styles => {
@@ -23,6 +24,14 @@ class Ish::ImageAsset
23
24
 
24
25
  validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif", 'application/octet-stream' ]
25
26
 
26
- end
27
+ def export_fields
28
+ %w|
29
+ location_id
30
+ marker_id marker_title_id
31
+ image_file_name image_content_type image_file_size image_updated_at image_fingerprint
32
+ |
33
+ end
27
34
 
35
+ end
28
36
 
37
+ Asset = Ish::ImageAsset
data/lib/ish/payment.rb CHANGED
@@ -1,3 +1,5 @@
1
+
2
+
1
3
  class Ish::Payment
2
4
  include Mongoid::Document
3
5
  include Mongoid::Timestamps
@@ -1,18 +1,32 @@
1
+
2
+ require 'ish/utils'
3
+
4
+ ## @TODO: rename to Ish::Profile
1
5
  class Ish::UserProfile
2
6
  include Mongoid::Document
3
7
  include Mongoid::Timestamps
8
+ include Ish::Utils
4
9
 
5
- field :name
6
- validates_presence_of :name
7
-
8
- field :username
9
- field :scratchpad
10
+ store_in collection: 'ish_user_profiles'
10
11
 
11
12
  field :email
12
- # validates_format_of :email, :with => ::Devise::email_regexp
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
20
+
21
+ def export_fields
22
+ %w|
23
+ email
24
+ role_name
25
+ |
26
+ end
27
+
28
+ field :scratchpad
29
+
16
30
  field :fb_access_token
17
31
  field :fb_long_access_token
18
32
  field :fb_expires_in
@@ -31,18 +45,21 @@ class Ish::UserProfile
31
45
  has_many :galleries, :inverse_of => :user_profile
32
46
  has_and_belongs_to_many :shared_galleries, :inverse_of => :shared_profiles, class_name: 'Gallery'
33
47
  has_and_belongs_to_many :shared_markers, :inverse_of => :shared_profiles, class_name: 'Gameui::Marker'
48
+ has_many :my_markers, :inverse_of => :creator_profile, class_name: 'Gameui::Marker'
34
49
  has_and_belongs_to_many :shared_locations, :inverse_of => :shared_profiles, class_name: 'Gameui::Map'
50
+ has_many :my_maps, :inverse_of => :creator_profile, class_name: 'Gameui::Map'
35
51
 
36
52
  has_many :invoices, :class_name => '::Ish::Invoice'
37
53
  has_many :leads, :class_name => '::Ish::Lead'
38
54
  has_many :photos
39
55
  has_many :reports, inverse_of: :user_profile
40
56
 
57
+ ## @TODO: do something about this.
41
58
  # has_many :stock_watches, class_name: 'IronWarbler::StockWatch'
42
59
  # has_many :option_watches, class_name: 'IronWarbler::OptionWatch'
43
60
 
44
61
  has_many :videos, inverse_of: :user_profile
45
- has_many :newsitems, inverse_of: :user_profile
62
+ has_many :newsitems, inverse_of: :user_profile ## @TODO: remove?!
46
63
 
47
64
  has_and_belongs_to_many :bookmarked_locations, class_name: '::Gameui::Map', inverse_of: :bookmarked_profile
48
65
  def bookmarks
@@ -53,7 +70,7 @@ class Ish::UserProfile
53
70
  has_and_belongs_to_many :friendeds, :class_name => '::Ish::UserProfile', :inverse_of => :friends
54
71
 
55
72
  field :n_unlocks, type: Integer, default: 0
56
- def n_coins
73
+ def n_coins # @deprecated, do not use
57
74
  n_unlocks
58
75
  end
59
76
 
@@ -83,6 +100,7 @@ class Ish::UserProfile
83
100
  def premium_purchases
84
101
  ::Gameui::PremiumPurchase.where( user_profile_id: self.id )
85
102
  end
103
+ field :is_purchasing, type: Boolean, default: false
86
104
 
87
105
  # used in rake tasks
88
106
  def self.generate delta
@@ -100,7 +118,11 @@ class Ish::UserProfile
100
118
  if !user
101
119
  user = User.new({ email: email, password: password })
102
120
  end
103
- profile = Ish::UserProfile.new({ email: email, name: email, role_name: role_name, user: user })
121
+ profile = Ish::UserProfile.new({
122
+ email: email,
123
+ role_name: role_name,
124
+ user: user,
125
+ })
104
126
  profile.save
105
127
 
106
128
  if profile.persisted?
@@ -111,3 +133,5 @@ class Ish::UserProfile
111
133
  end
112
134
 
113
135
  end
136
+
137
+ Profile = Ish::UserProfile
data/lib/ish/utils.rb CHANGED
@@ -1,6 +1,22 @@
1
1
 
2
2
  module Ish::Utils
3
3
 
4
+ def export
5
+ out = {}
6
+ %w| created_at updated_at |.map do |f|
7
+ out[f] = send(f)
8
+ end
9
+ export_fields.map do |field|
10
+ if field[-3..-1] == '_id'
11
+ out[field] = send(field).to_s
12
+ else
13
+ out[field] = send(field)
14
+ end
15
+ end
16
+ out[:_id] = id.to_s
17
+ out.with_indifferent_access
18
+ end
19
+
4
20
  private
5
21
 
6
22
  def set_slug
data/lib/ish_models.rb CHANGED
@@ -40,7 +40,6 @@ require 'ish/input_error'
40
40
  require 'ish/invoice'
41
41
  require 'ish/issue'
42
42
  require 'ish/lead'
43
- require 'ish/nonpublic'
44
43
  require 'ish/payment'
45
44
  require 'ish/premium_item'
46
45
  require 'ish/utils'
data/lib/newsitem.rb CHANGED
@@ -1,20 +1,24 @@
1
+
2
+ require 'ish/utils'
3
+
1
4
  class Newsitem
2
5
  include Mongoid::Document
3
6
  include Mongoid::Timestamps
7
+ include Ish::Utils
4
8
 
5
- belongs_to :site, :optional => true
6
- belongs_to :tag, :optional => true
7
- belongs_to :city, :optional => true
8
- belongs_to :report, :optional => true
9
+ belongs_to :site, optional: true
10
+ belongs_to :tag, optional: true
11
+ belongs_to :city, optional: true
12
+ belongs_to :report, optional: true
9
13
  belongs_to :user_profile, class_name: 'Ish::UserProfile', optional: true
10
- belongs_to :map, class_name: '::Gameui::Map', optional: true
14
+ belongs_to :map, class_name: '::Gameui::Map', optional: true
11
15
 
12
- belongs_to :gallery, :optional => true
16
+ belongs_to :gallery, optional: true
13
17
  def gallery
14
18
  self.gallery_id ? Gallery.unscoped.find( self.gallery_id ) : nil
15
19
  end
16
20
 
17
- belongs_to :video, :optional => true
21
+ belongs_to :video, optional: true
18
22
 
19
23
  has_one :photo
20
24
 
@@ -58,4 +62,25 @@ class Newsitem
58
62
  return n
59
63
  end
60
64
 
65
+ def export_fields
66
+ %w|
67
+ descr
68
+ gallery_id
69
+ image_path
70
+ link_path
71
+ map_id
72
+ name
73
+ photo_id
74
+ report_id
75
+ video_id
76
+ |
77
+ end
78
+
79
+ def collect export_object
80
+ export_object[:galleries][gallery.id.to_s] = gallery.id.to_s if gallery
81
+ export_object[:photos][photo.id.to_s] = photo.id.to_s if photo
82
+ export_object[:reports][report.id.to_s] = report.id.to_s if report
83
+ export_object[:videos][video.id.to_s] = video.id.to_s if video
84
+ end
85
+
61
86
  end
data/lib/photo.rb CHANGED
@@ -1,9 +1,11 @@
1
- class Photo
2
- require 'aws-sdk'
3
1
 
2
+ require 'aws-sdk'
3
+
4
+ class Photo
4
5
  include Mongoid::Document
5
6
  include Mongoid::Timestamps
6
7
  include Mongoid::Paperclip
8
+ include Ish::Utils
7
9
 
8
10
  has_and_belongs_to_many :viewers, :class_name => 'User', :inverse_of => :viewable_photos
9
11
 
@@ -28,10 +30,8 @@ class Photo
28
30
  field :weight, :type => Integer, :default => 10
29
31
 
30
32
  field :is_public, :type => Boolean, :default => true
31
-
32
- # @TODO: nuke this boolean _vp_ 20170515
33
- field :is_trash, :type => Boolean, :default => false
34
- default_scope ->{ where({ :is_trash => false }) }
33
+ field :is_trash, :type => Boolean, :default => false # @TODO: nuke this boolean _vp_ 20170515
34
+ default_scope ->{ where({ :is_trash => false }) } # @TODO: nuke default scopes
35
35
 
36
36
  has_mongoid_attached_file :photo,
37
37
  :styles => {
@@ -53,6 +53,15 @@ class Photo
53
53
  25
54
54
  end
55
55
 
56
+ def export_fields
57
+ %w|
58
+ gallery_id
59
+ name descr weight is_public is_trash
60
+
61
+ photo_file_name photo_content_type photo_file_size photo_updated_at photo_fingerprint
62
+ |
63
+ end
64
+
56
65
  validates_attachment_content_type :photo, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif", 'application/octet-stream' ]
57
66
 
58
67
  end
data/lib/report.rb CHANGED
@@ -13,6 +13,7 @@ class Report
13
13
  index({ :slug => 1 }, { :unique => true })
14
14
  before_validation :set_slug, :on => :create
15
15
 
16
+ ## @TODO: then constantize this.
16
17
  ## Can be one of: default (nil), longscroll
17
18
  field :item_type, type: String
18
19
 
@@ -152,4 +153,8 @@ class Report
152
153
  def premium?; is_premium; end
153
154
  has_many :premium_purchases, class_name: '::Gameui::PremiumPurchase', as: :item
154
155
 
156
+ def export_fields
157
+ %w| name descr |
158
+ end
159
+
155
160
  end
data/lib/site.rb CHANGED
@@ -5,6 +5,7 @@ class Site
5
5
  include AuxModel
6
6
 
7
7
  field :domain, :type => String
8
+ validates_presence_of :domain
8
9
 
9
10
  field :lang, :type => String, :default => 'en'
10
11
  # validates :lang, { :uniqueness => :true, :scope => :domain }
data/lib/video.rb CHANGED
@@ -3,6 +3,7 @@ class Video
3
3
  include Mongoid::Timestamps
4
4
  include Mongoid::Paperclip
5
5
  include Mongoid::Paranoia
6
+ include Ish::Utils
6
7
 
7
8
  PER_PAGE = 6
8
9
 
@@ -96,5 +97,8 @@ class Video
96
97
  def premium?; is_premium; end
97
98
  has_many :premium_purchases, class_name: '::Gameui::PremiumPurchase', as: :item
98
99
 
100
+ def export_fields
101
+ %w| name descr |
102
+ end
99
103
 
100
104
  end
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.158
4
+ version: 0.0.33.159
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
@@ -142,7 +142,6 @@ files:
142
142
  - lib/ish/invoice.rb
143
143
  - lib/ish/issue.rb
144
144
  - lib/ish/lead.rb
145
- - lib/ish/nonpublic.rb
146
145
  - lib/ish/payment.rb
147
146
  - lib/ish/premium_item.rb
148
147
  - lib/ish/railtie.rb
data/lib/ish/nonpublic.rb DELETED
@@ -1,13 +0,0 @@
1
-
2
- ## THIS IS TRASH. I copy-paste repetitively instead!
3
-
4
- ## aka: Ish::Shareable
5
- ## adds is_public (default true) and #shared_profiles, inverse :shared_items ???
6
- module Ish::Nonpublic
7
-
8
- def self.included base
9
- base.send :field, :is_public, type: Boolean, default: true
10
- base.send :has_and_belongs_to_many, :shared_profiles, :class_name => 'Ish::UserProfile', :inverse_of => :shared_markers
11
- end
12
-
13
- end