ish_lib_engine 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/ish_lib_engine/application.js +13 -0
- data/app/assets/javascripts/ish_lib_engine/articles.js +2 -0
- data/app/assets/stylesheets/ish_lib_engine/application.css +15 -0
- data/app/assets/stylesheets/ish_lib_engine/articles.css +4 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/ish_lib_engine/application_controller.rb +4 -0
- data/app/controllers/ish_lib_engine/articles_controller.rb +62 -0
- data/app/controllers/ish_lib_engine/manager/cities_controller.rb +95 -0
- data/app/controllers/ish_lib_engine/manager/cities_controller.rb~ +95 -0
- data/app/controllers/ish_lib_engine/manager/features_controller.rb +122 -0
- data/app/controllers/ish_lib_engine/manager/features_controller.rb~ +122 -0
- data/app/controllers/ish_lib_engine/manager/galleries_controller.rb +78 -0
- data/app/controllers/ish_lib_engine/manager/galleries_controller.rb~ +78 -0
- data/app/controllers/ish_lib_engine/manager/manager_controller.rb +31 -0
- data/app/controllers/ish_lib_engine/manager/manager_controller.rb~ +31 -0
- data/app/controllers/ish_lib_engine/manager/newsitems_controller.rb +47 -0
- data/app/controllers/ish_lib_engine/manager/newsitems_controller.rb~ +47 -0
- data/app/controllers/ish_lib_engine/manager/photos_controller.rb +20 -0
- data/app/controllers/ish_lib_engine/manager/photos_controller.rb~ +20 -0
- data/app/controllers/ish_lib_engine/manager/reports_controller.rb +62 -0
- data/app/controllers/ish_lib_engine/manager/reports_controller.rb~ +62 -0
- data/app/controllers/ish_lib_engine/manager/sites_controller.rb +72 -0
- data/app/controllers/ish_lib_engine/manager/sites_controller.rb~ +72 -0
- data/app/controllers/ish_lib_engine/manager/tags_controller.rb +54 -0
- data/app/controllers/ish_lib_engine/manager/tags_controller.rb~ +54 -0
- data/app/controllers/ish_lib_engine/manager/users_controller.rb +13 -0
- data/app/controllers/ish_lib_engine/manager/users_controller.rb~ +13 -0
- data/app/controllers/ish_lib_engine/manager/welcome_controller.rb +8 -0
- data/app/controllers/ish_lib_engine/manager/welcome_controller.rb~ +9 -0
- data/app/helpers/ish_lib_engine/application_helper.rb +4 -0
- data/app/helpers/ish_lib_engine/articles_helper.rb +4 -0
- data/app/models/ability.rb +152 -0
- data/app/models/ability.rb~ +151 -0
- data/app/models/admin_user.rb +113 -0
- data/app/models/app_model2.rb +33 -0
- data/app/models/auth_token.rb +17 -0
- data/app/models/aux_model.rb +22 -0
- data/app/models/cities_user.rb +17 -0
- data/app/models/city.rb +117 -0
- data/app/models/country.rb +13 -0
- data/app/models/day.rb +21 -0
- data/app/models/decoded_auth_token.rb +6 -0
- data/app/models/event.rb +21 -0
- data/app/models/feature.rb +38 -0
- data/app/models/gallery.rb +59 -0
- data/app/models/ish_lib_engine/article.rb +4 -0
- data/app/models/ish_lib_engine/comment.rb +4 -0
- data/app/models/manager.rb +10 -0
- data/app/models/manager_city.rb +4 -0
- data/app/models/manager_feature.rb +4 -0
- data/app/models/manager_gallery.rb +3 -0
- data/app/models/manager_newsitem.rb +5 -0
- data/app/models/manager_photo.rb +3 -0
- data/app/models/manager_report.rb +4 -0
- data/app/models/manager_site.rb +4 -0
- data/app/models/manager_tag.rb +6 -0
- data/app/models/manager_user.rb +3 -0
- data/app/models/manager_venue.rb +4 -0
- data/app/models/message.rb +14 -0
- data/app/models/newsitem.rb +50 -0
- data/app/models/nodeitem.rb +18 -0
- data/app/models/photo.rb +68 -0
- data/app/models/rate_me.rb +13 -0
- data/app/models/report.rb +144 -0
- data/app/models/review.rb +4 -0
- data/app/models/site.rb +83 -0
- data/app/models/tag.rb +78 -0
- data/app/models/user.rb +122 -0
- data/app/models/user_profile.rb +20 -0
- data/app/models/venue.rb +69 -0
- data/app/models/video.rb +48 -0
- data/app/models/welcome.rb +6 -0
- data/app/models/wikitravel_page.rb +19 -0
- data/app/views/application/_flash_messages.haml +24 -0
- data/app/views/application/_flash_messages.haml~ +24 -0
- data/app/views/ish_lib_engine/articles/_form.html.erb +25 -0
- data/app/views/ish_lib_engine/articles/edit.html.erb +6 -0
- data/app/views/ish_lib_engine/articles/index.html.erb +29 -0
- data/app/views/ish_lib_engine/articles/new.html.erb +5 -0
- data/app/views/ish_lib_engine/articles/show.html.erb +14 -0
- data/app/views/layouts/ish_lib_engine/application.html.erb +14 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20160501041837_create_ish_lib_engine_articles.rb +10 -0
- data/db/migrate/20160501041940_create_ish_lib_engine_comments.rb +10 -0
- data/lib/addressbookitems_tasks.rb +33 -0
- data/lib/cities_tasks.rb +143 -0
- data/lib/core_extensions.rb +21 -0
- data/lib/features_tasks.rb +17 -0
- data/lib/float.rb +14 -0
- data/lib/galleries_tasks.rb +91 -0
- data/lib/ish_lib_engine.rb +4 -0
- data/lib/ish_lib_engine/engine.rb +5 -0
- data/lib/ish_lib_engine/version.rb +3 -0
- data/lib/reports_tasks.rb +53 -0
- data/lib/sitemaps_tasks.rb +108 -0
- data/lib/sites_tasks.rb +31 -0
- data/lib/string.rb +15 -0
- data/lib/tags_tasks.rb +104 -0
- data/lib/tasks/cities.rake +29 -0
- data/lib/tasks/galleries.rake +19 -0
- data/lib/tasks/ish_lib_engine_tasks.rake +4 -0
- data/lib/tasks/reports.rake +37 -0
- data/lib/tasks/resque.rake +8 -0
- data/lib/tasks/sitemaps.rake +12 -0
- data/lib/tasks/sites.rake +12 -0
- data/lib/tasks/tags.rake +17 -0
- data/lib/tasks/users.rake +14 -0
- data/lib/tasks/venues.rake +13 -0
- data/lib/tasks/videos.rake +18 -0
- data/lib/tasks/wikitravel_pages.rake +40 -0
- data/lib/test_extensions.rb +9 -0
- data/lib/u.rb +34 -0
- data/lib/users_tasks.rb +88 -0
- data/lib/venues_tasks.rb +15 -0
- data/lib/videos_tasks.rb +71 -0
- data/lib/wikitravel_tasks.rb +139 -0
- data/spec/factories/cities.rb +89 -0
- data/spec/factories/galleries.rb +133 -0
- data/spec/factories/photo.rb +20 -0
- data/spec/factories/reports.rb +379 -0
- data/spec/factories/site.rb +26 -0
- data/spec/factories/tag.rb +42 -0
- data/spec/factories/user.rb +87 -0
- data/spec/factories/user_profiles.rb +33 -0
- data/spec/factories/venues.rb +25 -0
- data/spec/factories/videos.rb +38 -0
- data/test/controllers/ish_lib_engine/articles_controller_test.rb +52 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +30 -0
- data/test/dummy/log/development.log +15 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/fixtures/ish_lib_engine/articles.yml +9 -0
- data/test/fixtures/ish_lib_engine/comments.yml +9 -0
- data/test/integration/navigation_test.rb +8 -0
- data/test/ish_lib_engine_test.rb +7 -0
- data/test/models/ish_lib_engine/article_test.rb +9 -0
- data/test/models/ish_lib_engine/comment_test.rb +9 -0
- data/test/test_helper.rb +21 -0
- metadata +361 -0
@@ -0,0 +1,152 @@
|
|
1
|
+
class Ability
|
2
|
+
|
3
|
+
include CanCan::Ability
|
4
|
+
def initialize(user)
|
5
|
+
|
6
|
+
#
|
7
|
+
# signed in user
|
8
|
+
#
|
9
|
+
unless user.blank?
|
10
|
+
|
11
|
+
can [ :create, :new ], Gallery
|
12
|
+
can [ :edit, :update, :destroy_photo, :show, :show_long ], Gallery do |g|
|
13
|
+
g.user == user
|
14
|
+
end
|
15
|
+
|
16
|
+
can [ :new ], Message
|
17
|
+
|
18
|
+
can [ :upload, :driver, :set_profile_photo, :new_profile_photo ], Photo
|
19
|
+
can [ :move, :edit, :update, :show ], Photo do |photo|
|
20
|
+
photo.user == user
|
21
|
+
end
|
22
|
+
can [ :show ], Photo do |photo|
|
23
|
+
photo.viewer_ids.include? user.id || user == photo.user
|
24
|
+
end
|
25
|
+
can [ :destroy ], Photo do |photo|
|
26
|
+
if photo.user == user
|
27
|
+
if photo.gallery.blank?
|
28
|
+
true
|
29
|
+
elsif photo.gallery.is_anonymous
|
30
|
+
false
|
31
|
+
else
|
32
|
+
true
|
33
|
+
end
|
34
|
+
else
|
35
|
+
false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
can [ :new, :create, :search, :index, :my_index ], Report
|
40
|
+
can [ :edit, :update, :show, :delete ], Report do |r|
|
41
|
+
r.user == user
|
42
|
+
end
|
43
|
+
|
44
|
+
can [ :newsitems_new, :newsitems_create ], Site
|
45
|
+
|
46
|
+
can [ :organizer, :photos, :new_profile, :create_profile, :edit_profile, :update_profile ], User
|
47
|
+
can [ :edit, :update, :update_profile ], User do |uu|
|
48
|
+
uu == user
|
49
|
+
end
|
50
|
+
|
51
|
+
can [ :new ], Venue
|
52
|
+
|
53
|
+
can [ :new, :create ], Video
|
54
|
+
|
55
|
+
# manager, group_id 1
|
56
|
+
#
|
57
|
+
if user[:group_id] <= 2
|
58
|
+
can [ :manage ], CitiesUser
|
59
|
+
can [ :manage ], City
|
60
|
+
can [ :manage ], Country
|
61
|
+
can [ :manage ], Day
|
62
|
+
can [ :manage ], Event
|
63
|
+
can [ :manage ], Feature
|
64
|
+
can [ :manage ], Gallery
|
65
|
+
can [ :manage ], Newsitem
|
66
|
+
can [ :manage ], Nodeitem
|
67
|
+
can [ :manage ], Photo
|
68
|
+
can [ :manage ], Report
|
69
|
+
can [ :manage ], Site
|
70
|
+
can [ :manage ], Tag
|
71
|
+
can [ :manage ], User
|
72
|
+
can [ :manage ], UserProfile
|
73
|
+
can [ :manage ], Venue
|
74
|
+
can [ :manage ], Video
|
75
|
+
can [ :manage ], Welcome
|
76
|
+
can [ :manage ], Manager
|
77
|
+
can [ :manage ], ManagerCity
|
78
|
+
can [ :manage ], ManagerFeature
|
79
|
+
can [ :manage ], ManagerGallery
|
80
|
+
can [ :manage ], ManagerNewsitem
|
81
|
+
can [ :manage ], ManagerPhoto
|
82
|
+
can [ :manage ], ManagerReport
|
83
|
+
can [ :manage ], ManagerSite
|
84
|
+
can [ :manage ], ManagerTag
|
85
|
+
can [ :manage ], ManagerUser
|
86
|
+
can [ :manage ], ManagerVenue
|
87
|
+
end
|
88
|
+
|
89
|
+
#
|
90
|
+
# if admin
|
91
|
+
#
|
92
|
+
can :manage, :all do
|
93
|
+
user.group_id.to_s == "1"
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
user ||= User.new
|
98
|
+
|
99
|
+
###
|
100
|
+
### applies to all users
|
101
|
+
###
|
102
|
+
|
103
|
+
can [ :index, :show ], City
|
104
|
+
|
105
|
+
can [ :render_partial ], AuxModel
|
106
|
+
|
107
|
+
can [ :new ], Event
|
108
|
+
|
109
|
+
can [ :index, :search, :not_found, :set_show_style, :new ], Gallery
|
110
|
+
can [ :show ], Gallery do |g|
|
111
|
+
g.is_public && !g.is_trash
|
112
|
+
end
|
113
|
+
|
114
|
+
can [ :error500, :search ], Manager
|
115
|
+
|
116
|
+
# has to be outside user auth b/c the uploading component is ajax.
|
117
|
+
can [ :new, :create, :index, :do_upload, :not_found ], Photo
|
118
|
+
can [ :show ], Photo do |photo|
|
119
|
+
photo.is_public && !photo.is_trash
|
120
|
+
end
|
121
|
+
|
122
|
+
can [ :search, :not_found, :new, :index ], Report
|
123
|
+
can [ :show ], Report do |r|
|
124
|
+
r.is_public && !r.is_trash
|
125
|
+
end
|
126
|
+
|
127
|
+
can [ :new ], Review
|
128
|
+
|
129
|
+
can [ :show, :newsitems, :features, :newsitems, :create_missing, :register ], Site do |s|
|
130
|
+
!s.is_private
|
131
|
+
end
|
132
|
+
|
133
|
+
can [ :index ], Tag
|
134
|
+
can [ :show ], Tag do |t|
|
135
|
+
true
|
136
|
+
end
|
137
|
+
|
138
|
+
can [ :resume, :reports, :galleries, :report, :gallery,
|
139
|
+
:sign_in, :sign_up, :sign_out, :logout,
|
140
|
+
:index, :show, :not_found, :github, :about ], User
|
141
|
+
can [ :report ], User do |r|
|
142
|
+
r.is_public && !r.is_trash
|
143
|
+
end
|
144
|
+
|
145
|
+
can [ :new, :index, :show, :not_found ], Venue
|
146
|
+
|
147
|
+
can [ :index, :show, :view ], Video
|
148
|
+
|
149
|
+
can [ :home ], Welcome
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
@@ -0,0 +1,151 @@
|
|
1
|
+
class Ability
|
2
|
+
|
3
|
+
include CanCan::Ability
|
4
|
+
def initialize(user)
|
5
|
+
|
6
|
+
#
|
7
|
+
# signed in user
|
8
|
+
#
|
9
|
+
unless user.blank?
|
10
|
+
|
11
|
+
can [ :create, :new ], Gallery
|
12
|
+
can [ :edit, :update, :destroy_photo, :show, :show_long ], Gallery do |g|
|
13
|
+
g.user == user
|
14
|
+
end
|
15
|
+
|
16
|
+
can [ :new ], Message
|
17
|
+
|
18
|
+
can [ :upload, :driver, :set_profile_photo, :new_profile_photo ], Photo
|
19
|
+
can [ :move, :edit, :update, :show ], Photo do |photo|
|
20
|
+
photo.user == user
|
21
|
+
end
|
22
|
+
can [ :show ], Photo do |photo|
|
23
|
+
photo.viewer_ids.include? user.id || user == photo.user
|
24
|
+
end
|
25
|
+
can [ :destroy ], Photo do |photo|
|
26
|
+
if photo.user == user
|
27
|
+
if photo.gallery.blank?
|
28
|
+
true
|
29
|
+
elsif photo.gallery.is_anonymous
|
30
|
+
false
|
31
|
+
else
|
32
|
+
true
|
33
|
+
end
|
34
|
+
else
|
35
|
+
false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
can [ :new, :create, :search, :index, :my_index ], Report
|
40
|
+
can [ :edit, :update, :show, :delete ], Report do |r|
|
41
|
+
r.user == user
|
42
|
+
end
|
43
|
+
|
44
|
+
can [ :newsitems_new, :newsitems_create ], Site
|
45
|
+
|
46
|
+
can [ :organizer, :photos, :new_profile, :create_profile, :edit_profile, :update_profile ], User
|
47
|
+
can [ :edit, :update, :update_profile ], User do |uu|
|
48
|
+
uu == user
|
49
|
+
end
|
50
|
+
|
51
|
+
can [ :new ], Venue
|
52
|
+
|
53
|
+
can [ :new, :create ], Video
|
54
|
+
|
55
|
+
# manager, group_id 1
|
56
|
+
#
|
57
|
+
if user[:group_id] <= 2
|
58
|
+
can [ :manage ], CitiesUser
|
59
|
+
can [ :manage ], City
|
60
|
+
can [ :manage ], Country
|
61
|
+
can [ :manage ], Day
|
62
|
+
can [ :manage ], Event
|
63
|
+
can [ :manage ], Feature
|
64
|
+
can [ :manage ], Gallery
|
65
|
+
can [ :manage ], Newsitem
|
66
|
+
can [ :manage ], Nodeitem
|
67
|
+
can [ :manage ], Photo
|
68
|
+
can [ :manage ], Report
|
69
|
+
can [ :manage ], Site
|
70
|
+
can [ :manage ], Tag
|
71
|
+
can [ :manage ], User
|
72
|
+
can [ :manage ], UserProfile
|
73
|
+
can [ :manage ], Venue
|
74
|
+
can [ :manage ], Video
|
75
|
+
can [ :manage ], Welcome
|
76
|
+
can [ :manage ], Manager
|
77
|
+
can [ :manage ], ManagerCity
|
78
|
+
can [ :manage ], ManagerFeature
|
79
|
+
can [ :manage ], ManagerGallery
|
80
|
+
can [ :manage ], ManagerNewsitem
|
81
|
+
can [ :manage ], ManagerPhoto
|
82
|
+
can [ :manage ], ManagerReport
|
83
|
+
can [ :manage ], ManagerSite
|
84
|
+
can [ :manage ], ManagerTag
|
85
|
+
can [ :manage ], ManagerUser
|
86
|
+
can [ :manage ], ManagerVenue
|
87
|
+
end
|
88
|
+
|
89
|
+
#
|
90
|
+
# if admin
|
91
|
+
#
|
92
|
+
can :manage, :all do
|
93
|
+
user.group_id.to_s == "1"
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
user ||= User.new
|
98
|
+
|
99
|
+
###
|
100
|
+
### applies to all users
|
101
|
+
###
|
102
|
+
|
103
|
+
can [ :index, :show ], City
|
104
|
+
|
105
|
+
can [ :render_partial ], AuxModel
|
106
|
+
|
107
|
+
can [ :new ], Event
|
108
|
+
|
109
|
+
can [ :index, :search, :not_found, :set_show_style, :new ], Gallery
|
110
|
+
can [ :show ], Gallery do |g|
|
111
|
+
g.is_public && !g.is_trash
|
112
|
+
end
|
113
|
+
|
114
|
+
can [ :error500, :search ], Manager
|
115
|
+
|
116
|
+
# has to be outside user auth b/c the uploading component is ajax.
|
117
|
+
can [ :new, :create, :index, :do_upload, :not_found ], Photo
|
118
|
+
can [ :show ], Photo do |photo|
|
119
|
+
photo.is_public && !photo.is_trash
|
120
|
+
end
|
121
|
+
|
122
|
+
can [ :search, :not_found, :new, :index ], Report
|
123
|
+
can [ :show ], Report do |r|
|
124
|
+
r.is_public && !r.is_trash
|
125
|
+
end
|
126
|
+
|
127
|
+
can [ :new ], Review
|
128
|
+
|
129
|
+
can [ :show, :newsitems, :features, :newsitems, :create_missing, :register ], Site do |s|
|
130
|
+
!s.is_private
|
131
|
+
end
|
132
|
+
|
133
|
+
can [ :index ], Tag
|
134
|
+
can [ :show ], Tag do |t|
|
135
|
+
true
|
136
|
+
end
|
137
|
+
|
138
|
+
can [ :resume, :reports, :galleries, :report, :gallery,
|
139
|
+
:sign_in, :sign_up, :sign_out, :logout,
|
140
|
+
:index, :show, :not_found, :github, :about ], User
|
141
|
+
can [ :report ], User do |r|
|
142
|
+
r.is_public && !r.is_trash
|
143
|
+
end
|
144
|
+
|
145
|
+
can [ :new, :index, :show, :not_found ], Venue
|
146
|
+
|
147
|
+
can [ :index, :show, :view ], Video
|
148
|
+
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
@@ -0,0 +1,113 @@
|
|
1
|
+
|
2
|
+
class AdminUser
|
3
|
+
|
4
|
+
include Mongoid::Document
|
5
|
+
# Include default devise modules. Others available are:
|
6
|
+
# :token_authenticatable, :confirmable,
|
7
|
+
# :lockable, :timeoutable and :omniauthable
|
8
|
+
devise :database_authenticatable,
|
9
|
+
:recoverable, :rememberable, :trackable, :validatable
|
10
|
+
|
11
|
+
# Include default devise modules. Others available are:
|
12
|
+
# :token_authenticatable, :confirmable,
|
13
|
+
# :lockable, :timeoutable and :omniauthable
|
14
|
+
devise :database_authenticatable,
|
15
|
+
:recoverable, :rememberable, :trackable, :validatable
|
16
|
+
|
17
|
+
# Include default devise modules. Others available are:
|
18
|
+
# :token_authenticatable, :confirmable,
|
19
|
+
# :lockable, :timeoutable and :omniauthable
|
20
|
+
devise :database_authenticatable,
|
21
|
+
:recoverable, :rememberable, :trackable, :validatable
|
22
|
+
|
23
|
+
# Include default devise modules. Others available are:
|
24
|
+
# :token_authenticatable, :confirmable,
|
25
|
+
# :lockable, :timeoutable and :omniauthable
|
26
|
+
devise :database_authenticatable,
|
27
|
+
:recoverable, :rememberable, :trackable, :validatable
|
28
|
+
|
29
|
+
## Database authenticatable
|
30
|
+
field :email, :type => String, :default => ""
|
31
|
+
field :encrypted_password, :type => String, :default => ""
|
32
|
+
|
33
|
+
## Recoverable
|
34
|
+
field :reset_password_token, :type => String
|
35
|
+
field :reset_password_sent_at, :type => Time
|
36
|
+
|
37
|
+
## Rememberable
|
38
|
+
field :remember_created_at, :type => Time
|
39
|
+
|
40
|
+
## Trackable
|
41
|
+
field :sign_in_count, :type => Integer, :default => 0
|
42
|
+
field :current_sign_in_at, :type => Time
|
43
|
+
field :last_sign_in_at, :type => Time
|
44
|
+
field :current_sign_in_ip, :type => String
|
45
|
+
field :last_sign_in_ip, :type => String
|
46
|
+
|
47
|
+
## Confirmable
|
48
|
+
# field :confirmation_token, :type => String
|
49
|
+
# field :confirmed_at, :type => Time
|
50
|
+
# field :confirmation_sent_at, :type => Time
|
51
|
+
# field :unconfirmed_email, :type => String # Only if using reconfirmable
|
52
|
+
|
53
|
+
## Lockable
|
54
|
+
# field :failed_attempts, :type => Integer, :default => 0 # Only if lock strategy is :failed_attempts
|
55
|
+
# field :unlock_token, :type => String # Only if unlock strategy is :email or :both
|
56
|
+
# field :locked_at, :type => Time
|
57
|
+
|
58
|
+
## Token authenticatable
|
59
|
+
# field :authentication_token, :type => String
|
60
|
+
|
61
|
+
# Include default devise modules. Others available are:
|
62
|
+
# :token_authenticatable, :confirmable,
|
63
|
+
# :lockable, :timeoutable and :omniauthable
|
64
|
+
devise :database_authenticatable,
|
65
|
+
:recoverable, :rememberable, :trackable, :validatable
|
66
|
+
|
67
|
+
# Include default devise modules. Others available are:
|
68
|
+
# :token_authenticatable, :confirmable,
|
69
|
+
# :lockable, :timeoutable and :omniauthable
|
70
|
+
devise :database_authenticatable,
|
71
|
+
:recoverable, :rememberable, :trackable, :validatable
|
72
|
+
|
73
|
+
# Include default devise modules. Others available are:
|
74
|
+
# :token_authenticatable, :confirmable,
|
75
|
+
# :lockable, :timeoutable and :omniauthable
|
76
|
+
devise :database_authenticatable,
|
77
|
+
:recoverable, :rememberable, :trackable, :validatable
|
78
|
+
|
79
|
+
## Database authenticatable
|
80
|
+
field :email, :type => String, :default => ""
|
81
|
+
field :encrypted_password, :type => String, :default => ""
|
82
|
+
|
83
|
+
validates_presence_of :email
|
84
|
+
validates_presence_of :encrypted_password
|
85
|
+
|
86
|
+
## Recoverable
|
87
|
+
field :reset_password_token, :type => String
|
88
|
+
field :reset_password_sent_at, :type => Time
|
89
|
+
|
90
|
+
## Rememberable
|
91
|
+
field :remember_created_at, :type => Time
|
92
|
+
|
93
|
+
## Trackable
|
94
|
+
field :sign_in_count, :type => Integer, :default => 0
|
95
|
+
field :current_sign_in_at, :type => Time
|
96
|
+
field :last_sign_in_at, :type => Time
|
97
|
+
field :current_sign_in_ip, :type => String
|
98
|
+
field :last_sign_in_ip, :type => String
|
99
|
+
|
100
|
+
## Confirmable
|
101
|
+
# field :confirmation_token, :type => String
|
102
|
+
# field :confirmed_at, :type => Time
|
103
|
+
# field :confirmation_sent_at, :type => Time
|
104
|
+
# field :unconfirmed_email, :type => String # Only if using reconfirmable
|
105
|
+
|
106
|
+
## Lockable
|
107
|
+
# field :failed_attempts, :type => Integer, :default => 0 # Only if lock strategy is :failed_attempts
|
108
|
+
# field :unlock_token, :type => String # Only if unlock strategy is :email or :both
|
109
|
+
# field :locked_at, :type => Time
|
110
|
+
|
111
|
+
## Token authenticatable
|
112
|
+
# field :authentication_token, :type => String
|
113
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class AppModel2
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::Timestamps
|
4
|
+
|
5
|
+
field :is_feature, :type => Boolean, :default => false
|
6
|
+
field :is_public, :type => Boolean, :default => true
|
7
|
+
field :is_done, :type => Boolean, :default => false
|
8
|
+
field :is_trash, :type => Boolean, :default => false
|
9
|
+
field :is_anonymous, :type => Boolean, :default => false
|
10
|
+
|
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 }) }
|
15
|
+
|
16
|
+
default_scope ->{ where({ :is_public => true, :is_trash => false }).order_by({ :created_at => :desc }) }
|
17
|
+
|
18
|
+
field :x, :type => Float
|
19
|
+
field :y, :type => Float
|
20
|
+
|
21
|
+
def self.list conditions = { :is_trash => false }
|
22
|
+
out = self.where( conditions).order_by( :name => :asc )
|
23
|
+
[['', nil]] + out.map { |item| [ item.name, item.id ] }
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def puts! arg, label=""
|
29
|
+
puts "+++ +++ #{label}"
|
30
|
+
puts arg.inspect
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|