raffle_v1 0.0.5 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (418) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/Rakefile +3 -9
  4. data/app/assets/javascripts/raffle_v1/application.js +6 -5
  5. data/app/assets/stylesheets/raffle_v1/application.css.scss +4 -31
  6. data/app/assets/stylesheets/raffle_v1/framework_and_overrides.css.scss +422 -0
  7. data/app/controllers/raffle_v1/admin/base_controller.rb +11 -0
  8. data/app/controllers/raffle_v1/admin/users_controller.rb +69 -0
  9. data/app/controllers/raffle_v1/application_controller.rb +51 -78
  10. data/app/controllers/raffle_v1/pages_controller.rb +11 -178
  11. data/app/helpers/raffle_v1/application_helper.rb +5 -0
  12. data/app/models/raffle_v1/user.rb +61 -107
  13. data/app/views/layouts/raffle_v1/application.html.erb +28 -5
  14. data/app/views/raffle_v1/admin/base/index.html.erb +39 -0
  15. data/app/views/raffle_v1/admin/users/edit.html.erb +65 -0
  16. data/app/views/raffle_v1/admin/users/index.html.erb +55 -0
  17. data/app/views/raffle_v1/devise/confirmations/new.html.erb +31 -0
  18. data/app/views/raffle_v1/devise/mailer/confirmation_instructions.html.erb +12 -0
  19. data/app/views/raffle_v1/devise/mailer/reset_password_instructions.html.erb +15 -0
  20. data/app/views/raffle_v1/devise/passwords/edit.html.erb +43 -0
  21. data/app/views/raffle_v1/devise/passwords/new.html.erb +31 -0
  22. data/app/views/raffle_v1/devise/registrations/edit.html.erb +63 -0
  23. data/app/views/raffle_v1/devise/registrations/new.html.erb +58 -0
  24. data/app/views/raffle_v1/devise/sessions/new.html.erb +45 -0
  25. data/app/views/raffle_v1/devise/shared/_links.erb +29 -0
  26. data/app/views/raffle_v1/layouts/_footer.html.erb +17 -0
  27. data/app/views/raffle_v1/layouts/_messages.html.erb +9 -0
  28. data/app/views/raffle_v1/layouts/_navigation.html.erb +18 -0
  29. data/app/views/raffle_v1/layouts/_navigation_links.html.erb +13 -0
  30. data/app/views/raffle_v1/layouts/application.html.erb +37 -0
  31. data/app/views/raffle_v1/pages/home.html.erb +3 -0
  32. data/app/views/raffle_v1/pages/inside.html.erb +3 -0
  33. data/config/add_files/date_format.rb +27 -0
  34. data/config/add_files/devise.rb +267 -0
  35. data/config/add_files/filter_parameter_logging.rb +4 -0
  36. data/config/add_files/friendly_id.rb +88 -0
  37. data/config/add_files/kaminari_config.rb +10 -0
  38. data/config/add_files/rafflev1.rb +4 -0
  39. data/config/initializers/rafflev1.rb +1 -6
  40. data/config/locales/devise.en.yml +59 -0
  41. data/config/routes.rb +30 -5
  42. data/db/migrate/20130123214645_devise_create_raffle_v1_users.rb +56 -0
  43. data/db/migrate/{20130123214645_devise_create_users.rb → 20130124004626_devise_create_raffle_v1_admins.rb} +7 -7
  44. data/db/migrate/{20130124231541_create_versions.rb → 20130124231541_create_raffle_v1_versions.rb} +5 -5
  45. data/db/migrate/20140719165853_create_raffle_v1_friendly_id_slugs.rb +15 -0
  46. data/db/seeds.rb +24 -77
  47. data/lib/generators/raffle_v1/install/install_generator.rb +142 -54
  48. data/lib/generators/raffle_v1/install/templates/assets/images/raffle_v1/game.png +0 -0
  49. data/lib/generators/raffle_v1/install/templates/assets/images/raffle_v1/gift.png +0 -0
  50. data/lib/generators/raffle_v1/install/templates/assets/images/raffle_v1/lifesaver.png +0 -0
  51. data/lib/generators/raffle_v1/install/templates/assets/images/raffle_v1/person01.jpg +0 -0
  52. data/lib/generators/raffle_v1/install/templates/assets/javascripts/raffle_v1/application.js +17 -0
  53. data/lib/generators/raffle_v1/install/templates/assets/stylesheets/raffle_v1/application.css.scss +7 -0
  54. data/lib/generators/raffle_v1/install/templates/assets/stylesheets/raffle_v1/framework_and_overrides.css.scss +422 -0
  55. data/lib/generators/raffle_v1/install/templates/config/initializers/date_format.rb +27 -0
  56. data/lib/generators/raffle_v1/install/templates/config/initializers/devise.rb +269 -0
  57. data/lib/generators/raffle_v1/install/templates/config/initializers/filter_parameter_logging.rb +4 -0
  58. data/lib/generators/raffle_v1/install/templates/config/initializers/friendly_id.rb +89 -0
  59. data/lib/generators/raffle_v1/install/templates/config/initializers/kaminari_config.rb +11 -0
  60. data/lib/generators/raffle_v1/install/templates/config/initializers/rafflev1.rb +4 -0
  61. data/lib/generators/raffle_v1/install/templates/db/seeds.rb +28 -0
  62. data/lib/raffle_v1/version.rb +2 -2
  63. data/test/controllers/raffle_v1/locales_controller_test.rb +51 -0
  64. data/test/controllers/raffle_v1/page_layouts_controller_test.rb +51 -0
  65. data/test/controllers/raffle_v1/pages_controller_test.rb +51 -0
  66. data/test/controllers/raffle_v1/program_locales_controller_test.rb +51 -0
  67. data/test/controllers/raffle_v1/program_settings_controller_test.rb +51 -0
  68. data/test/controllers/raffle_v1/programs_controller_test.rb +51 -0
  69. data/test/controllers/raffle_v1/role_users_controller_test.rb +51 -0
  70. data/test/controllers/raffle_v1/roles_controller_test.rb +51 -0
  71. data/test/controllers/raffle_v1/style_sheets_controller_test.rb +51 -0
  72. data/test/dummy/Guardfile +24 -0
  73. data/test/dummy/README.rdoc +15 -248
  74. data/test/dummy/Rakefile +1 -2
  75. data/test/dummy/app/assets/javascripts/application.js +3 -5
  76. data/test/dummy/app/assets/stylesheets/application.css +5 -3
  77. data/test/dummy/app/controllers/application_controller.rb +3 -1
  78. data/test/dummy/app/models/user.rb +4 -0
  79. data/test/dummy/app/views/layouts/application.html.erb +2 -2
  80. data/test/dummy/assets/javascripts/application.js +17 -0
  81. data/test/dummy/assets/stylesheets/application.css.scss +7 -0
  82. data/test/dummy/assets/stylesheets/framework_and_overrides.css.scss +422 -0
  83. data/test/dummy/bin/bundle +3 -0
  84. data/test/dummy/bin/rails +4 -0
  85. data/test/dummy/bin/rake +4 -0
  86. data/test/dummy/config.ru +1 -1
  87. data/test/dummy/config/application.rb +29 -47
  88. data/test/dummy/config/boot.rb +4 -9
  89. data/test/dummy/config/database.yml +48 -13
  90. data/test/dummy/config/environment.rb +3 -3
  91. data/test/dummy/config/environments/development.rb +19 -19
  92. data/test/dummy/config/environments/production.rb +44 -28
  93. data/test/dummy/config/environments/test.rb +17 -15
  94. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  95. data/test/dummy/config/initializers/date_format.rb +27 -0
  96. data/test/dummy/config/initializers/devise.rb +269 -0
  97. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  98. data/test/dummy/config/initializers/friendly_id.rb +89 -0
  99. data/test/dummy/config/initializers/inflections.rb +6 -5
  100. data/test/dummy/config/initializers/kaminari_config.rb +11 -0
  101. data/test/dummy/config/initializers/mime_types.rb +0 -1
  102. data/test/dummy/config/initializers/rafflev1.rb +4 -0
  103. data/test/dummy/config/initializers/session_store.rb +1 -6
  104. data/test/dummy/config/initializers/wrap_parameters.rb +6 -6
  105. data/test/dummy/config/locales/en.yml +20 -2
  106. data/{lib/database_cleaner-0.7.2/examples/db/sqlite_databases_go_here → test/dummy/config/rafflev1.yml} +0 -0
  107. data/test/dummy/config/routes.rb +3 -1
  108. data/test/dummy/config/secrets.yml +22 -0
  109. data/test/dummy/db/migrate/20140719173448_devise_create_raffle_v1_users.raffle_v1.rb +57 -0
  110. data/{db/migrate/20130124004626_devise_create_admins.rb → test/dummy/db/migrate/20140719173449_devise_create_raffle_v1_admins.raffle_v1.rb} +8 -7
  111. data/test/dummy/db/migrate/20140719173450_create_raffle_v1_versions.raffle_v1.rb +19 -0
  112. data/test/dummy/db/migrate/20140719173451_create_raffle_v1_friendly_id_slugs.raffle_v1.rb +16 -0
  113. data/test/dummy/db/schema.rb +72 -12
  114. data/test/dummy/db/seeds.rb +30 -0
  115. data/test/dummy/public/404.html +54 -13
  116. data/test/dummy/public/422.html +54 -13
  117. data/test/dummy/public/500.html +53 -12
  118. data/test/dummy/spec/factories.rb +5 -0
  119. data/test/dummy/spec/models/user_spec.rb +5 -0
  120. data/test/dummy/spec/rails_helper.rb +66 -0
  121. data/test/dummy/spec/spec_helper.rb +78 -0
  122. data/test/dummy/test/factories/users.rb +6 -0
  123. data/test/dummy/vendor/assets/javascripts/all_file.js +0 -0
  124. data/test/dummy/vendor/assets/javascripts/all_raffle_v1.js +7 -0
  125. data/test/dummy/vendor/assets/stylesheets/all_file.css +0 -0
  126. data/test/dummy/vendor/assets/stylesheets/all_raffle_v1.css +9 -0
  127. data/test/fixtures/raffle_v1/abilities.yml +11 -0
  128. data/test/fixtures/raffle_v1/add_name_to_users.yml +11 -0
  129. data/test/fixtures/raffle_v1/admin_abilities.yml +11 -0
  130. data/test/fixtures/raffle_v1/admins.yml +11 -0
  131. data/test/fixtures/raffle_v1/locales.yml +9 -0
  132. data/test/fixtures/raffle_v1/page_layouts.yml +11 -0
  133. data/test/fixtures/raffle_v1/pages.yml +41 -0
  134. data/test/fixtures/raffle_v1/program_locales.yml +9 -0
  135. data/test/fixtures/raffle_v1/program_settings.yml +7 -0
  136. data/test/fixtures/raffle_v1/programs.yml +23 -0
  137. data/test/fixtures/raffle_v1/role_users.yml +9 -0
  138. data/test/fixtures/raffle_v1/roles.yml +7 -0
  139. data/test/fixtures/raffle_v1/style_sheets.yml +17 -0
  140. data/test/fixtures/raffle_v1/stylesheets.yml +11 -0
  141. data/test/fixtures/raffle_v1/terms_and_conditions.yml +11 -0
  142. data/test/fixtures/raffle_v1/testers.yml +11 -0
  143. data/test/fixtures/raffle_v1/translation_keys.yml +11 -0
  144. data/test/fixtures/raffle_v1/translation_objects.yml +11 -0
  145. data/test/fixtures/raffle_v1/translations.yml +11 -0
  146. data/test/fixtures/raffle_v1/users.yml +11 -0
  147. data/test/helpers/raffle_v1/locales_helper_test.rb +6 -0
  148. data/test/helpers/raffle_v1/page_layouts_helper_test.rb +6 -0
  149. data/test/{unit/helpers/raffle_v1/posts_helper_test.rb → helpers/raffle_v1/pages_helper_test.rb} +1 -1
  150. data/test/helpers/raffle_v1/program_locales_helper_test.rb +6 -0
  151. data/test/helpers/raffle_v1/program_settings_helper_test.rb +6 -0
  152. data/test/helpers/raffle_v1/programs_helper_test.rb +6 -0
  153. data/test/helpers/raffle_v1/role_users_helper_test.rb +6 -0
  154. data/test/helpers/raffle_v1/roles_helper_test.rb +6 -0
  155. data/test/helpers/raffle_v1/style_sheets_helper_test.rb +6 -0
  156. data/test/{unit/raffle_v1/comment_test.rb → models/raffle_v1/ability_test.rb} +1 -1
  157. data/test/{functional/raffle_v1/comments_controller_test.rb → models/raffle_v1/add_name_to_user_test.rb} +1 -1
  158. data/test/models/raffle_v1/admin_ability_test.rb +9 -0
  159. data/test/models/raffle_v1/admin_test.rb +9 -0
  160. data/test/models/raffle_v1/locale_test.rb +9 -0
  161. data/test/models/raffle_v1/page_layout_test.rb +9 -0
  162. data/test/{unit/raffle_v1/post_test.rb → models/raffle_v1/page_test.rb} +1 -1
  163. data/test/models/raffle_v1/program_locale_test.rb +9 -0
  164. data/test/models/raffle_v1/program_setting_test.rb +9 -0
  165. data/test/models/raffle_v1/program_test.rb +9 -0
  166. data/test/models/raffle_v1/role_test.rb +9 -0
  167. data/test/models/raffle_v1/role_user_test.rb +9 -0
  168. data/test/models/raffle_v1/style_sheet_test.rb +9 -0
  169. data/test/models/raffle_v1/stylesheet_test.rb +9 -0
  170. data/test/models/raffle_v1/terms_and_condition_test.rb +9 -0
  171. data/test/models/raffle_v1/tester_test.rb +9 -0
  172. data/test/models/raffle_v1/translation_key_test.rb +9 -0
  173. data/test/models/raffle_v1/translation_object_test.rb +9 -0
  174. data/test/models/raffle_v1/translation_test.rb +9 -0
  175. data/test/models/raffle_v1/user_test.rb +9 -0
  176. metadata +409 -278
  177. data/README.md +0 -53
  178. data/app/assets/javascripts/raffle_v1/comments.js +0 -2
  179. data/app/assets/javascripts/raffle_v1/home.js.coffee +0 -3
  180. data/app/assets/javascripts/raffle_v1/locales.js.coffee +0 -3
  181. data/app/assets/javascripts/raffle_v1/page_layouts.js.coffee +0 -3
  182. data/app/assets/javascripts/raffle_v1/pages.js.coffee +0 -3
  183. data/app/assets/javascripts/raffle_v1/posts.js +0 -2
  184. data/app/assets/javascripts/raffle_v1/programs.js.coffee +0 -3
  185. data/app/assets/javascripts/raffle_v1/roles.js.coffee +0 -3
  186. data/app/assets/javascripts/raffle_v1/stylesheets.js.coffee +0 -3
  187. data/app/assets/javascripts/raffle_v1/terms_and_conditions.js.coffee +0 -3
  188. data/app/assets/javascripts/raffle_v1/terms_of_conditions.js.coffee +0 -3
  189. data/app/assets/javascripts/raffle_v1/translation_keys.js.coffee +0 -3
  190. data/app/assets/javascripts/raffle_v1/translation_objects.js.coffee +0 -3
  191. data/app/assets/javascripts/raffle_v1/user.js.coffee +0 -3
  192. data/app/assets/javascripts/raffle_v1/versions.js.coffee +0 -3
  193. data/app/assets/stylesheets/raffle_v1/TableTools.css +0 -264
  194. data/app/assets/stylesheets/raffle_v1/TableTools.css.scss +0 -264
  195. data/app/assets/stylesheets/raffle_v1/TableTools_JUI.css +0 -182
  196. data/app/assets/stylesheets/raffle_v1/TableTools_JUI.css.scss +0 -183
  197. data/app/assets/stylesheets/raffle_v1/_custom.css.scss +0 -3310
  198. data/app/assets/stylesheets/raffle_v1/_variable.scss +0 -122
  199. data/app/assets/stylesheets/raffle_v1/_variable_defaults.scss +0 -83
  200. data/app/assets/stylesheets/raffle_v1/application.css +0 -13
  201. data/app/assets/stylesheets/raffle_v1/application.css.scss.erb +0 -32
  202. data/app/assets/stylesheets/raffle_v1/bootstrap-responsive.css +0 -570
  203. data/app/assets/stylesheets/raffle_v1/bootstrap-responsive.css.scss +0 -570
  204. data/app/assets/stylesheets/raffle_v1/bootstrap.css +0 -4226
  205. data/app/assets/stylesheets/raffle_v1/bootstrap.css.scss +0 -4226
  206. data/app/assets/stylesheets/raffle_v1/colorbox.css +0 -88
  207. data/app/assets/stylesheets/raffle_v1/colorbox.css.scss +0 -88
  208. data/app/assets/stylesheets/raffle_v1/comments.css +0 -4
  209. data/app/assets/stylesheets/raffle_v1/grid.css.scss +0 -258
  210. data/app/assets/stylesheets/raffle_v1/hierarchy.css.scss +0 -16
  211. data/app/assets/stylesheets/raffle_v1/home.css.scss +0 -18
  212. data/app/assets/stylesheets/raffle_v1/jquery.dataTables.css +0 -83
  213. data/app/assets/stylesheets/raffle_v1/jquery.dataTables.css.scss +0 -83
  214. data/app/assets/stylesheets/raffle_v1/jquery.jcarousel.css +0 -206
  215. data/app/assets/stylesheets/raffle_v1/jquery.wysiwyg.css +0 -57
  216. data/app/assets/stylesheets/raffle_v1/jquery.wysiwyg.css.scss +0 -57
  217. data/app/assets/stylesheets/raffle_v1/jqueryui/jquery.ui.core.css +0 -38
  218. data/app/assets/stylesheets/raffle_v1/jqueryui/jquery.ui.core.css.scss +0 -38
  219. data/app/assets/stylesheets/raffle_v1/jqueryui/jquery.ui.dialog.css +0 -21
  220. data/app/assets/stylesheets/raffle_v1/jqueryui/jquery.ui.dialog.css.scss +0 -21
  221. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  222. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  223. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
  224. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  225. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  226. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  227. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  228. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  229. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  230. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
  231. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
  232. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
  233. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
  234. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
  235. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/jquery-ui-1.8.18.custom.css +0 -563
  236. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/jquery-ui-1.8.18.custom.css.scss +0 -563
  237. data/app/assets/stylesheets/raffle_v1/locales.css.scss +0 -3
  238. data/app/assets/stylesheets/raffle_v1/page_layouts.css.scss +0 -3
  239. data/app/assets/stylesheets/raffle_v1/pages.css.scss +0 -3
  240. data/app/assets/stylesheets/raffle_v1/posts.css +0 -4
  241. data/app/assets/stylesheets/raffle_v1/programs.css.scss +0 -3
  242. data/app/assets/stylesheets/raffle_v1/reset.css.scss +0 -96
  243. data/app/assets/stylesheets/raffle_v1/roles.css.scss +0 -3
  244. data/app/assets/stylesheets/raffle_v1/scaffolds.css.scss +0 -42
  245. data/app/assets/stylesheets/raffle_v1/stylesheets.css.scss +0 -3
  246. data/app/assets/stylesheets/raffle_v1/terms_and_conditions.css.scss +0 -3
  247. data/app/assets/stylesheets/raffle_v1/terms_of_conditions.css.scss +0 -4
  248. data/app/assets/stylesheets/raffle_v1/translation_keys.css.scss +0 -3
  249. data/app/assets/stylesheets/raffle_v1/translation_objects.css.scss +0 -3
  250. data/app/assets/stylesheets/raffle_v1/ui.multiselect.css +0 -33
  251. data/app/assets/stylesheets/raffle_v1/ui.multiselect.css.scss +0 -33
  252. data/app/assets/stylesheets/raffle_v1/user.css.scss +0 -3
  253. data/app/assets/stylesheets/raffle_v1/versions.css.scss +0 -3
  254. data/app/assets/stylesheets/scaffold.css +0 -56
  255. data/app/controllers/raffle_v1/comments_controller.rb +0 -30
  256. data/app/controllers/raffle_v1/home_controller.rb +0 -15
  257. data/app/controllers/raffle_v1/locales_controller.rb +0 -87
  258. data/app/controllers/raffle_v1/page_layouts_controller.rb +0 -87
  259. data/app/controllers/raffle_v1/posts_controller.rb +0 -87
  260. data/app/controllers/raffle_v1/programs_controller.rb +0 -140
  261. data/app/controllers/raffle_v1/roles_controller.rb +0 -87
  262. data/app/controllers/raffle_v1/stylesheets_controller.rb +0 -19
  263. data/app/controllers/raffle_v1/terms_and_conditions_controller.rb +0 -118
  264. data/app/controllers/raffle_v1/translation_keys_controller.rb +0 -119
  265. data/app/controllers/raffle_v1/translation_objects_controller.rb +0 -87
  266. data/app/controllers/raffle_v1/user_controller.rb +0 -138
  267. data/app/controllers/raffle_v1/versions_controller.rb +0 -15
  268. data/app/helpers/raffle_v1/comments_helper.rb +0 -4
  269. data/app/helpers/raffle_v1/posts_helper.rb +0 -4
  270. data/app/models/raffle_v1/ability.rb +0 -30
  271. data/app/models/raffle_v1/admin.rb +0 -35
  272. data/app/models/raffle_v1/admin_ability.rb +0 -28
  273. data/app/models/raffle_v1/comment.rb +0 -7
  274. data/app/models/raffle_v1/locale.rb +0 -29
  275. data/app/models/raffle_v1/page.rb +0 -26
  276. data/app/models/raffle_v1/page_layout.rb +0 -6
  277. data/app/models/raffle_v1/post.rb +0 -7
  278. data/app/models/raffle_v1/program.rb +0 -84
  279. data/app/models/raffle_v1/program_locale.rb +0 -11
  280. data/app/models/raffle_v1/program_setting.rb +0 -5
  281. data/app/models/raffle_v1/role.rb +0 -5
  282. data/app/models/raffle_v1/roles_users.rb +0 -5
  283. data/app/models/raffle_v1/stylesheet.rb +0 -9
  284. data/app/models/raffle_v1/terms_and_condition.rb +0 -17
  285. data/app/models/raffle_v1/translation.rb +0 -29
  286. data/app/models/raffle_v1/translation_key.rb +0 -35
  287. data/app/models/raffle_v1/translation_object.rb +0 -11
  288. data/app/views/raffle_v1/comments/_comment.html.erb +0 -1
  289. data/app/views/raffle_v1/comments/_form.html.erb +0 -8
  290. data/app/views/raffle_v1/comments/index.html.erb +0 -13
  291. data/app/views/raffle_v1/posts/_form.html.erb +0 -25
  292. data/app/views/raffle_v1/posts/edit.html.erb +0 -6
  293. data/app/views/raffle_v1/posts/index.html.erb +0 -25
  294. data/app/views/raffle_v1/posts/new.html.erb +0 -5
  295. data/app/views/raffle_v1/posts/show.html.erb +0 -19
  296. data/config/rafflev1.rb +0 -6
  297. data/db/migrate/20130127235347_create_programs.rb +0 -9
  298. data/db/migrate/20130129155515_add_domain_fields_to_programs.rb +0 -6
  299. data/db/migrate/20130129160949_create_terms_and_conditions.rb +0 -18
  300. data/db/migrate/20130129183112_add_program_to_users.rb +0 -5
  301. data/db/migrate/20130129204204_add_username_to_users.rb +0 -6
  302. data/db/migrate/20130129211205_create_roles.rb +0 -9
  303. data/db/migrate/20130129212302_create_roles_users.rb +0 -12
  304. data/db/migrate/20130130013315_create_locales.rb +0 -11
  305. data/db/migrate/20130130154500_create_program_locales.rb +0 -8
  306. data/db/migrate/20130130223342_add_settings_to_users.rb +0 -5
  307. data/db/migrate/20130130223609_add_locale_available_to_program.rb +0 -5
  308. data/db/migrate/20130130223810_add_locales_to_versions.rb +0 -5
  309. data/db/migrate/20130130224141_add_locale_name_to_program.rb +0 -5
  310. data/db/migrate/20130130224327_add_admin_type_to_admins.rb +0 -5
  311. data/db/migrate/20130130225223_add_deleted_at_to_models.rb +0 -9
  312. data/db/migrate/20130130230516_create_translations.rb +0 -13
  313. data/db/migrate/20130131005653_add_timeout_field_to_program.rb +0 -7
  314. data/db/migrate/20130131144951_create_stylesheets.rb +0 -14
  315. data/db/migrate/20130202132442_add_tos_to_program.rb +0 -5
  316. data/db/migrate/20130202133149_add_programid_to_terms.rb +0 -23
  317. data/db/migrate/20130202193646_add_akm_to_terms_and_conditions.rb +0 -5
  318. data/db/migrate/20130203035054_create_translation_keys.rb +0 -10
  319. data/db/migrate/20130203214314_create_program_settings.rb +0 -9
  320. data/db/migrate/20130204025824_add_translationkey_to_translation.rb +0 -5
  321. data/db/migrate/20130204030555_create_translation_objects.rb +0 -39
  322. data/db/migrate/20130205203152_create_pages.rb +0 -25
  323. data/db/migrate/20130208042652_add_fields_to_page.rb +0 -6
  324. data/db/migrate/20130208043123_create_page_layouts.rb +0 -12
  325. data/db/migrate/20130208051925_add_statusitem_to_page.rb +0 -5
  326. data/db/migrate/20130306012135_add_fields_to_user.rb +0 -40
  327. data/db/migrate/20130306162357_change_bad_fields_on_user.rb +0 -11
  328. data/db/migrate/20130306163554_add_password_created_at_to_user.rb +0 -6
  329. data/db/migrate/20130306165455_add_confirmable_to_user.rb +0 -14
  330. data/db/migrate/20130306211253_add_username_index_to_user.rb +0 -41
  331. data/db/migrate/20130313011833_add_field_to_user.rb +0 -5
  332. data/db/migrate/20130326135125_create_raffle_v1_posts.rb +0 -10
  333. data/db/migrate/20130326174121_create_raffle_v1_comments.rb +0 -10
  334. data/lib/database_cleaner-0.7.2/Gemfile.lock +0 -163
  335. data/lib/database_cleaner-0.7.2/History.txt +0 -209
  336. data/lib/database_cleaner-0.7.2/LICENSE +0 -20
  337. data/lib/database_cleaner-0.7.2/README.textile +0 -223
  338. data/lib/database_cleaner-0.7.2/Rakefile +0 -65
  339. data/lib/database_cleaner-0.7.2/TODO +0 -3
  340. data/lib/database_cleaner-0.7.2/VERSION.yml +0 -5
  341. data/lib/database_cleaner-0.7.2/cucumber.yml +0 -1
  342. data/lib/database_cleaner-0.7.2/examples/Gemfile +0 -49
  343. data/lib/database_cleaner-0.7.2/examples/Gemfile.lock +0 -163
  344. data/lib/database_cleaner-0.7.2/examples/config/database.yml.example +0 -8
  345. data/lib/database_cleaner-0.7.2/examples/features/example.feature +0 -11
  346. data/lib/database_cleaner-0.7.2/examples/features/example_multiple_db.feature +0 -23
  347. data/lib/database_cleaner-0.7.2/examples/features/example_multiple_orm.feature +0 -22
  348. data/lib/database_cleaner-0.7.2/examples/features/step_definitions/activerecord_steps.rb +0 -31
  349. data/lib/database_cleaner-0.7.2/examples/features/step_definitions/couchpotato_steps.rb +0 -31
  350. data/lib/database_cleaner-0.7.2/examples/features/step_definitions/datamapper_steps.rb +0 -37
  351. data/lib/database_cleaner-0.7.2/examples/features/step_definitions/mongoid_steps.rb +0 -23
  352. data/lib/database_cleaner-0.7.2/examples/features/step_definitions/mongomapper_steps.rb +0 -31
  353. data/lib/database_cleaner-0.7.2/examples/features/step_definitions/translation_steps.rb +0 -55
  354. data/lib/database_cleaner-0.7.2/examples/features/support/env.rb +0 -62
  355. data/lib/database_cleaner-0.7.2/examples/lib/activerecord_models.rb +0 -41
  356. data/lib/database_cleaner-0.7.2/examples/lib/couchpotato_models.rb +0 -61
  357. data/lib/database_cleaner-0.7.2/examples/lib/datamapper_models.rb +0 -50
  358. data/lib/database_cleaner-0.7.2/examples/lib/mongoid_models.rb +0 -49
  359. data/lib/database_cleaner-0.7.2/examples/lib/mongomapper_models.rb +0 -51
  360. data/lib/database_cleaner-0.7.2/features/cleaning.feature +0 -22
  361. data/lib/database_cleaner-0.7.2/features/cleaning_default_strategy.feature +0 -19
  362. data/lib/database_cleaner-0.7.2/features/cleaning_multiple_dbs.feature +0 -21
  363. data/lib/database_cleaner-0.7.2/features/cleaning_multiple_orms.feature +0 -29
  364. data/lib/database_cleaner-0.7.2/features/step_definitions/database_cleaner_steps.rb +0 -32
  365. data/lib/database_cleaner-0.7.2/features/support/env.rb +0 -7
  366. data/lib/database_cleaner-0.7.2/features/support/feature_runner.rb +0 -39
  367. data/lib/database_cleaner-0.7.2/lib/database_cleaner.rb +0 -3
  368. data/lib/database_cleaner-0.7.2/lib/database_cleaner/active_record/base.rb +0 -53
  369. data/lib/database_cleaner-0.7.2/lib/database_cleaner/active_record/deletion.rb +0 -69
  370. data/lib/database_cleaner-0.7.2/lib/database_cleaner/active_record/transaction.rb +0 -28
  371. data/lib/database_cleaner-0.7.2/lib/database_cleaner/active_record/truncation.rb +0 -151
  372. data/lib/database_cleaner-0.7.2/lib/database_cleaner/base.rb +0 -138
  373. data/lib/database_cleaner-0.7.2/lib/database_cleaner/configuration.rb +0 -94
  374. data/lib/database_cleaner-0.7.2/lib/database_cleaner/couch_potato/base.rb +0 -7
  375. data/lib/database_cleaner-0.7.2/lib/database_cleaner/couch_potato/truncation.rb +0 -28
  376. data/lib/database_cleaner-0.7.2/lib/database_cleaner/cucumber.rb +0 -11
  377. data/lib/database_cleaner-0.7.2/lib/database_cleaner/data_mapper/base.rb +0 -21
  378. data/lib/database_cleaner-0.7.2/lib/database_cleaner/data_mapper/transaction.rb +0 -26
  379. data/lib/database_cleaner-0.7.2/lib/database_cleaner/data_mapper/truncation.rb +0 -175
  380. data/lib/database_cleaner-0.7.2/lib/database_cleaner/generic/base.rb +0 -20
  381. data/lib/database_cleaner-0.7.2/lib/database_cleaner/generic/truncation.rb +0 -37
  382. data/lib/database_cleaner-0.7.2/lib/database_cleaner/mongo/truncation.rb +0 -22
  383. data/lib/database_cleaner-0.7.2/lib/database_cleaner/mongo_mapper/base.rb +0 -20
  384. data/lib/database_cleaner-0.7.2/lib/database_cleaner/mongo_mapper/truncation.rb +0 -19
  385. data/lib/database_cleaner-0.7.2/lib/database_cleaner/mongoid/base.rb +0 -20
  386. data/lib/database_cleaner-0.7.2/lib/database_cleaner/mongoid/truncation.rb +0 -20
  387. data/lib/database_cleaner-0.7.2/lib/database_cleaner/null_strategy.rb +0 -15
  388. data/lib/database_cleaner-0.7.2/lib/database_cleaner/sequel/base.rb +0 -22
  389. data/lib/database_cleaner-0.7.2/lib/database_cleaner/sequel/transaction.rb +0 -25
  390. data/lib/database_cleaner-0.7.2/lib/database_cleaner/sequel/truncation.rb +0 -50
  391. data/lib/database_cleaner-0.7.2/spec/database_cleaner/active_record/base_spec.rb +0 -144
  392. data/lib/database_cleaner-0.7.2/spec/database_cleaner/active_record/transaction_spec.rb +0 -77
  393. data/lib/database_cleaner-0.7.2/spec/database_cleaner/active_record/truncation_spec.rb +0 -76
  394. data/lib/database_cleaner-0.7.2/spec/database_cleaner/base_spec.rb +0 -493
  395. data/lib/database_cleaner-0.7.2/spec/database_cleaner/configuration_spec.rb +0 -294
  396. data/lib/database_cleaner-0.7.2/spec/database_cleaner/couch_potato/truncation_spec.rb +0 -41
  397. data/lib/database_cleaner-0.7.2/spec/database_cleaner/data_mapper/base_spec.rb +0 -30
  398. data/lib/database_cleaner-0.7.2/spec/database_cleaner/data_mapper/transaction_spec.rb +0 -23
  399. data/lib/database_cleaner-0.7.2/spec/database_cleaner/data_mapper/truncation_spec.rb +0 -11
  400. data/lib/database_cleaner-0.7.2/spec/database_cleaner/generic/base_spec.rb +0 -22
  401. data/lib/database_cleaner-0.7.2/spec/database_cleaner/generic/truncation_spec.rb +0 -78
  402. data/lib/database_cleaner-0.7.2/spec/database_cleaner/mongo_mapper/base_spec.rb +0 -33
  403. data/lib/database_cleaner-0.7.2/spec/database_cleaner/mongo_mapper/mongo_examples.rb +0 -8
  404. data/lib/database_cleaner-0.7.2/spec/database_cleaner/mongo_mapper/truncation_spec.rb +0 -74
  405. data/lib/database_cleaner-0.7.2/spec/database_cleaner/sequel/base_spec.rb +0 -32
  406. data/lib/database_cleaner-0.7.2/spec/database_cleaner/sequel/transaction_spec.rb +0 -21
  407. data/lib/database_cleaner-0.7.2/spec/database_cleaner/sequel/truncation_spec.rb +0 -13
  408. data/lib/database_cleaner-0.7.2/spec/database_cleaner/shared_strategy_spec.rb +0 -13
  409. data/lib/database_cleaner-0.7.2/spec/rcov.opts +0 -1
  410. data/lib/database_cleaner-0.7.2/spec/spec.opts +0 -7
  411. data/lib/database_cleaner-0.7.2/spec/spec_helper.rb +0 -19
  412. data/lib/generators/raffle_v1/install/USAGE +0 -8
  413. data/test/dummy/config/initializers/secret_token.rb +0 -7
  414. data/test/dummy/script/rails +0 -6
  415. data/test/fixtures/raffle_v1/comments.yml +0 -9
  416. data/test/fixtures/raffle_v1/posts.yml +0 -9
  417. data/test/functional/raffle_v1/posts_controller_test.rb +0 -51
  418. data/test/unit/helpers/raffle_v1/comments_helper_test.rb +0 -6
