ish_models 0.0.33.157 → 0.0.33.160
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gallery.rb +5 -1
- data/lib/gameui/map.rb +146 -4
- data/lib/gameui/marker.rb +92 -31
- data/lib/ish/image_asset.rb +16 -6
- data/lib/ish/payment.rb +2 -0
- data/lib/ish/user_profile.rb +30 -9
- data/lib/ish/utils.rb +16 -0
- data/lib/ish_models.rb +0 -1
- data/lib/newsitem.rb +34 -12
- data/lib/photo.rb +15 -6
- data/lib/report.rb +5 -0
- data/lib/site.rb +1 -0
- data/lib/video.rb +4 -0
- metadata +1 -2
- data/lib/ish/nonpublic.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9357739f510cad92b5496ec766b721e5dc1a621855ad3d43aa17d95715415b02
|
4
|
+
data.tar.gz: a1e7f1e1e0687d944313996bf0684977706f3340dbf85a76463616453a988521
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a23fdd757857717baa7e99b0ffb5d01d3a32dda773ba6655a3c525f65e31a10185e4918788804a2ddabbb926b633a1538f2e6fc20dba46d60bd16e427e467bc6
|
7
|
+
data.tar.gz: 794c26976f05052b423499feb31cdf2f801b5d0e55dd8aacdd51dd41d315f11cdd4c4ed92b14e0a79618214133e3a5c33fd9f3a8e8adc6a8f50f7d645caef1b0
|
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
|
@@ -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,
|
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
|
-
|
58
|
-
|
59
|
-
|
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: :
|
15
|
-
has_one :title_image, class_name: '::Ish::ImageAsset', inverse_of: :
|
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,
|
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
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
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
|
data/lib/ish/image_asset.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
-
class Ish::ImageAsset
|
2
|
-
require 'aws-sdk'
|
3
1
|
|
2
|
+
require 'aws-sdk'
|
3
|
+
|
4
|
+
class Ish::ImageAsset
|
4
5
|
include Mongoid::Document
|
5
6
|
include Mongoid::Timestamps
|
6
7
|
include Mongoid::Paperclip
|
8
|
+
include Ish::Utils
|
7
9
|
|
8
|
-
belongs_to :location,
|
9
|
-
belongs_to :
|
10
|
-
belongs_to :
|
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
|
11
13
|
|
12
14
|
has_mongoid_attached_file :image,
|
13
15
|
:styles => {
|
@@ -22,6 +24,14 @@ class Ish::ImageAsset
|
|
22
24
|
|
23
25
|
validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif", 'application/octet-stream' ]
|
24
26
|
|
25
|
-
|
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
|
26
34
|
|
35
|
+
end
|
27
36
|
|
37
|
+
Asset = Ish::ImageAsset
|
data/lib/ish/payment.rb
CHANGED
data/lib/ish/user_profile.rb
CHANGED
@@ -1,18 +1,29 @@
|
|
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
|
-
|
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
|
+
field :name
|
17
|
+
|
18
|
+
def export_fields
|
19
|
+
%w|
|
20
|
+
email
|
21
|
+
role_name
|
22
|
+
|
|
23
|
+
end
|
24
|
+
|
25
|
+
field :scratchpad
|
26
|
+
|
16
27
|
field :fb_access_token
|
17
28
|
field :fb_long_access_token
|
18
29
|
field :fb_expires_in
|
@@ -31,18 +42,21 @@ class Ish::UserProfile
|
|
31
42
|
has_many :galleries, :inverse_of => :user_profile
|
32
43
|
has_and_belongs_to_many :shared_galleries, :inverse_of => :shared_profiles, class_name: 'Gallery'
|
33
44
|
has_and_belongs_to_many :shared_markers, :inverse_of => :shared_profiles, class_name: 'Gameui::Marker'
|
45
|
+
has_many :my_markers, :inverse_of => :creator_profile, class_name: 'Gameui::Marker'
|
34
46
|
has_and_belongs_to_many :shared_locations, :inverse_of => :shared_profiles, class_name: 'Gameui::Map'
|
47
|
+
has_many :my_maps, :inverse_of => :creator_profile, class_name: 'Gameui::Map'
|
35
48
|
|
36
49
|
has_many :invoices, :class_name => '::Ish::Invoice'
|
37
50
|
has_many :leads, :class_name => '::Ish::Lead'
|
38
51
|
has_many :photos
|
39
52
|
has_many :reports, inverse_of: :user_profile
|
40
53
|
|
54
|
+
## @TODO: do something about this.
|
41
55
|
# has_many :stock_watches, class_name: 'IronWarbler::StockWatch'
|
42
56
|
# has_many :option_watches, class_name: 'IronWarbler::OptionWatch'
|
43
57
|
|
44
58
|
has_many :videos, inverse_of: :user_profile
|
45
|
-
has_many :newsitems, inverse_of: :
|
59
|
+
has_many :newsitems, inverse_of: :profile # @TODO: remove? denorm handle over here?
|
46
60
|
|
47
61
|
has_and_belongs_to_many :bookmarked_locations, class_name: '::Gameui::Map', inverse_of: :bookmarked_profile
|
48
62
|
def bookmarks
|
@@ -53,7 +67,7 @@ class Ish::UserProfile
|
|
53
67
|
has_and_belongs_to_many :friendeds, :class_name => '::Ish::UserProfile', :inverse_of => :friends
|
54
68
|
|
55
69
|
field :n_unlocks, type: Integer, default: 0
|
56
|
-
def n_coins
|
70
|
+
def n_coins # @deprecated, do not use
|
57
71
|
n_unlocks
|
58
72
|
end
|
59
73
|
|
@@ -83,6 +97,7 @@ class Ish::UserProfile
|
|
83
97
|
def premium_purchases
|
84
98
|
::Gameui::PremiumPurchase.where( user_profile_id: self.id )
|
85
99
|
end
|
100
|
+
field :is_purchasing, type: Boolean, default: false
|
86
101
|
|
87
102
|
# used in rake tasks
|
88
103
|
def self.generate delta
|
@@ -100,7 +115,11 @@ class Ish::UserProfile
|
|
100
115
|
if !user
|
101
116
|
user = User.new({ email: email, password: password })
|
102
117
|
end
|
103
|
-
profile = Ish::UserProfile.new({
|
118
|
+
profile = Ish::UserProfile.new({
|
119
|
+
email: email,
|
120
|
+
role_name: role_name,
|
121
|
+
user: user,
|
122
|
+
})
|
104
123
|
profile.save
|
105
124
|
|
106
125
|
if profile.persisted?
|
@@ -111,3 +130,5 @@ class Ish::UserProfile
|
|
111
130
|
end
|
112
131
|
|
113
132
|
end
|
133
|
+
|
134
|
+
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
data/lib/newsitem.rb
CHANGED
@@ -1,22 +1,23 @@
|
|
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 :
|
6
|
-
belongs_to :
|
7
|
-
belongs_to :city, :optional => true
|
8
|
-
belongs_to :report, :optional => true
|
9
|
-
belongs_to :user_profile, class_name: 'Ish::UserProfile', optional: true
|
10
|
-
belongs_to :map, class_name: '::Gameui::Map', optional: true
|
11
|
-
|
12
|
-
belongs_to :gallery, :optional => true
|
9
|
+
belongs_to :city, optional: true
|
10
|
+
belongs_to :gallery, optional: true # seems correct. _vp_ 2022-03-21
|
13
11
|
def gallery
|
14
12
|
self.gallery_id ? Gallery.unscoped.find( self.gallery_id ) : nil
|
15
13
|
end
|
16
|
-
|
17
|
-
belongs_to :
|
18
|
-
|
19
|
-
|
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
|
20
|
+
belongs_to :video, optional: true
|
20
21
|
|
21
22
|
field :name
|
22
23
|
field :descr
|
@@ -58,4 +59,25 @@ class Newsitem
|
|
58
59
|
return n
|
59
60
|
end
|
60
61
|
|
62
|
+
def export_fields
|
63
|
+
%w|
|
64
|
+
descr
|
65
|
+
gallery_id
|
66
|
+
image_path
|
67
|
+
link_path
|
68
|
+
map_id
|
69
|
+
name
|
70
|
+
photo_id
|
71
|
+
report_id
|
72
|
+
video_id
|
73
|
+
|
|
74
|
+
end
|
75
|
+
|
76
|
+
def collect export_object
|
77
|
+
export_object[:galleries][gallery.id.to_s] = gallery.id.to_s if gallery
|
78
|
+
export_object[:photos][photo.id.to_s] = photo.id.to_s if photo
|
79
|
+
export_object[:reports][report.id.to_s] = report.id.to_s if report
|
80
|
+
export_object[:videos][video.id.to_s] = video.id.to_s if video
|
81
|
+
end
|
82
|
+
|
61
83
|
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
|
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
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.
|
4
|
+
version: 0.0.33.160
|
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
|