ish_lib 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -3
- data/Gemfile.lock +5 -3
- data/Rakefile +3 -0
- data/VERSION +1 -1
- data/ish_lib.gemspec +50 -7
- data/lib/app/models/ability.rb +151 -0
- data/lib/app/models/admin_user.rb +113 -0
- data/lib/app/models/app_model2.rb +33 -0
- data/lib/app/models/auth_token.rb +17 -0
- data/lib/app/models/aux_model.rb +22 -0
- data/lib/app/models/cities_user.rb +17 -0
- data/lib/app/models/city.rb +117 -0
- data/lib/app/models/country.rb +13 -0
- data/lib/app/models/day.rb +21 -0
- data/lib/app/models/decoded_auth_token.rb +6 -0
- data/lib/app/models/event.rb +21 -0
- data/lib/app/models/feature.rb +38 -0
- data/lib/app/models/gallery.rb +57 -0
- data/lib/app/models/manager.rb +10 -0
- data/lib/app/models/manager_city.rb +4 -0
- data/lib/app/models/manager_feature.rb +4 -0
- data/lib/app/models/manager_gallery.rb +3 -0
- data/lib/app/models/manager_newsitem.rb +5 -0
- data/lib/app/models/manager_photo.rb +3 -0
- data/lib/app/models/manager_report.rb +4 -0
- data/lib/app/models/manager_site.rb +4 -0
- data/lib/app/models/manager_tag.rb +6 -0
- data/lib/app/models/manager_user.rb +3 -0
- data/lib/app/models/manager_venue.rb +4 -0
- data/lib/app/models/message.rb +14 -0
- data/lib/app/models/newsitem.rb +50 -0
- data/lib/app/models/nodeitem.rb +18 -0
- data/lib/app/models/photo.rb +68 -0
- data/lib/app/models/rate_me.rb +13 -0
- data/lib/app/models/report.rb +144 -0
- data/lib/app/models/review.rb +4 -0
- data/lib/app/models/site.rb +85 -0
- data/lib/app/models/tag.rb +78 -0
- data/lib/app/models/user.rb +122 -0
- data/lib/app/models/user_profile.rb +20 -0
- data/lib/app/models/venue.rb +69 -0
- data/lib/app/models/video.rb +48 -0
- data/lib/app/models/welcome.rb +6 -0
- data/lib/app/models/wikitravel_page.rb +19 -0
- data/lib/ish_lib.rb +19 -0
- data/lib/string.rb +15 -0
- metadata +59 -5
@@ -0,0 +1,78 @@
|
|
1
|
+
|
2
|
+
class Tag
|
3
|
+
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Timestamps
|
6
|
+
|
7
|
+
field :name, :type => String
|
8
|
+
validates :name, :uniqueness => true, :allow_nil => false
|
9
|
+
|
10
|
+
field :name_seo, :type => String
|
11
|
+
validates :name_seo, :uniqueness => true, :allow_nil => false
|
12
|
+
|
13
|
+
field :descr, :type => String, :default => ''
|
14
|
+
|
15
|
+
field :is_public, :type => Boolean, :default => true
|
16
|
+
field :is_trash, :type => Boolean, :default => false
|
17
|
+
field :is_feature, :type => Boolean, :default => false
|
18
|
+
|
19
|
+
field :weight, :type => Integer, :default => 10
|
20
|
+
|
21
|
+
has_many :reports
|
22
|
+
has_many :galleries
|
23
|
+
has_many :videos
|
24
|
+
|
25
|
+
has_many :children_tags, :class_name => 'Tag', :inverse_of => :parent_tag
|
26
|
+
belongs_to :parent_tag, :class_name => 'Tag', :inverse_of => :children_tags
|
27
|
+
|
28
|
+
embeds_many :features
|
29
|
+
embeds_many :newsitems
|
30
|
+
|
31
|
+
belongs_to :site
|
32
|
+
validates :site, :presence => true
|
33
|
+
|
34
|
+
default_scope ->{
|
35
|
+
where({ :is_public => true, :is_trash => false }).order_by({ :name => :asc })
|
36
|
+
}
|
37
|
+
|
38
|
+
before_create do |d|
|
39
|
+
if d.name_seo.blank?
|
40
|
+
d.name_seo = d.name.to_simple_string
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.clear
|
45
|
+
if Rails.env.test?
|
46
|
+
Tag.each { |r| r.remove }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.no_parent
|
51
|
+
Tag.where( :parent_tag_id => nil )
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.list
|
55
|
+
out = Tag.all.order_by( :name => :desc )
|
56
|
+
[['', nil]] + out.map { |item| [ item.name, item.id ] }
|
57
|
+
end
|
58
|
+
|
59
|
+
# @deprecated, there will be no reports or galleries in tags. There will be only features and newsitems
|
60
|
+
def self.n_items
|
61
|
+
10
|
62
|
+
end
|
63
|
+
def self.n_reports
|
64
|
+
4
|
65
|
+
end
|
66
|
+
def self.n_galleries
|
67
|
+
4
|
68
|
+
end
|
69
|
+
def self.n_videos
|
70
|
+
4
|
71
|
+
end
|
72
|
+
|
73
|
+
# @deprecated I don't even know why I have this. Should be simplified into non-being.
|
74
|
+
def self.n_features
|
75
|
+
4
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
|
2
|
+
class 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
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
class UserProfile
|
3
|
+
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Timestamps
|
6
|
+
|
7
|
+
field :about, :type => String
|
8
|
+
field :education, :type => String
|
9
|
+
field :objectives, :type => String
|
10
|
+
field :current_employment, :type => String
|
11
|
+
field :past_employment, :type => String
|
12
|
+
|
13
|
+
field :pdf_resume_path, :type => String
|
14
|
+
field :doc_resume_path, :type => String
|
15
|
+
|
16
|
+
field :lang, :type => String
|
17
|
+
|
18
|
+
belongs_to :user
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
|
2
|
+
require 'string'
|
3
|
+
|
4
|
+
class Venue
|
5
|
+
|
6
|
+
include Mongoid::Document
|
7
|
+
include Mongoid::Timestamps
|
8
|
+
|
9
|
+
field :name, :type => String
|
10
|
+
validates :name, :uniqueness => true, :allow_nil => false
|
11
|
+
|
12
|
+
field :name_seo, :type => String
|
13
|
+
validates :name_seo, :uniqueness => true, :allow_nil => false
|
14
|
+
|
15
|
+
field :descr, :type => String
|
16
|
+
|
17
|
+
field :is_trash, :type => Boolean, :default => false
|
18
|
+
scope :fresh, ->{ where({ :is_trash => false }) }
|
19
|
+
scope :trash, ->{ where({ :is_trash => true }) }
|
20
|
+
|
21
|
+
field :is_public, :type => Boolean, :default => true
|
22
|
+
scope :public, ->{ where({ :is_public => true }) }
|
23
|
+
scope :not_public, ->{ where({ :is_public => false }) }
|
24
|
+
|
25
|
+
field :is_feature, :type => Boolean, :default => false
|
26
|
+
|
27
|
+
field :x, :type => Float
|
28
|
+
field :y, :type => Float
|
29
|
+
|
30
|
+
field :lang, :type => String, :default => 'en'
|
31
|
+
|
32
|
+
belongs_to :city
|
33
|
+
belongs_to :owner, :class_name => 'User', :inverse_of => :owned_venue
|
34
|
+
validates :city, :allow_nil => false, :presence => true
|
35
|
+
|
36
|
+
has_and_belongs_to_many :users
|
37
|
+
|
38
|
+
has_one :profile_photo, :class_name => 'Photo', :inverse_of => :profile_venue
|
39
|
+
|
40
|
+
has_many :reports
|
41
|
+
has_many :galleries
|
42
|
+
has_many :photos
|
43
|
+
|
44
|
+
embeds_many :newsitems
|
45
|
+
embeds_many :features
|
46
|
+
|
47
|
+
def self.list conditions = { :is_trash => false }
|
48
|
+
out = self.where( conditions).order_by( :name => :asc )
|
49
|
+
[['', nil]] + out.map { |item| [ item.name, item.id ] }
|
50
|
+
end
|
51
|
+
|
52
|
+
set_callback(:create, :before) do |doc|
|
53
|
+
doc.name_seo = doc.name.to_simple_string
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.types
|
57
|
+
return []
|
58
|
+
# if 'en' == @locale
|
59
|
+
# [ 'Hotels', 'Restaurants', 'Bars' ]
|
60
|
+
# else
|
61
|
+
# [ 'Hotels', 'Restaurants', 'Bars' ]
|
62
|
+
# end
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.n_features
|
66
|
+
6
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
|
2
|
+
class Video
|
3
|
+
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Timestamps
|
6
|
+
|
7
|
+
PER_PAGE = 6
|
8
|
+
|
9
|
+
field :name, :type => String
|
10
|
+
field :descr, :type => String
|
11
|
+
|
12
|
+
default_scope ->{ where({ :is_public => true, :is_trash => false }).order_by({ :created_at => :desc }) }
|
13
|
+
|
14
|
+
field :is_trash, :type => Boolean, :default => false
|
15
|
+
field :is_public, :type => Boolean, :default => true
|
16
|
+
field :is_feature, :type => Boolean, :default => false
|
17
|
+
|
18
|
+
field :x, :type => Float
|
19
|
+
field :y, :type => Float
|
20
|
+
|
21
|
+
field :lang, :type => String, :default => 'en'
|
22
|
+
|
23
|
+
field :youtube_id, :type => String
|
24
|
+
validates :youtube_id, :uniqueness => true, :presence => true
|
25
|
+
|
26
|
+
belongs_to :tag
|
27
|
+
belongs_to :city
|
28
|
+
belongs_to :site
|
29
|
+
validates :site, :presence => true
|
30
|
+
belongs_to :user
|
31
|
+
validates :user, :presence => true
|
32
|
+
|
33
|
+
accepts_nested_attributes_for :site, :tag, :city
|
34
|
+
|
35
|
+
|
36
|
+
def self.list
|
37
|
+
[['', nil]] + Video.all.order_by( :name => :desc ).map { |item| [ item.name, item.id ] }
|
38
|
+
end
|
39
|
+
|
40
|
+
set_callback( :create, :before ) do |doc|
|
41
|
+
if doc.is_public
|
42
|
+
doc.city.add_newsitem( doc ) unless doc.city.blank?
|
43
|
+
doc.site.add_newsitem( doc ) unless doc.site.blank?
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class WikitravelPage
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::Timestamps
|
4
|
+
|
5
|
+
field :title, :type => String
|
6
|
+
validates :title, :presence => true, :uniqueness => true
|
7
|
+
|
8
|
+
field :url, :type => String
|
9
|
+
validates :url, :presence => true, :uniqueness => true
|
10
|
+
|
11
|
+
def self.clear
|
12
|
+
if Rails.env.test?
|
13
|
+
self.each { |r| r.remove }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
DOMAIN = 'http://wikitravel.org'
|
18
|
+
|
19
|
+
end
|
data/lib/ish_lib.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# microsites
|
4
|
+
#
|
5
|
+
require 'app/models/gallery'
|
6
|
+
require 'app/models/site'
|
7
|
+
require 'app/models/tag'
|
8
|
+
require 'app/models/user_profile'
|
9
|
+
require 'app/models/video'
|
10
|
+
|
11
|
+
#
|
12
|
+
# travel
|
13
|
+
#
|
14
|
+
require 'app/models/venue'
|
15
|
+
require 'app/models/review'
|
16
|
+
|
17
|
+
#
|
18
|
+
# manager
|
19
|
+
#
|
data/lib/string.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ish_lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Piousbox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shoulda
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
61
|
+
version: 2.1.1
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.
|
68
|
+
version: 2.1.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: simplecov
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: kaminari
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: models and assets for piousbox.com
|
84
98
|
email: piousbox@gmail.com
|
85
99
|
executables: []
|
@@ -96,7 +110,47 @@ files:
|
|
96
110
|
- Rakefile
|
97
111
|
- VERSION
|
98
112
|
- ish_lib.gemspec
|
113
|
+
- lib/app/models/ability.rb
|
114
|
+
- lib/app/models/admin_user.rb
|
115
|
+
- lib/app/models/app_model2.rb
|
116
|
+
- lib/app/models/auth_token.rb
|
117
|
+
- lib/app/models/aux_model.rb
|
118
|
+
- lib/app/models/cities_user.rb
|
119
|
+
- lib/app/models/city.rb
|
120
|
+
- lib/app/models/country.rb
|
121
|
+
- lib/app/models/day.rb
|
122
|
+
- lib/app/models/decoded_auth_token.rb
|
123
|
+
- lib/app/models/event.rb
|
124
|
+
- lib/app/models/feature.rb
|
125
|
+
- lib/app/models/gallery.rb
|
126
|
+
- lib/app/models/manager.rb
|
127
|
+
- lib/app/models/manager_city.rb
|
128
|
+
- lib/app/models/manager_feature.rb
|
129
|
+
- lib/app/models/manager_gallery.rb
|
130
|
+
- lib/app/models/manager_newsitem.rb
|
131
|
+
- lib/app/models/manager_photo.rb
|
132
|
+
- lib/app/models/manager_report.rb
|
133
|
+
- lib/app/models/manager_site.rb
|
134
|
+
- lib/app/models/manager_tag.rb
|
135
|
+
- lib/app/models/manager_user.rb
|
136
|
+
- lib/app/models/manager_venue.rb
|
137
|
+
- lib/app/models/message.rb
|
138
|
+
- lib/app/models/newsitem.rb
|
139
|
+
- lib/app/models/nodeitem.rb
|
140
|
+
- lib/app/models/photo.rb
|
141
|
+
- lib/app/models/rate_me.rb
|
142
|
+
- lib/app/models/report.rb
|
143
|
+
- lib/app/models/review.rb
|
144
|
+
- lib/app/models/site.rb
|
145
|
+
- lib/app/models/tag.rb
|
146
|
+
- lib/app/models/user.rb
|
147
|
+
- lib/app/models/user_profile.rb
|
148
|
+
- lib/app/models/venue.rb
|
149
|
+
- lib/app/models/video.rb
|
150
|
+
- lib/app/models/welcome.rb
|
151
|
+
- lib/app/models/wikitravel_page.rb
|
99
152
|
- lib/ish_lib.rb
|
153
|
+
- lib/string.rb
|
100
154
|
- test/helper.rb
|
101
155
|
- test/test_ish_lib.rb
|
102
156
|
homepage: http://github.com/piousbox/ish_lib
|
@@ -119,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
173
|
version: '0'
|
120
174
|
requirements: []
|
121
175
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.
|
176
|
+
rubygems_version: 2.5.1
|
123
177
|
signing_key:
|
124
178
|
specification_version: 4
|
125
179
|
summary: ish_lib, powering piousbox.com
|