ish_models 0.0.33.175 → 0.0.33.176

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: 5349fd582ae245c9fc34c05cb1e72cca9868c2a3ae2012b19043e152ed5db0c7
4
- data.tar.gz: 9ef7b974e6c2995e69a94ed68d6d16044c55b923630a02fb72ddac125f0d17c9
3
+ metadata.gz: a810365ee2634ffbe66e6d14a7f189fd852163998af2c3edde1a57d4b2d68f7d
4
+ data.tar.gz: 89845a5d0201ec225d6a2a0f645169603a66612f82b4fcb10ba9b5e7e6ebad9e
5
5
  SHA512:
6
- metadata.gz: 383dcf0cdce386bc597cdbd64baad28d00d6647482fd23775032acf040dfb22e448f3602a1cb64132f3a18ba889a48e0799e2198356287e709b5712f1069aabc
7
- data.tar.gz: ad082ecd825e7264a147a0dec3b7f74dac3702110e41ca77783491a67d50ed4c55d139f0d7727e48c905a74bad40d88c66f8723cdbb3897d10e2720fbf52db86
6
+ metadata.gz: 0c4a699711808f394354761e45910afafa47efd8e8c6f2e378e680ed5a1edc4c9a6ff36714aa196a93dba4bae0070b0dc817753458d82b67423a11aa5d6aa42d
7
+ data.tar.gz: f5c50bcfffb3d7d2e130bb64c11b66b6f47297771bb0f68fb1a89df4e09c2b4dc1dd52f62fb9f0f70e37caab3f6bd6098ff4af829bfcb4e99172248a4532c270
data/lib/ish/lead.rb CHANGED
@@ -49,6 +49,3 @@ class Ish::Lead
49
49
  field :extra, :type => Array, :default => []
50
50
 
51
51
  end
52
-
53
- Lead = Ish::Lead
54
-
@@ -82,8 +82,9 @@ class Ish::UserProfile
82
82
  ## @TODO: better naming convention, or remove this
83
83
  field :videos_embed, :type => Boolean, :default => false
84
84
 
85
+ ## @TODO: remove _vp_ 2022-10-04
85
86
  def sudoer?
86
- %w( piousbox@gmail.com victor@wasya.co ).include?( self.user.email ) ? true : false
87
+ %w( piousbox@gmail.com victor@wasya.co ).include?( email )
87
88
  end
88
89
 
89
90
  ## 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
+
@@ -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
@@ -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.175
4
+ version: 0.0.33.176
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