ish_models 0.0.33.31 → 0.0.33.32

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
  SHA1:
3
- metadata.gz: 8bc52706ccbe2c0f4eea769079e009ae0b8b12f3
4
- data.tar.gz: 7d1b2f63e0a8c7532f5e15a91807b947db5dd47f
3
+ metadata.gz: 7e747705d526fb9344bdfe6074d0c0c227db0765
4
+ data.tar.gz: 0ce281f0fc5b26486647ffe524c899d8a1de7595
5
5
  SHA512:
6
- metadata.gz: 2f4f0a06c7561bbbdae6dc0b1abb194e97318573cb9c9ec02ffa844e552ecbe9e912cfc9aa65289ba3a3b505fa7633508dc7e1a429b8677a0b066e5d100c5e37
7
- data.tar.gz: 372c31c04a48c7e2ebf0575d013a5b8335ef35d06df548997719af0ffcb4d1bbe7182eb3bbbdf84c7b9efd61bd86985b0d36b2011e785439ab2d5aa6aca26cd8
6
+ metadata.gz: 6b2264ef110897e64315e2220326a07c16bb448f6d06da84e550de96d81de877198668342504029256cd721adff0422a071f544ce83f5fbaa1a04d14480c12cd
7
+ data.tar.gz: 504db5fe120651d41fda715622deb3b72c3dcf7b77526c7db8d97748184a1db3d08617cc131765fe1357f4ae27a6b538284f1f82e0c22a51a165ebb2477ec113
data/lib/app_model2.rb CHANGED
@@ -2,16 +2,15 @@ class AppModel2
2
2
  include ::Mongoid::Document
3
3
  include ::Mongoid::Timestamps
4
4
 
5
- field :is_feature, :type => Boolean, :default => false
6
- field :is_public, :type => Boolean, :default => false
7
- field :is_done, :type => Boolean, :default => false
8
- field :is_trash, :type => Boolean, :default => false
9
- field :is_anonymous, :type => Boolean, :default => false
5
+ field :is_feature, :type => Boolean, :default => false
6
+ field :is_public, :type => Boolean, :default => false
7
+ field :is_done, :type => Boolean, :default => false
8
+ field :is_trash, :type => Boolean, :default => false
10
9
 
11
- scope :fresh, ->{ where({ :is_trash => false }) }
12
- scope :trash, ->{ where({ :is_trash => true }) }
13
- scope :public, ->{ where({ :is_public => true }) }
14
- scope :done, ->{ where({ :is_done => true }) }
10
+ scope :fresh, ->{ where({ :is_trash => false }) }
11
+ scope :trash, ->{ where({ :is_trash => true }) }
12
+ scope :public, ->{ where({ :is_public => true }) }
13
+ scope :done, ->{ where({ :is_done => true }) }
15
14
 
16
15
  default_scope ->{ where({ :is_public => true, :is_trash => false }).order_by({ :created_at => :desc }) }
17
16
 
data/lib/gallery.rb CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  class Gallery < AppModel2
2
3
 
3
4
  belongs_to :site
@@ -11,11 +12,12 @@ class Gallery < AppModel2
11
12
  validates :name, :uniqueness => true # , :allow_nil => false
12
13
 
13
14
  field :galleryname, :type => String
14
- validates :galleryname, :uniqueness => true # , :allow_nil => false
15
+ index({ :galleryname => -1 }, { :unique => true })
16
+ embeds_many :gallery_names, :class_name => 'Ish::GalleryName'
15
17
 
16
18
  field :subhead, :type => String
17
- field :descr, :type => String
18
- field :lang, :type => String, :default => 'en'
19
+ field :descr, :type => String, :as => :description
20
+ field :lang, :type => String, :default => 'en'
19
21
 
20
22
  has_many :photos
21
23
 
@@ -29,7 +31,7 @@ class Gallery < AppModel2
29
31
  if doc.user_profile && doc.user_profile.username
30
32
  doc.username = doc.user_profile.username
31
33
  end
32
- doc.galleryname = doc.id.to_s
34
+ doc.galleryname ||= doc.id.to_s
33
35
 
34
36
  #
35
37
  # newsitems
data/lib/gallery2.rb ADDED
@@ -0,0 +1,101 @@
1
+
2
+ class Gallery2
3
+ include ::Mongoid::Document
4
+ include ::Mongoid::Timestamps
5
+ store_in :collection => 'galleries'
6
+
7
+ field :is_feature, :type => Boolean, :default => false
8
+ field :is_public, :type => Boolean, :default => false
9
+ field :is_done, :type => Boolean, :default => false
10
+ field :is_trash, :type => Boolean, :default => false
11
+
12
+ default_scope ->{ where({ :is_public => true, :is_trash => false }).order_by({ :created_at => :desc }) }
13
+ index({ :is_public => 1, :is_trash => -1, :order_by => 1 })
14
+
15
+ field :x, :type => Float
16
+ field :y, :type => Float
17
+
18
+ def self.list conditions = { :is_trash => false }
19
+ out = self.where( conditions ).order_by( :created_at => :desc )
20
+ [['', nil]] + out.map { |item| [ "#{item.created_at.strftime('%Y%m%d')} #{item.name}", item.id ] }
21
+ end
22
+
23
+ belongs_to :site
24
+ validates :site, :presence => true
25
+
26
+ belongs_to :user_profile, :optional => true, :class_name => 'IshModels::UserProfile'
27
+ field :username, :type => String
28
+
29
+ field :name, :type => String
30
+ validates :name, :uniqueness => true # , :allow_nil => false
31
+
32
+ field :galleryname, :type => String
33
+ index({ :galleryname => -1 }, { :unique => true })
34
+ embeds_many :gallery_names, :class_name => 'Ish::GalleryName'
35
+
36
+ field :subhead, :type => String
37
+ field :descr, :type => String, :as => :description
38
+ field :lang, :type => String, :default => 'en'
39
+
40
+ has_many :photos
41
+
42
+ belongs_to :tag, :optional => true
43
+ belongs_to :city, :optional => true
44
+ belongs_to :venue, :optional => true
45
+
46
+ has_many :newsitems
47
+
48
+ set_callback(:create, :before) do |doc|
49
+ if doc.user_profile && doc.user_profile.username
50
+ doc.username = doc.user_profile.username
51
+ end
52
+ doc.galleryname ||= doc.id.to_s
53
+
54
+ #
55
+ # newsitems
56
+ #
57
+ if doc.is_public
58
+ # for the sites
59
+ if doc.site
60
+ sites = Site.where( :domain => doc.site.domain )
61
+ sites.each do |site|
62
+ n = Newsitem.new {}
63
+ n.gallery = doc
64
+ n.username = doc.username
65
+ site.newsitems << n
66
+ flag = site.save
67
+ if !flag
68
+ puts! site.errors
69
+ end
70
+ end
71
+ end
72
+ # for the city
73
+ if doc.city
74
+ n = Newsitem.new {}
75
+ n.gallery = doc
76
+ n.city = doc.city
77
+ n.username = doc.username
78
+ n.save
79
+ end
80
+ end
81
+
82
+ #
83
+ # cache
84
+ #
85
+ if doc.site
86
+ doc.site.touch
87
+ end
88
+ if doc.city
89
+ doc.city.touch
90
+ end
91
+
92
+ end
93
+
94
+ # @deprecated, use Gallery::ACTIONS
95
+ def self.actions
96
+ [ 'show_mini', 'show_long', 'show' ]
97
+ end
98
+ ACTIONS = [ 'show_mini', 'show_long', 'show' ]
99
+
100
+ end
101
+
@@ -0,0 +1,10 @@
1
+
2
+ module Ish
3
+ class GalleryName
4
+ include Mongoid::Document
5
+ include Mongoid::Timestamps
6
+ field :text
7
+ embedded_in :gallery
8
+ end
9
+ end
10
+
data/lib/ish_models.rb CHANGED
@@ -17,6 +17,8 @@ module IshModels
17
17
  end
18
18
  end
19
19
 
20
+ require 'ish/gallery_name.rb'
21
+
20
22
  require 'ish_models/cache_key.rb'
21
23
  # require 'ish_models/user.rb'
22
24
  require 'ish_models/stock_watch.rb'
@@ -30,6 +32,7 @@ require 'country.rb'
30
32
  require 'event.rb'
31
33
  require 'feature.rb'
32
34
  require 'gallery.rb'
35
+ require 'gallery2.rb'
33
36
  require 'manager.rb'
34
37
  require 'newsitem.rb'
35
38
  require 'photo.rb'
data/lib/photo.rb CHANGED
@@ -19,7 +19,7 @@ class Photo
19
19
  belongs_to :report, :optional => true
20
20
  belongs_to :venue, :optional => true
21
21
  belongs_to :feature, :optional => true
22
- belongs_to :gallery, :optional => true
22
+ belongs_to :gallery, :optional => true # , :class_name => 'Gallery2'
23
23
  belongs_to :newsitem, :optional => true
24
24
 
25
25
  field :name, :type => String
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.31
4
+ version: 0.0.33.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
@@ -60,6 +60,8 @@ files:
60
60
  - lib/event.rb
61
61
  - lib/feature.rb
62
62
  - lib/gallery.rb
63
+ - lib/gallery2.rb
64
+ - lib/ish/gallery_name.rb
63
65
  - lib/ish_models.rb
64
66
  - lib/ish_models.rb~
65
67
  - lib/ish_models/cache_key.rb