ish_models 0.0.33 → 0.0.33.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gallery.rb +6 -4
  3. data/lib/user_profile.rb +12 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b88f19a07f74c4ebd1304b99a73c27928d4607b2
4
- data.tar.gz: 4d4c0b4cf6324a53aea82a224bd18b8ae4080463
3
+ metadata.gz: bf36e9fb0e9249951d3567491b2d8c6d3c2aea0a
4
+ data.tar.gz: dab1ae7dbc298bb669d5cfd2e14a4b624ac59f6c
5
5
  SHA512:
6
- metadata.gz: 1e5d10953f7271af06325ee754e77bcf9e1a4bbdda20bf780ff8507a5b03d1217737a13b3b314aeba471bdbacb4db9e6965818edfdc34f23b81171935bdf2e37
7
- data.tar.gz: 569f5060aef50776fdf18cabf9614dc061aecc6045aeffbcf4a3ffdc22b765b4312093fe0e4fb3d395a15a0e1c11b66669053d5705bd8c853efc3e9422bf9efd
6
+ metadata.gz: a0adefcb63ea03b69dfd96d303c76e6fa06a325cdafd55dd9313a69f859269e8818c314a939aac095f329b0c8e4944161c1587de15a7cd9591343886ba64eb74
7
+ data.tar.gz: c6dc54fa3100c2fa3bb0984f3d75edf8b8cfe4629061a7ea893563e8dab6919a0c36b09b68d9537d16219e93cfa4620f44243e2c4396eebe431017aea3f2f65e
data/lib/gallery.rb CHANGED
@@ -3,8 +3,8 @@ class Gallery < AppModel2
3
3
  belongs_to :site
4
4
  validates :site, :presence => true
5
5
 
6
- belongs_to :user, :optional => true, :class_name => 'IshModels::User'
7
- # validates :user, :presence => true
6
+ belongs_to :user, :optional => true
7
+ belongs_to :user_profile, :optional => true, :class_name => 'IshModels::UserProfile'
8
8
  field :username, :type => String
9
9
 
10
10
  field :name, :type => String
@@ -29,8 +29,10 @@ class Gallery < AppModel2
29
29
  has_many :newsitems
30
30
 
31
31
  set_callback(:create, :before) do |doc|
32
- doc.username = doc.user.username
33
- doc.galleryname = doc.name.to_simple_string
32
+ if doc.user_profile && doc.user_profile.username
33
+ doc.username = doc.user_profile.username
34
+ end
35
+ doc.galleryname = doc.id.to_s
34
36
 
35
37
  if doc.is_public
36
38
  # for the sites
data/lib/user_profile.rb CHANGED
@@ -2,6 +2,8 @@ class UserProfile
2
2
  include Mongoid::Document
3
3
  include Mongoid::Timestamps
4
4
 
5
+ field :username, :type => String
6
+
5
7
  field :about, :type => String
6
8
  field :education, :type => String
7
9
  field :objectives, :type => String
@@ -12,11 +14,20 @@ class UserProfile
12
14
  field :doc_resume_path, :type => String
13
15
 
14
16
  field :lang, :type => String
15
-
17
+
16
18
  belongs_to :user
19
+
20
+ has_many :galleries
17
21
 
18
22
  def manager?
19
23
  %w( piousbox@gmail.com manager@gmail.com ).include?( self.user.email ) ? true : false
20
24
  end
21
25
 
26
+ # manager uses it.
27
+ # @TODO: check this, this is shit. _vp_ 20170527
28
+ def self.list
29
+ out = self.all.order_by( :domain => :asc, :lang => :asc )
30
+ [['', nil]] + out.map { |item| [ item.username, item.id ] }
31
+ end
32
+
22
33
  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.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox