ish_models 0.0.33.136 → 0.0.33.140

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
  SHA256:
3
- metadata.gz: 172ea3b5881a62b2d1c4ef8bed4360782c6f9676eaa39c1be7e9febab7e8937b
4
- data.tar.gz: ba242d1b5cc551a2257a0c2183413f1a9cebd5448cc570629761cb69e9e99863
3
+ metadata.gz: 35a17d0129c4e975bf32ae05423340b47ed47a2ddd6a807df9aec2e525547adf
4
+ data.tar.gz: 28bcbbd16948cafa7e42ba80eefb87f85223c86c6363a798e21b0f32eb441676
5
5
  SHA512:
6
- metadata.gz: c849a3a2b774e4290e10e28b83561f11d85eb0ed316acc2118ad8ff6188d2d7c902b7bab1e0e192f4010a6ab9f1bafafec3ecaaecf47029084c9fcce43da2c34
7
- data.tar.gz: 5c8641248d523733c55643e8fe3ee95c4aa75cd4b7257684b60d4d48735e1a68187015abd7dbbda3558964f6c97c090a12fba4de3deab8081e952501bcec3e1d
6
+ metadata.gz: a0021a55de96d807f76330128fb49487c8bb7f571b6d586296971023d2030987226b1d7dd4e5adccba529176a6a0dfe7d5b35bea3ba93f653eeb57bd6e63e8e7
7
+ data.tar.gz: d367ce9ee126d77e7d87ee2dd7c58934256a1d546764bb4a8dbecd75717222d55d22fe7f77a7c91288423492248b7a69c5f139696cea43ff2cc2564fc5b7cb71
data/lib/gallery.rb CHANGED
@@ -3,9 +3,13 @@ require 'kaminari/mongoid'
3
3
  class Gallery
4
4
  include ::Mongoid::Document
5
5
  include ::Mongoid::Timestamps
6
+ include Ish::Utils
6
7
 
7
8
  PER_PAGE = 6
8
9
 
10
+ field :name
11
+ validates :name, :uniqueness => true # , :allow_nil => false
12
+
9
13
  field :is_public, type: Boolean, default: false
10
14
  field :is_trash, type: Boolean, default: false
11
15
  field :is_done, type: Boolean, default: false
@@ -19,51 +23,46 @@ class Gallery
19
23
 
20
24
  default_scope ->{ where({ :is_public => true, :is_trash => false }).order_by({ :created_at => :desc }) }
21
25
 
22
- field :x, :type => Float
23
- field :y, :type => Float
26
+ field :x, :type => Float
27
+ field :y, :type => Float
28
+ field :subhead
29
+ field :descr, :as => :description
30
+ field :lang, :default => 'en'
31
+ field :issue
32
+ field :username
33
+
34
+ field :slug
35
+ index({ :slug => -1 }, { :unique => true })
36
+ validates :slug, presence: true, uniqueness: true
37
+ before_validation :set_slug, :on => :create
38
+
39
+ ## @TODO: I should have a redirect service, instead of this specific thing. But only after making $50.
40
+ # embeds_many :gallery_names, :class_name => '::Ish::GalleryName'
41
+
24
42
 
25
43
  def self.list conditions = { :is_trash => false }
26
44
  out = self.unscoped.where( conditions ).order_by( :created_at => :desc )
27
45
  [['', nil]] + out.map { |item| [ "#{item.created_at.strftime('%Y%m%d')} #{item.name}", item.id ] }
28
46
  end
29
47
 
30
- belongs_to :site, :optional => true
31
- # validates :site, :presence => true
32
-
48
+ belongs_to :site, :optional => true
33
49
  belongs_to :user_profile, :optional => true, :class_name => 'IshModels::UserProfile', :inverse_of => :galleries
34
- field :username, :type => String
35
- has_and_belongs_to_many :shared_profiles, :class_name => 'IshModels::UserProfile', :inverse_of => :shared_galleries
36
-
37
- field :name
38
- validates :name, :uniqueness => true # , :allow_nil => false
39
50
 
40
- field :galleryname
41
- index({ :galleryname => -1 }, { :unique => true })
42
- def slug
43
- galleryname
44
- end
45
- embeds_many :gallery_names, :class_name => '::Ish::GalleryName'
46
- def self.find_by_slug slug
47
- ::Gallery.where( galleryname: slug ).first
48
- end
49
-
50
- field :subhead, :type => String
51
- field :descr, :type => String, :as => :description
52
- field :lang, :type => String, :default => 'en'
51
+ has_and_belongs_to_many :shared_profiles, :class_name => 'IshModels::UserProfile', :inverse_of => :shared_galleries
52
+ has_and_belongs_to_many :tags
53
53
 
54
+ has_many :newsitems
54
55
  has_many :photos
55
56
 
56
- has_and_belongs_to_many :tags
57
57
  belongs_to :city, :optional => true
58
58
  belongs_to :venue, :optional => true
59
+ belongs_to :newsparent, polymorphic: true, optional: true
59
60
 
60
- has_many :newsitems
61
61
 
62
62
  set_callback(:create, :before) do |doc|
63
63
  if doc.user_profile && doc.user_profile.name
64
64
  doc.username = doc.user_profile.name
65
65
  end
66
- doc.galleryname ||= doc.id.to_s
67
66
 
68
67
  #
69
68
  # newsitems
@@ -107,16 +106,13 @@ class Gallery
107
106
 
108
107
  # @deprecated, use Gallery::ACTIONS
109
108
  def self.actions
110
- [ 'show_mini', 'show_long', 'show' ]
109
+ ACTIONS
111
110
  end
112
111
  ACTIONS = [ 'show_mini', 'show_long', 'show' ]
113
112
 
114
- field :issue
115
-
116
113
  RENDER_TITLES = 'index_titles' # view name
117
114
  RENDER_THUMBS = 'index_thumbs' # view name
118
115
 
119
- belongs_to :newsparent, polymorphic: true, optional: true
120
116
 
121
117
  set_callback :update, :after do |doc|
122
118
  Site.update_all updated_at: Time.now
data/lib/gameui/marker.rb CHANGED
@@ -6,7 +6,8 @@ class ::Gameui::Marker
6
6
  belongs_to :map, :class_name => '::Gameui::Map'
7
7
 
8
8
  field :slug
9
- validates :slug, uniqueness: true, presence: true
9
+ validates_uniqueness_of :slug, scope: :map_id
10
+ validates_presence_of :slug
10
11
 
11
12
  field :description
12
13
 
data/lib/ish/utils.rb CHANGED
@@ -5,7 +5,11 @@ module Ish::Utils
5
5
 
6
6
  def set_slug
7
7
  return if slug
8
- new_slug = name.downcase.gsub(/[^a-z0-9\s]/i, '').gsub(' ', '-')
8
+ if name
9
+ new_slug = name.downcase.gsub(/[^a-z0-9\s]/i, '').gsub(' ', '-')
10
+ else
11
+ new_slug = '1'
12
+ end
9
13
  if self.class.where( slug: new_slug ).first
10
14
  loop do
11
15
  if new_slug[new_slug.length-1].to_i != 0
@@ -16,11 +16,13 @@ class IshModels::UserProfile
16
16
  field :fb_long_access_token
17
17
  field :fb_expires_in
18
18
 
19
- field :lang, :type => String, :default => :en
19
+ field :lang, default: 'en'
20
20
 
21
21
  ROLES = [ :admin, :manager, :guy ]
22
22
  field :role_name, :type => Symbol
23
23
 
24
+ has_one :profile_photo, :class_name => 'Photo', :inverse_of => :profile_city
25
+
24
26
  belongs_to :user
25
27
  belongs_to :current_city, :class_name => 'City', :inverse_of => :current_users, :optional => true
26
28
  belongs_to :guide_city, :class_name => 'City', :inverse_of => :guide, :optional => true
@@ -90,16 +92,3 @@ class IshModels::UserProfile
90
92
  end
91
93
 
92
94
  Profile = IshModels::UserProfile
93
-
94
- =begin
95
- field :about, :type => String
96
- field :education, :type => String
97
- field :objectives, :type => String
98
- field :current_employment, :type => String
99
- field :past_employment, :type => String
100
- field :pdf_resume_path, :type => String
101
- field :doc_resume_path, :type => String
102
-
103
- TAGS = [ :social, :professional ]
104
- field :tag, :type => Symbol
105
- =end
data/lib/photo.rb CHANGED
@@ -5,17 +5,16 @@ class Photo
5
5
  include Mongoid::Timestamps
6
6
  include Mongoid::Paperclip
7
7
 
8
- # belongs_to :user, :inverse_of => :photos
9
- # validates :user, :presence => true
10
- # field :username, :type => String
11
-
12
8
  has_and_belongs_to_many :viewers, :class_name => 'User', :inverse_of => :viewable_photos
13
9
 
14
10
  belongs_to :user_profile, :class_name => 'IshModels::UserProfile', :optional => true
15
- def user; user_profile; end
16
- belongs_to :profile_city, :class_name => 'City', :inverse_of => :profile_photo, :optional => true
17
- belongs_to :profile_venue, :class_name => 'Venue', :inverse_of => :profile_photo, :optional => true
18
- belongs_to :profile_event, :class_name => 'Event', :inverse_of => :profile_photo, :optional => true
11
+ def user
12
+ user_profile
13
+ end
14
+ belongs_to :profile_city, :class_name => 'City', :inverse_of => :profile_photo, :optional => true
15
+ belongs_to :user_profile, :class_name => 'IshModels::UserProfile', :inverse_of => :profile_photo, :optional => true
16
+ belongs_to :profile_venue, :class_name => 'Venue', :inverse_of => :profile_photo, :optional => true
17
+ belongs_to :profile_event, :class_name => 'Event', :inverse_of => :profile_photo, :optional => true
19
18
 
20
19
  belongs_to :report, :optional => true
21
20
  belongs_to :venue, :optional => true
data/lib/report.rb CHANGED
@@ -11,6 +11,7 @@ class Report
11
11
  field :slug
12
12
  validates :slug, :uniqueness => true, :presence => true
13
13
  index({ :slug => 1 }, { :unique => true })
14
+ before_validation :set_slug, :on => :create
14
15
 
15
16
  ## Can be one of: default (nil), longscroll
16
17
  field :item_type, type: String
@@ -18,7 +19,7 @@ class Report
18
19
  field :descr, :type => String
19
20
 
20
21
  field :is_trash, :type => Boolean, :default => false
21
- index :is_trash => 1, :is_public => 1
22
+ index({ :is_trash => 1, :is_public => 1 }, { name: 'default_index' })
22
23
 
23
24
  field :is_public, :type => Boolean, :default => true
24
25
  index({ :is_public => 1 })
@@ -97,7 +98,7 @@ class Report
97
98
  end
98
99
  end
99
100
 
100
- before_validation :set_slug, :on => :create
101
+
101
102
 
102
103
  set_callback :update, :after do |doc|
103
104
  Site.update_all updated_at: Time.now
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.136
4
+ version: 0.0.33.140
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox