ish_models 0.0.6 → 0.0.29.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cache_key.rb~ +10 -0
- data/lib/cities_user.rb +17 -0
- data/lib/cities_user.rb~ +17 -0
- data/lib/city.rb +16 -9
- data/lib/gallery.rb +8 -6
- data/lib/ish_models/cache_key.rb +14 -0
- data/lib/ish_models/cache_key.rb~ +13 -0
- data/lib/ish_models/configuration.rb +11 -0
- data/lib/ish_models/configuration.rb~ +5 -0
- data/lib/ish_models/profile.rb +5 -0
- data/lib/ish_models/profile.rb~ +0 -0
- data/lib/ish_models/railtie.rb +27 -0
- data/lib/ish_models/railtie.rb~ +6 -0
- data/lib/ish_models/user.rb +125 -0
- data/lib/ish_models/user.rb~ +122 -0
- data/lib/ish_models.rb +22 -1
- data/lib/newsitem.rb +8 -6
- data/lib/photo.rb +13 -27
- data/lib/report.rb +10 -10
- data/lib/site.rb +6 -2
- data/lib/video.rb +0 -3
- metadata +14 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 733636d40b3fe04776da37c40360541136e61166
|
4
|
+
data.tar.gz: 3357164a8dc078c5a0c0fd4424de16feb5a000e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 944c55cce78cda9b9a9ad51195bf90676c4b20811af2601693e00e9ffa6cd56f0319a18b263cf72dd82061e519c999a214b86c97b67a4e3b06978d3e232de326
|
7
|
+
data.tar.gz: 8ccfb1542fe5aea56acca00f97c5c4d3236657bbdf56d75a151e5587c0659c0ec637ab2fd3c2de2239cf610df3fccb7e45b465d169f8e761d1d21fc1dff698ed
|
data/lib/cache_key.rb~
ADDED
data/lib/cities_user.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
class CitiesUser
|
3
|
+
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Timestamps
|
6
|
+
|
7
|
+
field :date, :type => Time
|
8
|
+
field :name, :type => String
|
9
|
+
field :descr, :type => String
|
10
|
+
|
11
|
+
belongs_to :city
|
12
|
+
belongs_to :user
|
13
|
+
|
14
|
+
has_many :reports
|
15
|
+
has_many :galleries
|
16
|
+
|
17
|
+
end
|
data/lib/cities_user.rb~
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
class CitiesUser
|
3
|
+
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Timestamps
|
6
|
+
|
7
|
+
field :date, :type => Time
|
8
|
+
field :name, :type => String
|
9
|
+
field :descr, :type => String
|
10
|
+
|
11
|
+
belongs_to :city
|
12
|
+
belongs_to :user
|
13
|
+
|
14
|
+
has_many :reports
|
15
|
+
has_many :galleries
|
16
|
+
|
17
|
+
end
|
data/lib/city.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
|
2
|
-
class City
|
3
|
-
|
1
|
+
class City
|
4
2
|
include ::Mongoid::Document
|
5
3
|
include ::Mongoid::Timestamps
|
6
4
|
|
7
|
-
# this does not have to be validated because I can autogenerate this value, yes?
|
8
5
|
field :name, :type => String
|
9
6
|
|
7
|
+
field :description, :type => String, :default => 'The description of this city'
|
8
|
+
|
10
9
|
field :cityname, :type => String
|
11
10
|
validates :cityname, :uniqueness => true, :allow_nil => false, :presence => true
|
12
11
|
|
@@ -24,7 +23,7 @@ class City
|
|
24
23
|
field :x, :type => Float
|
25
24
|
field :y, :type => Float
|
26
25
|
|
27
|
-
belongs_to :country
|
26
|
+
belongs_to :country, :optional => true
|
28
27
|
|
29
28
|
has_many :events
|
30
29
|
has_many :galleries
|
@@ -32,13 +31,13 @@ class City
|
|
32
31
|
has_many :reports
|
33
32
|
has_many :venues
|
34
33
|
has_many :videos
|
34
|
+
has_many :current_users, :class_name => 'User', :inverse_of => :current_city
|
35
35
|
|
36
36
|
has_one :profile_photo, :class_name => 'Photo', :inverse_of => :profile_city
|
37
37
|
has_one :guide, :class_name => 'User', :inverse_of => :guide_city
|
38
|
-
has_many :current_users, :class_name => 'User', :inverse_of => :current_city
|
39
38
|
|
40
|
-
|
41
|
-
|
39
|
+
has_many :newsitems
|
40
|
+
|
42
41
|
# @TODO @deprecated, I wish I don't use it.
|
43
42
|
field :n_newsitems, :type => Integer, :default => 16
|
44
43
|
|
@@ -112,6 +111,14 @@ class City
|
|
112
111
|
self.newsitems << Newsitem.new({ :descr => '', :username => '', :video => doc })
|
113
112
|
end
|
114
113
|
end
|
115
|
-
|
114
|
+
|
115
|
+
def self.method_missing name, *args, &block
|
116
|
+
city = City.where( :cityname => name ).first
|
117
|
+
return city if city
|
118
|
+
super
|
119
|
+
end
|
120
|
+
|
116
121
|
end
|
117
122
|
|
123
|
+
|
124
|
+
|
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
|
7
|
-
validates :user, :presence => true
|
6
|
+
belongs_to :user, :optional => true, :class_name => 'IshModels::User'
|
7
|
+
# validates :user, :presence => true
|
8
8
|
field :username, :type => String
|
9
9
|
|
10
10
|
field :name, :type => String
|
@@ -22,10 +22,12 @@ class Gallery < AppModel2
|
|
22
22
|
|
23
23
|
has_many :photos
|
24
24
|
|
25
|
-
belongs_to :tag
|
26
|
-
belongs_to :city
|
27
|
-
belongs_to :venue
|
28
|
-
|
25
|
+
belongs_to :tag, :optional => true
|
26
|
+
belongs_to :city, :optional => true
|
27
|
+
belongs_to :venue, :optional => true
|
28
|
+
|
29
|
+
has_many :newsitems
|
30
|
+
|
29
31
|
set_callback(:create, :before) do |doc|
|
30
32
|
doc.username = doc.user.username
|
31
33
|
doc.galleryname = doc.name.to_simple_string
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
require 'rails'
|
3
|
+
require 'byebug'
|
4
|
+
|
5
|
+
File.open('/tmp/this', 'a') { |f| f.puts "#{Time.now} - load railtie" }
|
6
|
+
|
7
|
+
module IshModels
|
8
|
+
class Railtie < Rails::Railtie
|
9
|
+
|
10
|
+
config.ish_models = ActiveSupport::OrderedOptions.new
|
11
|
+
|
12
|
+
initializer "ish_models.configure" do |app|
|
13
|
+
File.open('/tmp/this', 'a') { |f| f.puts "#{Time.now} - in railtie of ish_models" }
|
14
|
+
|
15
|
+
IshModels.configure do |config|
|
16
|
+
File.open('/tmp/this', 'a') { |f| f.puts "#{Time.now} - inside IshModels.configure inside... railtie" }
|
17
|
+
|
18
|
+
require Rails.root.join("config/initializers/00_s3.rb")
|
19
|
+
|
20
|
+
config.s3_cretendials = ::S3_CREDENTIALS
|
21
|
+
end
|
22
|
+
|
23
|
+
require Rails.root.join("config/initializers/00_s3.rb")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,125 @@
|
|
1
|
+
|
2
|
+
class IshModels::User
|
3
|
+
include Mongoid::Document
|
4
|
+
include Mongoid::Timestamps
|
5
|
+
|
6
|
+
# Setup accessible (or protected) attributes for your model
|
7
|
+
# attr_accessible :email, :password, :password_confirmation, :remember_me
|
8
|
+
|
9
|
+
## Database authenticatable
|
10
|
+
field :email, type: String, default: ""
|
11
|
+
validates :email, :presence => true, :uniqueness => true
|
12
|
+
|
13
|
+
field :encrypted_password, type: String, default: ""
|
14
|
+
|
15
|
+
## Recoverable
|
16
|
+
field :reset_password_token, type: String
|
17
|
+
field :reset_password_sent_at, type: Time
|
18
|
+
|
19
|
+
## Rememberable
|
20
|
+
field :remember_created_at, type: Time
|
21
|
+
|
22
|
+
## Trackable
|
23
|
+
field :sign_in_count, type: Integer, default: 0
|
24
|
+
field :current_sign_in_at, type: Time
|
25
|
+
field :last_sign_in_at, type: Time
|
26
|
+
field :current_sign_in_ip, type: String
|
27
|
+
field :last_sign_in_ip, type: String
|
28
|
+
|
29
|
+
## Confirmable
|
30
|
+
# field :confirmation_token, type: String
|
31
|
+
# field :confirmed_at, type: Time
|
32
|
+
# field :confirmation_sent_at, type: Time
|
33
|
+
# field :unconfirmed_email, type: String # Only if using reconfirmable
|
34
|
+
|
35
|
+
## Lockable
|
36
|
+
# field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
37
|
+
# field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
38
|
+
# field :locked_at, type: Time
|
39
|
+
|
40
|
+
# :recoverable, :trackable :rememberable,
|
41
|
+
# :token_authenticatable,
|
42
|
+
# :lockable, :timeoutable, :confirmable
|
43
|
+
|
44
|
+
# herehere, this was in (now its out)
|
45
|
+
# devise :registerable, :validatable
|
46
|
+
# devise :database_authenticatable, :authentication_keys => [ :email ]
|
47
|
+
|
48
|
+
# devise :omniauthable, :omniauth_providers => [ :facebook ]
|
49
|
+
# devise :encryptable, :encryptor => :sha1base64
|
50
|
+
#
|
51
|
+
#
|
52
|
+
# field :confirmed_at, :type => DateTime
|
53
|
+
# field :confirmation_token, :type => String
|
54
|
+
# field :confirmation_sent_at, :type => DateTime
|
55
|
+
|
56
|
+
field :username, :type => String
|
57
|
+
validates :username, :presence => true, :uniqueness => true
|
58
|
+
|
59
|
+
field :name, :type => String
|
60
|
+
validates :name, :presence => true
|
61
|
+
|
62
|
+
field :group_id, :type => Integer, :default => 3
|
63
|
+
|
64
|
+
field :scratchpad, :type => String
|
65
|
+
field :github_path, :type => String
|
66
|
+
field :facebook_path, :type => String
|
67
|
+
field :stackoverflow_path, :type => String
|
68
|
+
|
69
|
+
field :is_feature, :type => Boolean, :default => false
|
70
|
+
field :is_trash, :type => Boolean, :default => false
|
71
|
+
|
72
|
+
field :display_ads, :type => Boolean, :default => true
|
73
|
+
field :display_help, :type => Boolean, :default => true
|
74
|
+
|
75
|
+
has_many :reports
|
76
|
+
has_many :photos
|
77
|
+
has_many :user_profiles
|
78
|
+
has_many :galleries
|
79
|
+
has_many :videos
|
80
|
+
|
81
|
+
has_one :profile_photo, :class_name => 'Photo', :inverse_of => :profile_user
|
82
|
+
|
83
|
+
has_and_belongs_to_many :viewable_photos, :class_name => 'Photo', :inverse_of => :viewer
|
84
|
+
|
85
|
+
belongs_to :guide_city, :class_name => 'City', :inverse_of => :guide
|
86
|
+
belongs_to :current_city, :class_name => 'City', :inverse_of => :city_users
|
87
|
+
|
88
|
+
def self.list conditions = { :is_trash => false }
|
89
|
+
out = self.where( conditions ).order_by( :name => :asc )
|
90
|
+
[['', nil]] + out.map { |item| [ item.name, item.id ] }
|
91
|
+
end
|
92
|
+
|
93
|
+
embeds_many :newsitems
|
94
|
+
|
95
|
+
def self.all
|
96
|
+
self.where( :is_trash => false ).order_by( :created_at => :desc )
|
97
|
+
end
|
98
|
+
|
99
|
+
def create_newsitem args = {}
|
100
|
+
unless args[:photo].blank?
|
101
|
+
n = Newsitem.new
|
102
|
+
n.photo = args[:photo]
|
103
|
+
n.descr = 'uploaded new photo on'
|
104
|
+
n.username = self.username
|
105
|
+
self.newsitems << n
|
106
|
+
self.save
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.per_page
|
111
|
+
16
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.clear
|
115
|
+
if Rails.env.test?
|
116
|
+
User.unscoped.each { |u| u.remove }
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def generate_auth_token
|
121
|
+
payload = { user_id: self.id }
|
122
|
+
AuthToken.encode(payload)
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
|
2
|
+
class IshModels::User
|
3
|
+
include Mongoid::Document
|
4
|
+
include Mongoid::Timestamps
|
5
|
+
|
6
|
+
# Setup accessible (or protected) attributes for your model
|
7
|
+
# attr_accessible :email, :password, :password_confirmation, :remember_me
|
8
|
+
|
9
|
+
## Database authenticatable
|
10
|
+
field :email, type: String, default: ""
|
11
|
+
validates :email, :presence => true, :uniqueness => true
|
12
|
+
|
13
|
+
field :encrypted_password, type: String, default: ""
|
14
|
+
|
15
|
+
## Recoverable
|
16
|
+
field :reset_password_token, type: String
|
17
|
+
field :reset_password_sent_at, type: Time
|
18
|
+
|
19
|
+
## Rememberable
|
20
|
+
field :remember_created_at, type: Time
|
21
|
+
|
22
|
+
## Trackable
|
23
|
+
field :sign_in_count, type: Integer, default: 0
|
24
|
+
field :current_sign_in_at, type: Time
|
25
|
+
field :last_sign_in_at, type: Time
|
26
|
+
field :current_sign_in_ip, type: String
|
27
|
+
field :last_sign_in_ip, type: String
|
28
|
+
|
29
|
+
## Confirmable
|
30
|
+
# field :confirmation_token, type: String
|
31
|
+
# field :confirmed_at, type: Time
|
32
|
+
# field :confirmation_sent_at, type: Time
|
33
|
+
# field :unconfirmed_email, type: String # Only if using reconfirmable
|
34
|
+
|
35
|
+
## Lockable
|
36
|
+
# field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
37
|
+
# field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
38
|
+
# field :locked_at, type: Time
|
39
|
+
|
40
|
+
# :recoverable, :trackable :rememberable,
|
41
|
+
# :token_authenticatable,
|
42
|
+
# :lockable, :timeoutable, :confirmable
|
43
|
+
devise :registerable, :validatable
|
44
|
+
devise :database_authenticatable, :authentication_keys => [ :email ]
|
45
|
+
# devise :omniauthable, :omniauth_providers => [ :facebook ]
|
46
|
+
# devise :encryptable, :encryptor => :sha1base64
|
47
|
+
#
|
48
|
+
#
|
49
|
+
# field :confirmed_at, :type => DateTime
|
50
|
+
# field :confirmation_token, :type => String
|
51
|
+
# field :confirmation_sent_at, :type => DateTime
|
52
|
+
|
53
|
+
field :username, :type => String
|
54
|
+
validates :username, :presence => true, :uniqueness => true
|
55
|
+
|
56
|
+
field :name, :type => String
|
57
|
+
validates :name, :presence => true
|
58
|
+
|
59
|
+
field :group_id, :type => Integer, :default => 3
|
60
|
+
|
61
|
+
field :scratchpad, :type => String
|
62
|
+
field :github_path, :type => String
|
63
|
+
field :facebook_path, :type => String
|
64
|
+
field :stackoverflow_path, :type => String
|
65
|
+
|
66
|
+
field :is_feature, :type => Boolean, :default => false
|
67
|
+
field :is_trash, :type => Boolean, :default => false
|
68
|
+
|
69
|
+
field :display_ads, :type => Boolean, :default => true
|
70
|
+
field :display_help, :type => Boolean, :default => true
|
71
|
+
|
72
|
+
has_many :reports
|
73
|
+
has_many :photos
|
74
|
+
has_many :user_profiles
|
75
|
+
has_many :galleries
|
76
|
+
has_many :videos
|
77
|
+
|
78
|
+
has_one :profile_photo, :class_name => 'Photo', :inverse_of => :profile_user
|
79
|
+
|
80
|
+
has_and_belongs_to_many :viewable_photos, :class_name => 'Photo', :inverse_of => :viewer
|
81
|
+
|
82
|
+
belongs_to :guide_city, :class_name => 'City', :inverse_of => :guide
|
83
|
+
belongs_to :current_city, :class_name => 'City', :inverse_of => :city_users
|
84
|
+
|
85
|
+
def self.list conditions = { :is_trash => false }
|
86
|
+
out = self.where( conditions ).order_by( :name => :asc )
|
87
|
+
[['', nil]] + out.map { |item| [ item.name, item.id ] }
|
88
|
+
end
|
89
|
+
|
90
|
+
embeds_many :newsitems
|
91
|
+
|
92
|
+
def self.all
|
93
|
+
self.where( :is_trash => false ).order_by( :created_at => :desc )
|
94
|
+
end
|
95
|
+
|
96
|
+
def create_newsitem args = {}
|
97
|
+
unless args[:photo].blank?
|
98
|
+
n = Newsitem.new
|
99
|
+
n.photo = args[:photo]
|
100
|
+
n.descr = 'uploaded new photo on'
|
101
|
+
n.username = self.username
|
102
|
+
self.newsitems << n
|
103
|
+
self.save
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.per_page
|
108
|
+
16
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.clear
|
112
|
+
if Rails.env.test?
|
113
|
+
User.unscoped.each { |u| u.remove }
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def generate_auth_token
|
118
|
+
payload = { user_id: self.id }
|
119
|
+
AuthToken.encode(payload)
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
data/lib/ish_models.rb
CHANGED
@@ -1,7 +1,29 @@
|
|
1
1
|
|
2
|
+
require 'ish_models/configuration'
|
3
|
+
require 'ish_models/railtie' if defined?(Rails)
|
4
|
+
|
5
|
+
module IshModels
|
6
|
+
|
7
|
+
class << self
|
8
|
+
attr_accessor :configuration
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.configure
|
12
|
+
@configuration ||= Configuration.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.setup
|
16
|
+
yield(configuration)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'ish_models/cache_key.rb'
|
21
|
+
require 'ish_models/user.rb'
|
22
|
+
|
2
23
|
require 'app_model2.rb'
|
3
24
|
require 'aux_model.rb'
|
4
25
|
require 'city.rb'
|
26
|
+
require 'cities_user.rb'
|
5
27
|
require 'country.rb'
|
6
28
|
require 'event.rb'
|
7
29
|
require 'feature.rb'
|
@@ -14,4 +36,3 @@ require 'site.rb'
|
|
14
36
|
require 'tag.rb'
|
15
37
|
require 'venue.rb'
|
16
38
|
require 'video.rb'
|
17
|
-
|
data/lib/newsitem.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
class Newsitem
|
2
2
|
include Mongoid::Document
|
3
3
|
include Mongoid::Timestamps
|
4
|
-
|
5
|
-
|
4
|
+
|
5
|
+
=begin
|
6
6
|
embedded_in :user
|
7
7
|
embedded_in :site
|
8
8
|
embedded_in :city
|
9
9
|
embedded_in :tag
|
10
|
+
=end
|
10
11
|
|
11
|
-
belongs_to :
|
12
|
-
belongs_to :
|
13
|
-
belongs_to :
|
14
|
-
belongs_to :
|
12
|
+
belongs_to :site, :optional => true
|
13
|
+
belongs_to :city, :optional => true
|
14
|
+
belongs_to :report, :optional => true
|
15
|
+
belongs_to :gallery, :optional => true
|
16
|
+
# has_one :video
|
15
17
|
|
16
18
|
field :name, :type => String
|
17
19
|
field :descr, :type => String
|
data/lib/photo.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
-
|
2
1
|
class Photo
|
3
2
|
require 'aws-sdk'
|
4
|
-
require 'aws-sdk-v1'
|
5
3
|
|
6
4
|
include Mongoid::Document
|
7
5
|
include Mongoid::Timestamps
|
8
6
|
include Mongoid::Paperclip
|
9
7
|
|
10
|
-
belongs_to :user,
|
11
|
-
validates
|
12
|
-
field
|
8
|
+
belongs_to :user, :inverse_of => :photos
|
9
|
+
validates :user, :presence => true
|
10
|
+
field :username, :type => String
|
13
11
|
|
14
12
|
has_and_belongs_to_many :viewers, :class_name => 'User', :inverse_of => :viewable_photos
|
15
13
|
|
@@ -23,47 +21,35 @@ class Photo
|
|
23
21
|
belongs_to :feature
|
24
22
|
belongs_to :gallery
|
25
23
|
|
26
|
-
field :name,
|
27
|
-
field :descr,
|
28
|
-
|
24
|
+
field :name, :type => String
|
25
|
+
field :descr, :type => String
|
29
26
|
field :weight, :type => Integer, :default => 10
|
30
27
|
|
31
|
-
field :is_public, :type => Boolean, :default => true
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
field :is_public, :type => Boolean, :default => true
|
29
|
+
|
30
|
+
# @TODO: nuke this boolean _vp_ 20170515
|
31
|
+
field :is_trash, :type => Boolean, :default => false
|
35
32
|
default_scope ->{ where({ :is_trash => false }) }
|
36
33
|
|
34
|
+
File.open('/tmp/this', 'a') { |f| f.puts "#{Time.now} - inside photo.rb" }
|
35
|
+
|
37
36
|
has_mongoid_attached_file :photo,
|
38
37
|
:styles => {
|
39
38
|
:mini => '20x20#',
|
40
39
|
:thumb => "100x100#",
|
41
|
-
# :two_hundred => '200x200#',
|
42
40
|
:small => "400x400>",
|
43
|
-
# :small_square => "400x400#",
|
44
|
-
# :large_square => '950x650',
|
45
41
|
:large => '950x650>'
|
46
42
|
},
|
47
43
|
:storage => :s3,
|
48
44
|
:s3_credentials => ::S3_CREDENTIALS,
|
49
|
-
:path => "photos/:style/:id/:filename"
|
45
|
+
:path => "photos/:style/:id/:filename",
|
46
|
+
:s3_protocol => 'http'
|
50
47
|
|
51
48
|
def self.n_per_manager_gallery
|
52
49
|
25
|
53
50
|
end
|
54
51
|
|
55
52
|
validates_attachment_content_type :photo, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]
|
56
|
-
|
57
|
-
set_callback(:create, :before) do |doc|
|
58
|
-
# if doc.is_public
|
59
|
-
# Site.languages.each do |lang|
|
60
|
-
# n = Newsitem.new({
|
61
|
-
# # :descr => t('photos.new'),
|
62
|
-
# :photo => doc, :username => doc.user.username })
|
63
|
-
# Site.where( :domain => DOMAIN, :lang => lang ).first.newsitems << n
|
64
|
-
# end
|
65
|
-
# end
|
66
|
-
end
|
67
53
|
|
68
54
|
end
|
69
55
|
|
data/lib/report.rb
CHANGED
@@ -34,22 +34,20 @@ class Report
|
|
34
34
|
field :lang, :type => String, :default => 'en'
|
35
35
|
index({ :lang => 1 })
|
36
36
|
|
37
|
+
belongs_to :user, :optional => true, :class_name => 'IshModels::User'
|
38
|
+
# validates :user, :presence => true, :allow_nil => false
|
37
39
|
field :username, :type => String, :default => 'anonymous'
|
38
40
|
validates :username, :presence => true, :allow_nil => false
|
39
|
-
belongs_to :user
|
40
|
-
validates :user, :presence => true, :allow_nil => false
|
41
41
|
index({ :username => 1 })
|
42
42
|
|
43
43
|
field :subhead, :type => String
|
44
44
|
|
45
|
-
belongs_to :tag
|
46
|
-
belongs_to :city
|
47
|
-
|
48
|
-
belongs_to :
|
49
|
-
|
50
|
-
|
45
|
+
belongs_to :tag, :optional => true
|
46
|
+
belongs_to :city, :optional => true
|
47
|
+
belongs_to :site, :optional => true
|
48
|
+
belongs_to :cities_user, :optional => true
|
49
|
+
|
51
50
|
has_and_belongs_to_many :venues
|
52
|
-
belongs_to :cities_user
|
53
51
|
|
54
52
|
has_one :photo
|
55
53
|
|
@@ -60,6 +58,8 @@ class Report
|
|
60
58
|
where({ is_public: true, is_trash: false }).order_by({ created_at: :desc })
|
61
59
|
}
|
62
60
|
|
61
|
+
has_many :newsitems
|
62
|
+
|
63
63
|
def self.list conditions = { :is_trash => false }
|
64
64
|
out = self.where( conditions ).order_by( :name => :asc ).limit( 100 )
|
65
65
|
[['', nil]] + out.map { |item| [ item.name, item.id ] }
|
@@ -97,7 +97,7 @@ class Report
|
|
97
97
|
if !doc.venue_ids.blank?
|
98
98
|
( doc.venue_ids || [] ).each do |venue_id|
|
99
99
|
v = Venue.find venue_id
|
100
|
-
u = User.find doc.user_id
|
100
|
+
u = ::IshModels::User.find doc.user_id
|
101
101
|
n = Newsitem.new
|
102
102
|
n.username = u.username unless u.blank?
|
103
103
|
n.report = doc
|
data/lib/site.rb
CHANGED
@@ -34,9 +34,9 @@ class Site
|
|
34
34
|
has_many :galleries
|
35
35
|
has_many :tags
|
36
36
|
has_many :videos
|
37
|
+
has_many :newsitems
|
37
38
|
|
38
39
|
embeds_many :features
|
39
|
-
embeds_many :newsitems
|
40
40
|
|
41
41
|
default_scope ->{ where({ :is_trash => false }).order_by({ :domain => :asc, :lang => :asc }) }
|
42
42
|
|
@@ -78,5 +78,9 @@ class Site
|
|
78
78
|
def its_locales
|
79
79
|
Site.where( :domain => self.domain ).map { |s| s.lang.to_sym }
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
|
+
def self.Tgm
|
83
|
+
Site.find_by( :domain => 'travel-guide.mobi', :lang => :en )
|
84
|
+
end
|
85
|
+
|
82
86
|
end
|
data/lib/video.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
1
|
class Video
|
3
|
-
|
4
2
|
include Mongoid::Document
|
5
3
|
include Mongoid::Timestamps
|
6
4
|
|
@@ -32,7 +30,6 @@ class Video
|
|
32
30
|
|
33
31
|
accepts_nested_attributes_for :site, :tag, :city
|
34
32
|
|
35
|
-
|
36
33
|
def self.list
|
37
34
|
[['', nil]] + Video.all.order_by( :name => :desc ).map { |item| [ item.name, item.id ] }
|
38
35
|
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.
|
4
|
+
version: 0.0.29.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
@@ -38,6 +38,9 @@ extra_rdoc_files: []
|
|
38
38
|
files:
|
39
39
|
- lib/app_model2.rb
|
40
40
|
- lib/aux_model.rb
|
41
|
+
- lib/cache_key.rb~
|
42
|
+
- lib/cities_user.rb
|
43
|
+
- lib/cities_user.rb~
|
41
44
|
- lib/city.rb
|
42
45
|
- lib/country.rb
|
43
46
|
- lib/event.rb
|
@@ -45,6 +48,16 @@ files:
|
|
45
48
|
- lib/gallery.rb
|
46
49
|
- lib/ish_models.rb
|
47
50
|
- lib/ish_models.rb~
|
51
|
+
- lib/ish_models/cache_key.rb
|
52
|
+
- lib/ish_models/cache_key.rb~
|
53
|
+
- lib/ish_models/configuration.rb
|
54
|
+
- lib/ish_models/configuration.rb~
|
55
|
+
- lib/ish_models/profile.rb
|
56
|
+
- lib/ish_models/profile.rb~
|
57
|
+
- lib/ish_models/railtie.rb
|
58
|
+
- lib/ish_models/railtie.rb~
|
59
|
+
- lib/ish_models/user.rb
|
60
|
+
- lib/ish_models/user.rb~
|
48
61
|
- lib/newsitem.rb
|
49
62
|
- lib/photo.rb
|
50
63
|
- lib/public_item.rb
|