@@ -0,0 +1,11 @@
1
+ module RaffleV1
2
+ class Admin::BaseController < ApplicationController
3
+ before_filter :require_admin!
4
+
5
+ def index
6
+ @last_signups = User.last_signups(10)
7
+ @last_signins = User.last_signins(10)
8
+ @count = User.users_count
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,69 @@
1
+ module RaffleV1
2
+ class Admin::UsersController < Admin::BaseController
3
+ before_action :set_user, only: [
4
+ :show,
5
+ :edit,
6
+ :update,
7
+ :destroy
8
+ ]
9
+
10
+
11
+ def index
12
+ @users = User.search_and_order(params[:search], params[:page])
13
+ end
14
+
15
+ def show
16
+ redirect_to edit_admin_user_path(params[:id])
17
+ end
18
+
19
+ def edit
20
+ end
21
+
22
+ def update
23
+ old_username = @user.username
24
+ new_params = user_params.dup
25
+ new_params[:username] = new_params[:username].strip
26
+ new_params[:email] = new_params[:email].strip
27
+
28
+ @user.username = new_params[:username]
29
+ @user.email = new_params[:email]
30
+ @user.password = new_params[:password] if new_params[:password].strip.length > 0
31
+ @user.password_confirmation = new_params[:password_confirmation] if new_params[:password_confirmation].strip.length > 0
32
+
33
+ if current_user.id != @user.id
34
+ @user.admin = new_params[:admin]=="0" ? false : true
35
+ @user.locked = new_params[:locked]=="0" ? false : true
36
+ end
37
+
38
+ if @user.valid?
39
+ @user.skip_reconfirmation!
40
+ @user.save
41
+ redirect_to admin_users_path, notice: "#{@user.username} updated."
42
+ else
43
+ flash[:alert] = "#{old_username} couldn't be updated."
44
+ render :edit
45
+ end
46
+ end
47
+
48
+
49
+ private
50
+
51
+ def set_user
52
+ @user = User.friendly.find(params[:id])
53
+ rescue
54
+ flash[:alert] = "The user with an id of #{params[:id]} doesn't exist."
55
+ redirect_to admin_users_path
56
+ end
57
+
58
+ def user_params
59
+ params.require(:user).permit(
60
+ :username,
61
+ :email,
62
+ :password,
63
+ :password_confirmation,
64
+ :admin,
65
+ :locked
66
+ )
67
+ end
68
+ end
69
+ end
@@ -1,84 +1,57 @@
1
- require "cancan"
2
- require "ransack"
3
-
4
1
  module RaffleV1
