ish_models 0.0.33.174 → 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: e193de4eeef224f54fcf57c898a9bc3b6a6442a3fdb92ebc39bbe631e884c760
4
- data.tar.gz: be392236fdc22f242252992c4f473623798b1d837fb036be850f54dd6a26a32d
3
+ metadata.gz: a810365ee2634ffbe66e6d14a7f189fd852163998af2c3edde1a57d4b2d68f7d
4
+ data.tar.gz: 89845a5d0201ec225d6a2a0f645169603a66612f82b4fcb10ba9b5e7e6ebad9e
5
5
  SHA512:
6
- metadata.gz: c9e4729d7c569a6fe830403583e95552f2bf96b16d0d73601059e9680eb67ec8f526b9a5c655ebdc7f23312cd9608aafd44de088cb435f8b579ddfc2da514b7d
7
- data.tar.gz: e74ca05bc40aa65fdf65b31b228e5410bd9be2299664261404eb4e1e98b4f6af3632cd08445d9c6e23c33b89638b15a7540270cef023972c04c8d2e0c282d229
6
+ metadata.gz: 0c4a699711808f394354761e45910afafa47efd8e8c6f2e378e680ed5a1edc4c9a6ff36714aa196a93dba4bae0070b0dc817753458d82b67423a11aa5d6aa42d
7
+ data.tar.gz: f5c50bcfffb3d7d2e130bb64c11b66b6f47297771bb0f68fb1a89df4e09c2b4dc1dd52f62fb9f0f70e37caab3f6bd6098ff4af829bfcb4e99172248a4532c270
data/lib/gameui/marker.rb CHANGED
@@ -97,7 +97,6 @@ class ::Gameui::Marker
97
97
  map_id
98
98
  name
99
99
  ordering
100
- slug
101
100
  url
102
101
  version
103
102
  w
@@ -107,8 +106,6 @@ class ::Gameui::Marker
107
106
  end
108
107
 
109
108
  def collect export_object
110
- puts! export_object, "collecting in marker: |#{slug}|."
111
-
112
109
  if image
113
110
  export_object[:image_assets][image.id.to_s] = image.id.to_s
114
111
  end
@@ -1,15 +1,26 @@
1
1
 
2
- ##
3
- ## This shouldn't really be in Ish namespace... but oh well
4
- ##
2
+ #
3
+ # This looks like it sends a single email?
4
+ #
5
5
 
6
6
  class Ish::EmailContext
7
7
  include Mongoid::Document
8
8
  include Mongoid::Timestamps
9
9
 
10
10
  field :to_email
11
+ validates_presence_of :to_email
12
+
11
13
  field :subject
12
- field :template_name
14
+ validates_presence_of :subject
15
+
16
+ field :body
17
+ validates_presence_of :body
18
+
19
+ belongs_to :email_template
20
+
21
+ field :rendered_str
22
+
23
+ field :sent_at, type: DateTime
13
24
 
14
25
  end
15
26
  EmailContext = Ish::EmailContext
@@ -0,0 +1,13 @@
1
+
2
+ class ::Ish::EmailTemplate
3
+ include Mongoid::Document
4
+ include Mongoid::Timestamps
5
+
6
+ field :slug
7
+ validates_uniqueness_of :slug, scope: [ :version ]
8
+ validates_presence_of :slug
9
+
10
+ field :version, default: '0.0.0'
11
+
12
+ end
13
+ EmailTemplate = ::Ish::EmailTemplate
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.
data/lib/ish_models.rb CHANGED
@@ -44,6 +44,7 @@ require 'ish/cache_key'
44
44
  require 'ish/campaign'
45
45
  require 'ish/crawler'
46
46
  require 'ish/email_context'
47
+ require 'ish/email_template'
47
48
  require 'ish/gallery_name'
48
49
  require 'ish/image_asset'
49
50
  require 'ish/input_error'
@@ -56,6 +57,7 @@ require 'ish/premium_item'
56
57
  require 'ish/unsubscribe'
57
58
  require 'ish/user_profile'
58
59
 
60
+
59
61
  require 'city'
60
62
  require 'cities_user'
61
63
  require 'country'
data/lib/newsitem.rb CHANGED
@@ -29,6 +29,7 @@ class Newsitem
29
29
  def description
30
30
  descr
31
31
  end
32
+ field :subhead
32
33
 
33
34
  field :image_path
34
35
  field :link_path
data/lib/photo.rb CHANGED
@@ -27,6 +27,7 @@ class Photo
27
27
 
28
28
  field :name, :type => String
29
29
  field :descr, :type => String
30
+ field :subhead
30
31
  field :weight, :type => Integer, :default => 10
31
32
 
32
33
  field :is_public, :type => Boolean, :default => true
@@ -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.174
4
+ version: 0.0.33.176
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
@@ -132,6 +132,7 @@ files:
132
132
  - lib/ish/configuration.rb
133
133
  - lib/ish/crawler.rb
134
134
  - lib/ish/email_context.rb
135
+ - lib/ish/email_template.rb
135
136
  - lib/ish/gallery_name.rb
136
137
  - lib/ish/image_asset.rb
137
138
  - lib/ish/input_error.rb
@@ -153,6 +154,12 @@ files:
153
154
  - lib/report.rb
154
155
  - lib/site.rb
155
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
156
163
  - lib/venue.rb
157
164
  - lib/video.rb
158
165
  homepage: https://wasya.co