ish_models 0.0.33.175 → 0.0.33.177
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ish/lead.rb +0 -3
- data/lib/ish/user_profile.rb +3 -3
- data/lib/trash/app_model2.rb +21 -0
- data/lib/trash/city.rb-bk +100 -0
- data/lib/trash/event.rb +28 -0
- data/lib/trash/site.rb +99 -0
- data/lib/trash/tag_trash.rb +73 -0
- data/lib/trash/venue.rb +77 -0
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 397db72f891618fed009e038b838b8db501938fc138049694b36a231bdde5396
|
4
|
+
data.tar.gz: 61862f7ca0df8353154842805e14177545aa0ce5dfde14ad2b72eb2ccdedaec7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 369c6244bf7b9e27db9616b5584a1f9650eaabd76f82cb8ecf3df56f7012c3c47bd4de657820531c70bab77b959fe8b350113367305bde898618d32630787ffd
|
7
|
+
data.tar.gz: 4a6b95bcaeb3d47c66502f9d5b7cb268fc596a2ad9787bf01d654c9e620ba5a030f5c42b3e783491537cd52a09ee18038e6ba0748b7b9d5b52f1342f38c01b8b
|
data/lib/ish/lead.rb
CHANGED
data/lib/ish/user_profile.rb
CHANGED
@@ -40,8 +40,7 @@ class Ish::UserProfile
|
|
40
40
|
|
41
41
|
has_one :profile_photo, :class_name => 'Photo', :inverse_of => :profile_city
|
42
42
|
|
43
|
-
belongs_to :user
|
44
|
-
validates_presence_of :user
|
43
|
+
belongs_to :user, class_name: 'TmpUser', inverse_of: :profile
|
45
44
|
|
46
45
|
belongs_to :current_city, :class_name => 'City', :inverse_of => :current_users, :optional => true
|
47
46
|
belongs_to :guide_city, :class_name => 'City', :inverse_of => :guide, :optional => true
|
@@ -82,8 +81,9 @@ class Ish::UserProfile
|
|
82
81
|
## @TODO: better naming convention, or remove this
|
83
82
|
field :videos_embed, :type => Boolean, :default => false
|
84
83
|
|
84
|
+
## @TODO: remove _vp_ 2022-10-04
|
85
85
|
def sudoer?
|
86
|
-
%w( piousbox@gmail.com victor@wasya.co ).include?(
|
86
|
+
%w( piousbox@gmail.com victor@wasya.co ).include?( email )
|
87
87
|
end
|
88
88
|
|
89
89
|
## manager uses it.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
# @deprecated, remove
|
3
|
+
class Ish::AppModel2
|
4
|
+
include ::Mongoid::Document
|
5
|
+
include ::Mongoid::Timestamps
|
6
|
+
|
7
|
+
field :is_public, :type => Boolean, :default => false
|
8
|
+
field :is_trash, :type => Boolean, :default => false
|
9
|
+
|
10
|
+
default_scope ->{ where({ :is_public => true, :is_trash => false }).order_by({ :created_at => :desc }) }
|
11
|
+
|
12
|
+
field :x, :type => Float
|
13
|
+
field :y, :type => Float
|
14
|
+
|
15
|
+
def self.list conditions = { :is_trash => false }
|
16
|
+
out = self.where( conditions ).order_by( :created_at => :desc )
|
17
|
+
[['', nil]] + out.map { |item| [ "#{item.created_at.strftime('%Y%m%d')} #{item.name}", item.id ] }
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
class City
|
2
|
+
include ::Mongoid::Document
|
3
|
+
include ::Mongoid::Timestamps
|
4
|
+
|
5
|
+
field :name, :type => String
|
6
|
+
field :description, :type => String, :default => 'The description of this city'
|
7
|
+
|
8
|
+
field :cityname, :type => String
|
9
|
+
validates :cityname, :uniqueness => true, :allow_nil => false, :presence => true
|
10
|
+
def slug; cityname; end
|
11
|
+
def slug= s; cityname = s; end
|
12
|
+
|
13
|
+
field :x, :type => Float
|
14
|
+
field :y, :type => Float
|
15
|
+
|
16
|
+
field :deleted_at, type: Time
|
17
|
+
def self.all
|
18
|
+
self.where( deleted_at: nil, is_active: true ).order_by( name: :desc )
|
19
|
+
end
|
20
|
+
|
21
|
+
belongs_to :country, :optional => true
|
22
|
+
|
23
|
+
has_many :events
|
24
|
+
has_many :galleries
|
25
|
+
has_many :photos
|
26
|
+
has_many :reports
|
27
|
+
has_many :venues
|
28
|
+
has_many :videos
|
29
|
+
has_and_belongs_to_many :tags
|
30
|
+
|
31
|
+
has_many :current_users, :class_name => '::Ish::UserProfile', :inverse_of => :current_city
|
32
|
+
has_many :newsitems
|
33
|
+
|
34
|
+
has_many :current_users, :class_name => '::Ish::UserProfile', :inverse_of => :current_city
|
35
|
+
has_one :profile_photo, :class_name => 'Photo', :inverse_of => :profile_city
|
36
|
+
has_one :guide, :class_name => '::Ish::UserProfile', :inverse_of => :guide_city
|
37
|
+
|
38
|
+
has_many :features
|
39
|
+
|
40
|
+
field :calendar_frame, :type => String
|
41
|
+
field :is_active, type: Boolean, default: true
|
42
|
+
|
43
|
+
default_scope ->{ order_by({ :name => :asc }) }
|
44
|
+
|
45
|
+
def self.list
|
46
|
+
out = self.order_by( :name => :asc )
|
47
|
+
# no_city = City.where( :cityname => 'no_city' ).first || City.create( :cityname => 'no_city', :name => 'No City' )
|
48
|
+
[['', nil]] + out.map { |item| [ item.name, item.id ] }
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.list_citynames lang = 'en'
|
52
|
+
out = self.order_by( :name => :asc )
|
53
|
+
[['', nil]] + out.map { |item| [ item['name_'+lang], item.cityname ] }
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.clear
|
57
|
+
if Rails.env.test?
|
58
|
+
City.all.each { |r| r.remove }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.n_features
|
63
|
+
4
|
64
|
+
end
|
65
|
+
def n_features
|
66
|
+
4
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
def j_reports args = {}
|
71
|
+
out = []
|
72
|
+
self.reports.each do |r|
|
73
|
+
rr = r.clone
|
74
|
+
rr[:username] = r.user.username
|
75
|
+
rr.created_at = r.created_at # pretty_date( r.created_at )
|
76
|
+
rr[:tag_name] = r.tag.name unless r.tag.blank?
|
77
|
+
rr[:tag_name] ||= ''
|
78
|
+
out << rr
|
79
|
+
end
|
80
|
+
return out
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.for_homepage
|
84
|
+
cities = City.all.order_by( :name => :asc )
|
85
|
+
cities = cities.delete_if do |c|
|
86
|
+
( false == c.is_feature ) && ( 0 == c.galleries.length ) && ( 0 == c.reports.length )
|
87
|
+
end
|
88
|
+
return cities
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.method_missing name, *args, &block
|
92
|
+
city = City.where( :cityname => name ).first
|
93
|
+
return city if city
|
94
|
+
super
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
|
data/lib/trash/event.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
class Event
|
3
|
+
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Timestamps
|
6
|
+
|
7
|
+
field :name, :type => String
|
8
|
+
validates :name, :presence => true, :uniqueness => true
|
9
|
+
|
10
|
+
field :eventname, :type => String
|
11
|
+
validates :eventname, :presence => true, :uniqueness => true
|
12
|
+
|
13
|
+
field :description, :type => String
|
14
|
+
|
15
|
+
field :date, :type => DateTime
|
16
|
+
validates :date, :presence => true
|
17
|
+
|
18
|
+
belongs_to :city
|
19
|
+
validates :city, :presence => true
|
20
|
+
|
21
|
+
field :x, :type => Float
|
22
|
+
field :y, :type => Float
|
23
|
+
|
24
|
+
has_one :profile_photo, :class_name => 'Photo', :inverse_of => :profile_event
|
25
|
+
has_many :photos
|
26
|
+
|
27
|
+
end
|
28
|
+
|
data/lib/trash/site.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
class Site
|
2
|
+
|
3
|
+
include Mongoid::Document
|
4
|
+
include Mongoid::Timestamps
|
5
|
+
|
6
|
+
field :domain, :type => String
|
7
|
+
validates_presence_of :domain
|
8
|
+
|
9
|
+
field :lang, :type => String, :default => 'en'
|
10
|
+
# validates :lang, { :uniqueness => :true, :scope => :domain }
|
11
|
+
|
12
|
+
field :title
|
13
|
+
field :subhead
|
14
|
+
field :description
|
15
|
+
field :home_redirect_path
|
16
|
+
|
17
|
+
field :n_features, :type => Integer, :default => 4
|
18
|
+
field :n_newsitems, :type => Integer, :default => 20
|
19
|
+
field :newsitems_per_page, :type => Integer, :default => 10 # this is used. _vp_ 20171025
|
20
|
+
field :play_videos_in_preview, :type => Boolean, :default => true
|
21
|
+
|
22
|
+
# denormalized
|
23
|
+
field :n_reports, :type => Integer
|
24
|
+
field :n_galleries, :type => Integer
|
25
|
+
|
26
|
+
field :is_video_enabled, :type => Boolean, :default => false
|
27
|
+
field :is_resume_enabled, :type => Boolean, :default => false
|
28
|
+
field :is_ads_enabled, :type => Boolean, :default => true
|
29
|
+
field :is_trash, :type => Boolean, :default => false
|
30
|
+
field :is_primary, :type => Boolean, :default => false
|
31
|
+
field :is_private, :type => Boolean, :default => false
|
32
|
+
field :private_user_emails, :type => Array, :default => []
|
33
|
+
|
34
|
+
field :homepage_layout, :type => String, :default => 'show'
|
35
|
+
field :layout, :type => String, :default => 'application'
|
36
|
+
|
37
|
+
has_many :reports
|
38
|
+
has_many :galleries
|
39
|
+
has_many :tags
|
40
|
+
has_many :videos
|
41
|
+
has_many :newsitems, :order => :created_at.desc
|
42
|
+
has_many :issues, :class_name => 'Ish::Issue'
|
43
|
+
has_many :features, :order => :created_at.desc
|
44
|
+
|
45
|
+
default_scope ->{ where({ :is_trash => false }).order_by({ :domain => :asc, :lang => :asc }) }
|
46
|
+
|
47
|
+
set_callback :create, :before do |doc|
|
48
|
+
if Site.where( :lang => doc.lang, :domain => doc.domain ).length > 0
|
49
|
+
false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
set_callback :update, :before do |doc|
|
54
|
+
possible_duplicate = Site.where( :lang => doc.lang, :domain => doc.domain ).first
|
55
|
+
if possible_duplicate.blank?
|
56
|
+
true
|
57
|
+
elsif doc.id != possible_duplicate.id
|
58
|
+
false
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
LANGUAGES = [ 'en', 'ru', 'pt' ]
|
63
|
+
|
64
|
+
# manager uses it.
|
65
|
+
def self.list
|
66
|
+
out = self.all.order_by( :domain => :asc, :lang => :asc )
|
67
|
+
[['Select Site', nil]] + out.map { |item| [ "#{item.domain} #{item.lang}", item.id ] }
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.mobi
|
71
|
+
Site.where( :domain => 'travel-guide.mobi', :lang => 'en' ).first
|
72
|
+
end
|
73
|
+
|
74
|
+
def n_reports
|
75
|
+
self.reports.unscoped.where( :is_trash => false ).length
|
76
|
+
end
|
77
|
+
|
78
|
+
def n_private_reports
|
79
|
+
self.reports.unscoped.where( :is_public => false, :is_trash => false ).length
|
80
|
+
end
|
81
|
+
|
82
|
+
def its_locales
|
83
|
+
Site.where( :domain => self.domain ).map { |s| s.lang.to_sym }
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.Tgm
|
87
|
+
Site.find_by( :domain => 'travel-guide.mobi', :lang => :en )
|
88
|
+
end
|
89
|
+
def self.sedux
|
90
|
+
site = Site.where( :domain => 'sedux.local' ).first
|
91
|
+
site ||= Site.where( :domain => 'sedux.net' ).first
|
92
|
+
site
|
93
|
+
end
|
94
|
+
|
95
|
+
def name
|
96
|
+
"#{domain}/#{lang}"
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
class TagTrash
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::Timestamps
|
4
|
+
include Ish::Utils
|
5
|
+
|
6
|
+
field :name, :type => String
|
7
|
+
validates :name, uniqueness: true, presence: true, allow_nil: false # @TODO: tags should only be unique globally, and per-user.
|
8
|
+
|
9
|
+
field :slug
|
10
|
+
validates :slug, uniqueness: true, presence: true, allow_nil: false
|
11
|
+
|
12
|
+
field :descr, :type => String, :default => ''
|
13
|
+
|
14
|
+
field :is_public, :type => Boolean, :default => true
|
15
|
+
field :is_trash, :type => Boolean, :default => false
|
16
|
+
field :is_feature, :type => Boolean, :default => false
|
17
|
+
|
18
|
+
field :weight, :type => Integer, :default => 10
|
19
|
+
|
20
|
+
has_many :children_tags, :class_name => 'Tag', :inverse_of => :parent_tag
|
21
|
+
belongs_to :parent_tag, :class_name => 'Tag', :inverse_of => :children_tags, :optional => true
|
22
|
+
|
23
|
+
has_many :features
|
24
|
+
has_many :newsitems
|
25
|
+
|
26
|
+
belongs_to :site, :optional => true
|
27
|
+
belongs_to :city, :optional => true
|
28
|
+
|
29
|
+
has_and_belongs_to_many :venues
|
30
|
+
has_and_belongs_to_many :cities
|
31
|
+
has_and_belongs_to_many :galleries
|
32
|
+
has_and_belongs_to_many :reports
|
33
|
+
has_and_belongs_to_many :videos
|
34
|
+
has_and_belongs_to_many :maps, class_name: 'Gameui::Map'
|
35
|
+
|
36
|
+
before_validation :set_slug
|
37
|
+
|
38
|
+
def self.clear
|
39
|
+
if Rails.env.test?
|
40
|
+
Tag.each { |r| r.remove }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.no_parent
|
45
|
+
Tag.where( :parent_tag_id => nil )
|
46
|
+
end
|
47
|
+
|
48
|
+
# the first blank used to be disabled, not anymore _vp_ 20180418
|
49
|
+
def self.list
|
50
|
+
out = Tag.unscoped.order_by( :name => :asc )
|
51
|
+
return( [['', nil]] + out.map { |item| [ item.name, item.id ] } )
|
52
|
+
end
|
53
|
+
|
54
|
+
# @deprecated, there will be no reports or galleries in tags. There will be only features and newsitems
|
55
|
+
def self.n_items
|
56
|
+
10
|
57
|
+
end
|
58
|
+
def self.n_reports
|
59
|
+
4
|
60
|
+
end
|
61
|
+
def self.n_galleries
|
62
|
+
4
|
63
|
+
end
|
64
|
+
def self.n_videos
|
65
|
+
4
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.n_features
|
69
|
+
4
|
70
|
+
end
|
71
|
+
field :n_features, type: Integer, default: 4
|
72
|
+
|
73
|
+
end
|
data/lib/trash/venue.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
class Venue
|
2
|
+
include ::Mongoid::Document
|
3
|
+
include ::Mongoid::Timestamps
|
4
|
+
include Ish::Utils
|
5
|
+
|
6
|
+
field :address
|
7
|
+
|
8
|
+
field :name, :type => String
|
9
|
+
validates :name, :uniqueness => true, :allow_nil => false
|
10
|
+
|
11
|
+
field :slug
|
12
|
+
validates :slug, :uniqueness => true, :allow_nil => false
|
13
|
+
before_validation :set_slug
|
14
|
+
|
15
|
+
field :subhead
|
16
|
+
field :descr
|
17
|
+
|
18
|
+
field :is_trash, :type => Boolean, :default => false
|
19
|
+
scope :fresh, ->{ where({ :is_trash => false }) }
|
20
|
+
scope :trash, ->{ where({ :is_trash => true }) }
|
21
|
+
|
22
|
+
field :is_public, :type => Boolean, :default => true
|
23
|
+
scope :public, ->{ where({ :is_public => true }) }
|
24
|
+
scope :not_public, ->{ where({ :is_public => false }) }
|
25
|
+
|
26
|
+
field :is_feature, :type => Boolean, :default => false
|
27
|
+
|
28
|
+
field :x, :type => Float
|
29
|
+
field :y, :type => Float
|
30
|
+
|
31
|
+
field :lang, :type => String, :default => 'en'
|
32
|
+
|
33
|
+
belongs_to :city
|
34
|
+
# belongs_to :owner, :class_name => 'User', :inverse_of => :owned_venue
|
35
|
+
validates :city, :allow_nil => false, :presence => true
|
36
|
+
|
37
|
+
has_and_belongs_to_many :tags
|
38
|
+
|
39
|
+
has_and_belongs_to_many :users
|
40
|
+
|
41
|
+
has_one :profile_photo, :class_name => 'Photo', :inverse_of => :profile_venue
|
42
|
+
|
43
|
+
has_many :reports
|
44
|
+
has_many :galleries
|
45
|
+
has_many :photos
|
46
|
+
has_many :newsitems
|
47
|
+
has_many :features
|
48
|
+
|
49
|
+
PER_PAGE = 6
|
50
|
+
|
51
|
+
def self.list conditions = { :is_trash => false }
|
52
|
+
out = self.where( conditions).order_by( :name => :asc )
|
53
|
+
[['', nil]] + out.map { |item| [ item.name, item.id ] }
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
set_callback :save, :before do |doc|
|
59
|
+
if doc.city
|
60
|
+
city.touch
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.types
|
65
|
+
return []
|
66
|
+
# if 'en' == @locale
|
67
|
+
# [ 'Hotels', 'Restaurants', 'Bars' ]
|
68
|
+
# else
|
69
|
+
# [ 'Hotels', 'Restaurants', 'Bars' ]
|
70
|
+
# end
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.n_features
|
74
|
+
6
|
75
|
+
end
|
76
|
+
|
77
|
+
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.177
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
@@ -154,6 +154,12 @@ files:
|
|
154
154
|
- lib/report.rb
|
155
155
|
- lib/site.rb
|
156
156
|
- lib/tag.rb
|
157
|
+
- lib/trash/app_model2.rb
|
158
|
+
- lib/trash/city.rb-bk
|
159
|
+
- lib/trash/event.rb
|
160
|
+
- lib/trash/site.rb
|
161
|
+
- lib/trash/tag_trash.rb
|
162
|
+
- lib/trash/venue.rb
|
157
163
|
- lib/venue.rb
|
158
164
|
- lib/video.rb
|
159
165
|
homepage: https://wasya.co
|