5
2
  class ApplicationController < ActionController::Base
6
- protect_from_forgery
7
- before_filter :authenticate_any!, unless: :stylesheet_controller?
8
- check_authorization :unless => :devise_controller?
9
- helper :all
10
-
11
- def authenticate_any!
12
- if admin_signed_in?
13
- true
14
- else
15
- authenticate_user!
16
- end
17
- end
18
-
19
- rescue_from CanCan::AccessDenied do |exception|
20
- if user_signed_in? && current_user.requires_action_before_login? && !authenticated_by_proxy?
21
- redirect_to user_required_actions_index_path, :alert => exception.message
22
- else
23
- redirect_to root_url, :alert => exception.message
24
- end
25
- end
26
-
27
- def t(key, options = {})
28
- if (val = super) =~ /translation missing/
29
- return key
30
- end
31
-
32
- val
33
- end
34
-
35
- def authenticate_by_proxy(authenticate = true)
36
- session[:proxy_auth] = authenticate
37
- end
38
-
39
- def authenticated_by_proxy?
40
- session[:proxy_auth] || false
41
- end
42
-
43
- private
44
-
45
- def current_ability
46
- @current_ability ||= case
47
- when current_admin || current_user.class.name == "Admin"
48
- AdminAbility.new(current_admin || current_user, @current_program)
49
- when current_user
50
- UserAbility.new(current_user, authenticated_by_proxy?)
51
- # AdminAbility.new(current_user, @current_program)
52
- else
53
- GuestAbility.new
54
- end
55
- end
56
-
57
- def user_for_paper_trail
58
- if user_signed_in? || admin_signed_in?
59
- user = admin_signed_in? ? current_admin.email : current_user.email
60
- else
61
- user = "Guest"
62
- end
63
- end
64
-
65
- def ckeditor_filebrowser_scope(options = {})
66
- if @current_program
67
- super({ :program_id => @current_program.id}.merge(options))
68
- end
69
- end
70
-
71
- def after_sign_out_path_for(resource_or_scope)
72
- if admin_signed_in?
73
- admin_session_path
74
- else
75
- user_session_path
76
- end
3
+ # Prevent CSRF attacks by raising an exception.
4
+ # For APIs, you may want to use :null_session instead.
5
+ protect_from_forgery with: :exception
6
+
7
+ before_filter :configure_permitted_parameters, if: :devise_controller?
8
+ before_filter :reject_locked!, if: :devise_controller?
9
+
10
+
11
+ # Devise permitted params
12
+ def configure_permitted_parameters
13
+ devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(
14
+ :username,
15
+ :email,
16
+ :password,
17
+ :password_confirmation)
18
+ }
19
+ devise_parameter_sanitizer.for(:account_update) { |u| u.permit(
20
+ :username,
21
+ :email,
22
+ :password,
23
+ :password_confirmation,
24
+ :current_password
25
+ )
26
+ }
27
+ end
28
+
29
+ # Redirects on successful sign in
30
+ def after_sign_in_path_for(resource)
31
+ inside_path
32
+ end
33
+
34
+ # Auto-sign out locked users
35
+ def reject_locked!
36
+ if current_user && current_user.locked?
37
+ sign_out current_user
38
+ user_session = nil
39
+ current_user = nil
40
+ flash[:alert] = "Your account is locked."
41
+ flash[:notice] = nil
42
+ redirect_to root_url
77
43
  end
78
-
79
- def stylesheet_controller?
80
- is_a?(StylesheetsController)
44
+ end
45
+ helper_method :reject_locked!
46
+
47
+ # Only permits admin users
48
+ def require_admin!
49
+ authenticate_user!
50
+
51
+ if current_user && !current_user.admin?
52
+ redirect_to root_path
81
53
  end
82
-
54
+ end
55
+ helper_method :require_admin!
83
56
  end
84
57
  end
@@ -1,180 +1,13 @@
1
- require_dependency "raffle_v1/application_controller"
2
-
3
1
  module RaffleV1
4
- class PagesController < ApplicationController
5
- load_and_authorize_resource
6
-
7
- def index
8
- if !params[:page_filter].nil? && !params[:page_filter][:type].empty?
9
- @pages = @current_program.pages.where("page_type = ?", params[:page_filter][:type])
10
- else
11
- @pages = @current_program.pages.all
12
- end
13
-
14
- respond_to do |format|
15
- format.html # index.html.erb
16
- format.json { render json: @pages }
17
- end
18
- end
19
-
20
- def show
21
- @page = Page.find(params[:id])
22
-
23
- respond_to do |format|
24
- format.html # show.html.erb
25
- format.json { render json: @page }
26
- end
27
- end
28
-
29
- def new
30
- @page = Page.new
31
-
32
- respond_to do |format|
33
- format.html # new.html.erb
34
- format.json { render json: @page }
35
- end
36
- end
37
-
38
- def edit
39
- @page = Page.find(params[:id])
40
- @status = @page.item_status
41
- @header = @page.header
42
- @footer = @page.footer
43
- @nav = @page.nav
44
- @type = @page.page_type
45
- end
46
-
47
- def create
48
- @page = Page.new(params[:page])
49
- @page.program_id = @current_program.id
50
-
51
- preDefined = @current_program.pages.where(page_type: "Pre-Defined").first
52
- if params[:page][:page_type] == "Pre-Defined" && preDefined.present?
53
- flash[:notice] = "Pre-Defined page already exist."
54
- render :new
55
- return
56
- end
57
-
58
- if params[:preview_button] || !@page.save
59
- render :action => 'new'
60
- return
61
- end
62
-
63
-
64
- if @page.item_status == 'archive'
65
- @page.archived = true
66
- end
67
-
68
- params[:page][:translations_attributes].each do |t|
69
- t = t[1]
70
- doc = Nokogiri::HTML(t[:body])
71
- doc.xpath("//text()").remove
72
- t[:body] = doc.to_s
73
- end
74
-
75
- respond_to do |format|
76
- if @page.save
77
- save_reach @page
78
- if params[:button] == 'save_and_continue'
79
- format.html { redirect_to edit_page_path(@page), notice: "Page was successfully created." }
80
- else
81
- format.html { redirect_to @page, notice: 'Page was successfully created.' }
82
- end
83
-
84
- format.json { render json: @page, status: :created, location: @page }
85
- else
86
- format.html { render action: "new" }
87
- format.json { render json: @page.errors, status: :unprocessable_entity }
88
- end
89
- end
90
- end
91
-
92
- def update
93
- @page = Page.find(params[:id])
94
-
95
- if params[:page][:item_status] == 'archived'
96
- @page.archived = true
97
- end
98
-
99
- respond_to do |format|
100
- if @page.update_attributes(params[:page])
101
- save_reach @page
102
- if params[:button] == 'save_and_continue'
103
- format.html { redirect_to edit_page_path(@page), notice: "Page was successfully created." }
104
- else
105
- format.html { redirect_to @page, notice: 'Page was successfully created.' }
106
- end
107
- format.json { head :no_content }
108
- else
109
- format.html { render action: "edit" }
110
- format.json { render json: @page.errors, status: :unprocessable_entity }
111
- end
112
- end
113
- end
114
-
115
- def destroy
116
- @page = Page.find(params[:id])
117
- @page.destroy
118
-
119
- respond_to do |format|
120
- format.html { redirect_to pages_url }
121
- format.json { head :no_content }
122
- end
123
- end
124
-
125
- def action
126
- if params[:button] == 'archive' && params[:page_ids]
127
- archive
128
- elsif params[:button] == 'publish' && params[:page_ids]
129
- publish
130
- elsif params[:button] == 'draft' && params[:page_ids]
131
- draft
132
- elsif params[:button] == 'remove' && params[:page_ids]
133
- remove
134
- else
135
- redirect_to pages_url#, flash: "Article must be selected."
136
- end
137
- end
138
-
139
- def publish
140
- @pages = Page.find(params[:page_ids])
141
- @pages.each do |a|
142
- a.update_attributes(publish_date: Date.today, archived: false, item_status: "active", expiration_date: Date.today + 5.days)
143
- end
144
- redirect_to pages_url#, flash: "pages published."
145
- end
146
-
147
- def archive
148
- @pages = Page.find(params[:page_ids])
149
- @pages.each do |a|
150
- a.update_attributes(archived: true, item_status: 'archive')
151
- end
152
- redirect_to pages_url
153
- end
154
-
155
- def draft
156
- @pages = Page.find(params[:page_ids])
157
- @pages.each do |a|
158
- a.update_attributes(item_status: 'draft')
159
- end
160
- redirect_to pages_url
161
- end
162
-
163
- def remove
164
- @pages = Page.find(params[:page_ids])
165
- @pages.each do |a|
166
- a.destroy
167
- end
168
-
169
- respond_to do |format|
170
- format.html { redirect_to pages_url }
171
- format.json { head :no_content }
172
- end
173
- end
174
-
175
- def find_page_info
176
- page = Page.find(params[:page_id])
177
- render json: { title: page.translation_for(I18n.locale).title, body: page.translation_for(I18n.locale).body }
178
- end
179
- end
2
+ class PagesController < ApplicationController
3
+ before_action :authenticate_user!, only: [
4
+ :inside
5
+ ]
6
+
7
+ def home
8
+ end
9
+
10
+ def inside
11
+ end
12
+ end
180
13
  end
@@ -1,4 +1,9 @@
1
1
  module RaffleV1
2
2
  module ApplicationHelper
3
+ def title(value)
4
+ unless value.nil?
5
+ @title = "#{value} | RaffleV1"
6
+ end
7
+ end
3
8
  end
4
9
  end
@@ -1,108 +1,62 @@
1
- module RaffleV1
2
- class User < ActiveRecord::Base
3
-
4
- STATUSES = ["active", "terminated"]
5
- # Include default devise modules. Others available are:
6
- devise :database_authenticatable,
7
- :recoverable, :rememberable, :trackable,
8
- :token_authenticatable, :lockable, :authentication_keys => [:username, :program_id],
9
- :lock_strategy => :failed_attempts, :unlock_strategy => :time,
10
- :maximum_attempts => 1000, :unlock_in => 1000 # These are ignored and overridden by the attempts_exceeded? and lock_expired?
11
-
12
- # Setup accessible (or protected) attributes for the user model
13
- attr_accessible :email, :password, :password_confirmation, :remember_me, :first_name, :last_name, :middle_initial, :suffix,
14
- :work_email, :employee_number, :employee_id, :work_address, :work_city, :work_state, :work_postal, :work_county, :home_address, :home_city,:home_state,
15
- :home_postal,:home_county, :work_phone,:home_phone, :department_code, :department_name, :cost_center_cost, :user_name,
16
- :job_title, :date_of_hire, :date_of_rehire, :date_of_birth, :preferred_language, :user_type, :employment_type, :vip_flag, :time_offset, :date_of_terminate, :manager_id,
17
- :hierarchy_node, :hierarchy_node_id
18
-
19
- default_scope where(:deleted_at => nil)
20
-
21
- belongs_to :program
22
-
23
- has_many :belongs_to_user_relationships, class_name: "UserRelationship", foreign_key: "user_id"
24
- has_many :has_many_user_relationships, class_name: "UserRelationship", foreign_key: "related_user_id"
25
-
26
- before_validation :generate_password_for_new_user
27
-
28
- validates :username, :employee_id, :presence => true
29
- validates_confirmation_of :password, unless: Proc.new{|u| u.is_temporary_password == true or u.deleted_at != nil}
30
- validates :date_of_birth, date: { before: Date.today, message: "must be before #{Date.today}"}, if: Proc.new { self.date_of_birth.present? }
31
- validates_presence_of :password, :if => :password_required?
32
- validates_confirmation_of :password, :if => :password_required?
33
- validates_length_of :password, :within => Devise.password_length, :allow_blank => true
34
-
35
- validate :password, presence: true, unless: Proc.new {|u| u.is_temporary_password == true or u.deleted_at != nil}
36
- validate :custom_password_strength, unless: Proc.new { |u| u.deleted_at != nil}
37
- validate :unique_usernames, on: :create
38
-
39
- def generate_password_for_new_user
40
- if password.nil? and self.new_record?
41
- self.password = SecureRadom.hex(8) + "!&4$"
42
- self.password_created_at = Time.now
43
- self.is_temporary_password = true
44
- end
45
- end
46
-
47
- def reset_password_token_and_notify host = nil
48
- self.password = User.reset_password_token
49
- self.reset_password_sent_at = User.reset_password_token
50
- self.reset_password_sent_at = Time.now
51
- self.save
52
- puts UserMailer.reset_password(self, host).deliver
53
- end
54
-
55
- def custom_password_strength
56
- if self.password.present? && self.encrypted_password_changed?
57
- program = Program.find(self.program.id)
58
- strength = PasswordStrength.test(self.username, self.password)
59
- unless strength.valid?(program.password_strength.to_sym)
60
- is_valid = false
61
- self.errors.add(:password, "is not secure. Password must be #{program.password_strength.to_sym}")
62
- end
63
- end
1
+ require 'kaminari'
2
+ require 'friendly_id'
64
3
 
65
- is_valid
66
- end
67
-
68
- def self.generate_random_password
69
- start_length = 10
70
- token = ""
71
-
72
- #loop over token generation untill we get something matching our desired length
73
- #the reason we loop is so that we can confidently filter our barred characters
74
- #while resorting the gaps with the new random characters
75
- while token.length < start_length
76
- token << Devise.friendly_token.first(start_length)
77
- token.gsub!(/[iIlLoO10]/, "")
78
- end
79
- #slice incase the string became too long
80
- token = token[0, start_length]
81
-
82
- #need to add special chars into the string
83
- random = Random.new
84
-
85
- token.insert(random.rand(0..token.length), "@")
86
- token.insert(random.rand(0..token.length), "!")
87
-
88
- token
89
- end
90
-
91
- def fullname
92
- "#{self.first_name} #{self.last_name}"
93
- end
94
-
95
- def full_home_phone_number
96
- "(#{home_telephone_country_code}) #{home_telephone_area_code}-#{home_telephone_number}"
97
- end
98
-
99
- def full_home_address
100
- "#{home_address}\n #{home_city}, #{home_state}"
101
- end
102
-
103
- def active?
104
- self.date_of_termination.blank? || self.date_of_termination < Date.new
105
- end
106
-
107
- end
108
- end
4
+ module RaffleV1
5
+ class User < ActiveRecord::Base
6
+ # Use friendly_id on Users
7
+ extend FriendlyId
8
+ friendly_id :friendify, use: :slugged
9
+
10
+ # necessary to override friendly_id reserved words
11
+ def friendify
12
+ if username.downcase == "admin"
13
+ "user-#{username}"
14
+ else
15
+ "#{username}"
16
+ end
17
+ end
18
+
19
+ # Include default devise modules. Others available are:
20
+ # :confirmable, :lockable, :timeoutable and :omniauthable
21
+ devise :database_authenticatable, :registerable,
22
+ :recoverable, :rememberable, :trackable, :validatable, :confirmable
23
+
24
+ # Pagination
25
+ paginates_per 100
26
+
27
+ # Validations
28
+ # :username
29
+ validates :username, uniqueness: { case_sensitive: false }
30
+ validates_format_of :username, with: /\A[a-zA-Z0-9]*\z/, on: :create, message: "can only contain letters and digits"
31
+ validates :username, length: { in: 4..10 }
32
+ # :email
33
+ validates_format_of :email, with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
34
+
35
+ def self.paged(page_number)
36
+ order(admin: :desc, username: :asc).page page_number
37
+ end
38
+
39
+ def self.search_and_order(search, page_number)
40
+ if search
41
+ where("username LIKE ?", "%#{search.downcase}%").order(
42
+ admin: :desc, username: :asc
43
+ ).page page_number
44
+ else
45
+ order(admin: :desc, username: :asc).page page_number
46
+ end
47
+ end
48
+
49
+ def self.last_signups(count)
50
+ order(created_at: :desc).limit(count).select("id","username","slug","created_at")
51
+ end
52
+
53
+ def self.last_signins(count)
54
+ order(last_sign_in_at:
55
+ :desc).limit(count).select("id","username","slug","last_sign_in_at")
56
+ end
57
+
58
+ def self.users_count
59
+ where("admin = ? AND locked = ?",false,false).count
60
+ end
61
+ end
62
+ end