typus 3.0.2 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (343) hide show
  1. data/Gemfile +20 -9
  2. data/Gemfile.lock +93 -65
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +61 -0
  5. data/Rakefile +5 -0
  6. data/app/controllers/admin/account_controller.rb +7 -10
  7. data/app/controllers/admin/base_controller.rb +16 -1
  8. data/app/controllers/admin/resources_controller.rb +270 -159
  9. data/app/controllers/admin/session_controller.rb +8 -9
  10. data/app/helpers/admin/base_helper.rb +13 -28
  11. data/app/helpers/admin/dashboard_helper.rb +4 -10
  12. data/app/helpers/admin/file_preview_helper.rb +70 -0
  13. data/app/helpers/admin/filters_helper.rb +64 -45
  14. data/app/helpers/admin/form_helper.rb +37 -62
  15. data/app/helpers/admin/relationships_helper.rb +63 -78
  16. data/app/helpers/admin/resources_helper.rb +10 -31
  17. data/app/helpers/admin/search_helper.rb +6 -9
  18. data/app/helpers/admin/sidebar_helper.rb +15 -20
  19. data/app/helpers/admin/table_helper.rb +79 -170
  20. data/app/mailers/admin/mailer.rb +1 -1
  21. data/app/views/admin/account/forgot_password.html.erb +2 -2
  22. data/app/views/admin/account/new.html.erb +8 -4
  23. data/app/views/admin/base/user_guide.html.erb +85 -0
  24. data/app/views/admin/dashboard/_sidebar.html.erb +3 -1
  25. data/app/views/admin/dashboard/show.html.erb +2 -2
  26. data/app/views/admin/dashboard/styles.html.erb +2 -2
  27. data/app/views/admin/helpers/_apps.html.erb +5 -4
  28. data/app/views/admin/helpers/_file_preview.html.erb +3 -0
  29. data/app/views/admin/helpers/_header.html.erb +3 -3
  30. data/app/views/admin/helpers/_login_info.html.erb +2 -2
  31. data/app/views/admin/helpers/dashboard/_applications.html.erb +6 -9
  32. data/app/views/admin/helpers/dashboard/_resources.html.erb +2 -3
  33. data/app/views/admin/helpers/filters/_filters.html.erb +1 -1
  34. data/app/views/admin/helpers/resources/_display_link_to_previous.html.erb +1 -1
  35. data/app/views/admin/helpers/resources/_errors.html.erb +10 -0
  36. data/app/views/admin/helpers/search/_search.html.erb +1 -1
  37. data/app/views/admin/helpers/sidebar/_sidebar.html.erb +6 -3
  38. data/app/views/admin/helpers/table/_table.html.erb +17 -5
  39. data/app/views/admin/mailer/reset_password_link.text.erb +2 -2
  40. data/app/views/admin/resources/_form.html.erb +3 -12
  41. data/app/views/admin/resources/edit.html.erb +7 -5
  42. data/app/views/admin/resources/index.html.erb +13 -18
  43. data/app/views/admin/resources/new.html.erb +4 -4
  44. data/app/views/admin/resources/show.html.erb +9 -13
  45. data/app/views/admin/session/new.html.erb +8 -4
  46. data/app/views/admin/templates/_belongs_to.html.erb +1 -1
  47. data/app/views/admin/templates/_boolean.html.erb +2 -2
  48. data/app/views/admin/templates/_date.html.erb +2 -2
  49. data/app/views/admin/templates/_datetime.html.erb +2 -2
  50. data/app/views/admin/templates/_file.html.erb +3 -19
  51. data/app/views/admin/templates/_has_n.html.erb +4 -4
  52. data/app/views/admin/templates/_has_one.html.erb +14 -0
  53. data/app/views/admin/templates/_password.html.erb +2 -2
  54. data/app/views/admin/templates/_profile_sidebar.html.erb +3 -0
  55. data/app/views/admin/templates/_relate_form.html.erb +2 -1
  56. data/app/views/admin/templates/_selector.html.erb +1 -1
  57. data/app/views/admin/templates/_string.html.erb +6 -6
  58. data/app/views/admin/templates/_text.html.erb +11 -4
  59. data/app/views/admin/templates/_time.html.erb +2 -2
  60. data/app/views/admin/templates/_tree.html.erb +1 -1
  61. data/app/views/layouts/admin/base.html.erb +7 -6
  62. data/app/views/layouts/admin/session.html.erb +4 -14
  63. data/config/{available_locales/ca_models.yml → locales/typus.ca.models.yml} +5 -4
  64. data/config/locales/typus.ca.yml +81 -0
  65. data/config/{available_locales/de_models.yml → locales/typus.de.models.yml} +6 -2
  66. data/config/locales/typus.de.yml +80 -0
  67. data/config/locales/typus.el.models.yml +17 -0
  68. data/config/locales/typus.el.yml +82 -0
  69. data/config/{available_locales/es_models.yml → locales/typus.es.models.yml} +9 -4
  70. data/config/locales/typus.es.yml +82 -0
  71. data/config/{available_locales/fr_models.yml → locales/typus.fr.models.yml} +8 -3
  72. data/config/locales/typus.fr.yml +87 -0
  73. data/config/{available_locales/hu_models.yml → locales/typus.hu.models.yml} +6 -2
  74. data/config/locales/typus.hu.yml +80 -0
  75. data/config/{available_locales/it_models.yml → locales/typus.it.models.yml} +7 -4
  76. data/config/locales/typus.it.yml +89 -0
  77. data/config/{available_locales/language_models.yml.template → locales/typus.locale.models.yml.template} +8 -4
  78. data/config/locales/typus.locale.yml.template +81 -0
  79. data/config/{available_locales/pt-BR_models.yml → locales/typus.pt-BR.models.yml} +6 -2
  80. data/config/locales/typus.pt-BR.yml +80 -0
  81. data/config/{available_locales/ru_models.yml → locales/typus.ru.models.yml} +6 -2
  82. data/config/locales/typus.ru.yml +80 -0
  83. data/config/locales/typus.zh-CN.models.yml +17 -0
  84. data/config/locales/typus.zh-CN.yml +79 -0
  85. data/config/routes.rb +11 -7
  86. data/lib/generators/templates/config/initializers/typus.rb +8 -5
  87. data/lib/generators/templates/config/initializers/typus_resources.rb +0 -3
  88. data/lib/generators/templates/config/typus/README +6 -6
  89. data/lib/generators/templates/config/typus/typus.yml +5 -5
  90. data/lib/generators/templates/controller.rb +1 -1
  91. data/lib/generators/templates/migration.rb +1 -0
  92. data/lib/generators/templates/public/admin/javascripts/application.js +0 -4
  93. data/lib/generators/templates/public/admin/javascripts/jquery-1.4.4.min.js +167 -0
  94. data/lib/generators/templates/public/admin/javascripts/jquery.application.js +16 -0
  95. data/lib/generators/templates/public/admin/javascripts/jquery.rails.js +50 -22
  96. data/lib/generators/templates/public/admin/stylesheets/screen.css +43 -34
  97. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_loading.png +0 -0
  98. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.easing-1.3.pack.js +32 -32
  99. data/lib/generators/templates/public/admin/vendor/fancybox/{jquery.fancybox-1.3.1.css → jquery.fancybox-1.3.4.css} +359 -363
  100. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.4.js +1156 -0
  101. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.4.pack.js +46 -0
  102. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.mousewheel-3.0.4.pack.js +14 -0
  103. data/lib/generators/typus/assets_generator.rb +23 -0
  104. data/lib/generators/typus/controller_generator.rb +29 -0
  105. data/lib/generators/typus/migration_generator.rb +39 -20
  106. data/lib/generators/typus/typus_generator.rb +17 -57
  107. data/lib/generators/typus/views_generator.rb +2 -6
  108. data/lib/support/active_record.rb +8 -20
  109. data/lib/support/fake_user.rb +6 -1
  110. data/lib/support/hash.rb +1 -2
  111. data/lib/support/object.rb +4 -17
  112. data/lib/support/string.rb +34 -3
  113. data/lib/tasks/typus.rake +1 -1
  114. data/lib/typus.rb +60 -48
  115. data/lib/typus/actions.rb +27 -0
  116. data/lib/typus/authentication/base.rb +3 -4
  117. data/lib/typus/authentication/http_basic.rb +1 -1
  118. data/lib/typus/authentication/none.rb +1 -1
  119. data/lib/typus/authentication/session.rb +53 -108
  120. data/lib/typus/configuration.rb +13 -11
  121. data/lib/typus/filters.rb +12 -0
  122. data/lib/typus/format.rb +9 -13
  123. data/lib/typus/i18n.rb +30 -0
  124. data/lib/typus/orm/active_record.rb +97 -194
  125. data/lib/typus/orm/active_record/search.rb +91 -0
  126. data/lib/typus/resources.rb +6 -10
  127. data/lib/typus/user.rb +20 -40
  128. data/lib/typus/version.rb +1 -1
  129. metadata +77 -231
  130. data/CHANGELOG +0 -102
  131. data/README.rdoc +0 -48
  132. data/app/helpers/admin/preview_helper.rb +0 -46
  133. data/app/views/admin/helpers/_preview.html.erb +0 -13
  134. data/app/views/admin/templates/_has_many.html.erb +0 -22
  135. data/config/available_locales/ca.yml +0 -122
  136. data/config/available_locales/de.yml +0 -122
  137. data/config/available_locales/es.yml +0 -122
  138. data/config/available_locales/fr.yml +0 -127
  139. data/config/available_locales/hu.yml +0 -122
  140. data/config/available_locales/it.yml +0 -132
  141. data/config/available_locales/language.yml.template +0 -120
  142. data/config/available_locales/pt-BR.yml +0 -122
  143. data/config/available_locales/ru.yml +0 -122
  144. data/lib/generators/templates/functional_test.rb +0 -10
  145. data/lib/generators/templates/model.rb +0 -8
  146. data/lib/generators/templates/public/admin/images/ui-icons.png +0 -0
  147. data/lib/generators/templates/public/admin/javascripts/jquery-1.4.2.min.js +0 -154
  148. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.js +0 -1077
  149. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
  150. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.mousewheel-3.0.2.pack.js +0 -13
  151. data/lib/typus/pagination.rb +0 -18
  152. data/test/factories.rb +0 -43
  153. data/test/fixtures/config/broken/application.yml +0 -68
  154. data/test/fixtures/config/broken/application_roles.yml +0 -20
  155. data/test/fixtures/config/broken/empty.yml +0 -0
  156. data/test/fixtures/config/broken/empty_roles.yml +0 -0
  157. data/test/fixtures/config/broken/undefined.yml +0 -3
  158. data/test/fixtures/config/broken/undefined_roles.yml +0 -6
  159. data/test/fixtures/config/default/typus.yml +0 -13
  160. data/test/fixtures/config/default/typus_roles.yml +0 -2
  161. data/test/fixtures/config/empty/empty_01.yml +0 -0
  162. data/test/fixtures/config/empty/empty_01_roles.yml +0 -0
  163. data/test/fixtures/config/empty/empty_02.yml +0 -0
  164. data/test/fixtures/config/empty/empty_02_roles.yml +0 -0
  165. data/test/fixtures/config/locales/es.yml +0 -10
  166. data/test/fixtures/config/namespaced/application.yml +0 -5
  167. data/test/fixtures/config/namespaced/application_roles.yml +0 -2
  168. data/test/fixtures/config/ordered/001_roles.yml +0 -2
  169. data/test/fixtures/config/ordered/002_roles.yml +0 -2
  170. data/test/fixtures/config/unordered/app_one_roles.yml +0 -2
  171. data/test/fixtures/config/unordered/app_two_roles.yml +0 -2
  172. data/test/fixtures/config/working/application.yml +0 -73
  173. data/test/fixtures/config/working/application_roles.yml +0 -24
  174. data/test/fixtures/config/working/typus.yml +0 -13
  175. data/test/fixtures/config/working/typus_roles.yml +0 -2
  176. data/test/fixtures/rails_app/Rakefile +0 -7
  177. data/test/fixtures/rails_app/app/controllers/admin/assets_controller.rb +0 -2
  178. data/test/fixtures/rails_app/app/controllers/admin/categories_controller.rb +0 -2
  179. data/test/fixtures/rails_app/app/controllers/admin/comments_controller.rb +0 -2
  180. data/test/fixtures/rails_app/app/controllers/admin/pages_controller.rb +0 -2
  181. data/test/fixtures/rails_app/app/controllers/admin/pictures_controller.rb +0 -2
  182. data/test/fixtures/rails_app/app/controllers/admin/posts_controller.rb +0 -2
  183. data/test/fixtures/rails_app/app/controllers/admin/status_controller.rb +0 -2
  184. data/test/fixtures/rails_app/app/controllers/admin/typus_users_controller.rb +0 -2
  185. data/test/fixtures/rails_app/app/controllers/admin/watch_dog_controller.rb +0 -2
  186. data/test/fixtures/rails_app/app/controllers/application_controller.rb +0 -3
  187. data/test/fixtures/rails_app/app/models/asset.rb +0 -5
  188. data/test/fixtures/rails_app/app/models/category.rb +0 -11
  189. data/test/fixtures/rails_app/app/models/comment.rb +0 -6
  190. data/test/fixtures/rails_app/app/models/custom_user.rb +0 -2
  191. data/test/fixtures/rails_app/app/models/delayed/task.rb +0 -5
  192. data/test/fixtures/rails_app/app/models/page.rb +0 -5
  193. data/test/fixtures/rails_app/app/models/picture.rb +0 -6
  194. data/test/fixtures/rails_app/app/models/post.rb +0 -21
  195. data/test/fixtures/rails_app/app/models/typus_user.rb +0 -8
  196. data/test/fixtures/rails_app/app/models/view.rb +0 -5
  197. data/test/fixtures/rails_app/app/views/admin/categories/_form.html.erb +0 -1
  198. data/test/fixtures/rails_app/app/views/admin/dashboard/_sidebar.html.erb +0 -1
  199. data/test/fixtures/rails_app/app/views/admin/mailer/reset_password_link.text.erb +0 -6
  200. data/test/fixtures/rails_app/app/views/admin/posts/_edit.html.erb +0 -1
  201. data/test/fixtures/rails_app/app/views/admin/posts/_index.html.erb +0 -1
  202. data/test/fixtures/rails_app/app/views/admin/posts/_new.html.erb +0 -1
  203. data/test/fixtures/rails_app/app/views/admin/posts/_show.html.erb +0 -1
  204. data/test/fixtures/rails_app/app/views/admin/posts/_sidebar.html.erb +0 -1
  205. data/test/fixtures/rails_app/app/views/admin/resources/_sidebar.html.erb +0 -1
  206. data/test/fixtures/rails_app/app/views/admin/status/index.html.erb +0 -1
  207. data/test/fixtures/rails_app/app/views/admin/templates/_datepicker.html.erb +0 -1
  208. data/test/fixtures/rails_app/config.ru +0 -4
  209. data/test/fixtures/rails_app/config/application.rb +0 -53
  210. data/test/fixtures/rails_app/config/boot.rb +0 -13
  211. data/test/fixtures/rails_app/config/database.yml +0 -14
  212. data/test/fixtures/rails_app/config/environment.rb +0 -5
  213. data/test/fixtures/rails_app/config/environments/test.rb +0 -34
  214. data/test/fixtures/rails_app/config/initializers/secret_token.rb +0 -7
  215. data/test/fixtures/rails_app/config/initializers/session_store.rb +0 -8
  216. data/test/fixtures/rails_app/config/initializers/typus.rb +0 -6
  217. data/test/fixtures/rails_app/config/routes.rb +0 -5
  218. data/test/fixtures/rails_app/config/typus/application.yml +0 -79
  219. data/test/fixtures/rails_app/config/typus/application_roles.yml +0 -25
  220. data/test/fixtures/rails_app/config/typus/typus.yml +0 -12
  221. data/test/fixtures/rails_app/config/typus/typus_roles.yml +0 -2
  222. data/test/fixtures/rails_app/db/test.sqlite3 +0 -0
  223. data/test/fixtures/rails_app/tmp/export-posts-20101012213057.csv +0 -2
  224. data/test/fixtures/rails_app/tmp/export-posts-20101012213132.csv +0 -2
  225. data/test/fixtures/rails_app/tmp/export-posts-20101012213234.csv +0 -2
  226. data/test/fixtures/rails_app/tmp/export-posts-20101012213506.csv +0 -2
  227. data/test/fixtures/rails_app/tmp/export-posts-20101012215057.csv +0 -2
  228. data/test/fixtures/rails_app/tmp/export-posts-20101012215217.csv +0 -2
  229. data/test/fixtures/rails_app/tmp/export-posts-20101012215415.csv +0 -2
  230. data/test/fixtures/rails_app/tmp/export-posts-20101012215443.csv +0 -2
  231. data/test/fixtures/rails_app/tmp/export-posts-20101012215509.csv +0 -2
  232. data/test/fixtures/rails_app/tmp/export-posts-20101012215528.csv +0 -2
  233. data/test/fixtures/rails_app/tmp/export-posts-20101012215551.csv +0 -2
  234. data/test/fixtures/rails_app/tmp/export-posts-20101012215615.csv +0 -2
  235. data/test/fixtures/rails_app/tmp/export-posts-20101012215640.csv +0 -2
  236. data/test/fixtures/rails_app/tmp/export-posts-20101012215714.csv +0 -2
  237. data/test/fixtures/rails_app/tmp/export-posts-20101012215744.csv +0 -2
  238. data/test/fixtures/rails_app/tmp/export-posts-20101012215814.csv +0 -2
  239. data/test/fixtures/rails_app/tmp/export-posts-20101012215836.csv +0 -2
  240. data/test/fixtures/rails_app/tmp/export-posts-20101012215906.csv +0 -2
  241. data/test/fixtures/rails_app/tmp/export-posts-20101012220659.csv +0 -2
  242. data/test/fixtures/rails_app/tmp/export-posts-20101012221043.csv +0 -2
  243. data/test/fixtures/rails_app/tmp/export-posts-20101012221258.csv +0 -2
  244. data/test/fixtures/rails_app/tmp/export-posts-20101012222558.csv +0 -2
  245. data/test/fixtures/rails_app/tmp/export-posts-20101012222752.csv +0 -2
  246. data/test/fixtures/rails_app/tmp/export-posts-20101012222848.csv +0 -2
  247. data/test/fixtures/rails_app/tmp/export-posts-20101012223433.csv +0 -2
  248. data/test/fixtures/rails_app/tmp/export-posts-20101012223535.csv +0 -2
  249. data/test/fixtures/rails_app/tmp/export-posts-20101012224003.csv +0 -2
  250. data/test/fixtures/rails_app/tmp/export-posts-20101012224052.csv +0 -2
  251. data/test/fixtures/rails_app/tmp/export-posts-20101012224109.csv +0 -2
  252. data/test/fixtures/rails_app/tmp/export-posts-20101012224139.csv +0 -2
  253. data/test/fixtures/rails_app/tmp/export-posts-20101012224205.csv +0 -2
  254. data/test/fixtures/rails_app/tmp/export-posts-20101012224243.csv +0 -2
  255. data/test/fixtures/rails_app/tmp/export-posts-20101012225119.csv +0 -2
  256. data/test/fixtures/rails_app/tmp/export-posts-20101013063215.csv +0 -2
  257. data/test/fixtures/rails_app/tmp/export-posts-20101013063300.csv +0 -2
  258. data/test/fixtures/rails_app/tmp/export-posts-20101013063352.csv +0 -2
  259. data/test/fixtures/rails_app/tmp/export-posts-20101013063427.csv +0 -2
  260. data/test/fixtures/rails_app/tmp/export-posts-20101013063448.csv +0 -2
  261. data/test/fixtures/rails_app/tmp/export-posts-20101013063530.csv +0 -2
  262. data/test/fixtures/rails_app/tmp/export-posts-20101013063559.csv +0 -2
  263. data/test/fixtures/rails_app/tmp/export-posts-20101013063646.csv +0 -2
  264. data/test/fixtures/rails_app/tmp/export-posts-20101013063737.csv +0 -2
  265. data/test/fixtures/rails_app/tmp/export-posts-20101013063822.csv +0 -2
  266. data/test/fixtures/rails_app/tmp/export-posts-20101013063837.csv +0 -2
  267. data/test/fixtures/rails_app/tmp/export-posts-20101013063919.csv +0 -2
  268. data/test/fixtures/rails_app/tmp/export-posts-20101013063939.csv +0 -2
  269. data/test/fixtures/rails_app/tmp/export-posts-20101013063952.csv +0 -2
  270. data/test/fixtures/rails_app/tmp/export-posts-20101013064220.csv +0 -2
  271. data/test/fixtures/rails_app/tmp/export-posts-20101013064253.csv +0 -2
  272. data/test/fixtures/rails_app/tmp/export-posts-20101013064318.csv +0 -2
  273. data/test/fixtures/rails_app/tmp/export-posts-20101013064404.csv +0 -2
  274. data/test/fixtures/rails_app/tmp/export-posts-20101013064452.csv +0 -2
  275. data/test/fixtures/rails_app/tmp/export-posts-20101013064536.csv +0 -2
  276. data/test/fixtures/rails_app/tmp/export-posts-20101013064652.csv +0 -2
  277. data/test/fixtures/rails_app/tmp/export-posts-20101013064845.csv +0 -2
  278. data/test/fixtures/rails_app/tmp/export-posts-20101013065023.csv +0 -2
  279. data/test/fixtures/rails_app/tmp/export-posts-20101013065137.csv +0 -2
  280. data/test/fixtures/rails_app/tmp/export-posts-20101013065713.csv +0 -2
  281. data/test/fixtures/rails_app/tmp/export-posts-20101013065954.csv +0 -2
  282. data/test/fixtures/rails_app/tmp/export-posts-20101013070057.csv +0 -2
  283. data/test/fixtures/rails_app/tmp/export-posts-20101013070116.csv +0 -2
  284. data/test/fixtures/rails_app/tmp/export-posts-20101013070156.csv +0 -2
  285. data/test/fixtures/rails_app/tmp/export-posts-20101013070349.csv +0 -2
  286. data/test/fixtures/rails_app/tmp/export-posts-20101013070429.csv +0 -2
  287. data/test/fixtures/rails_app/tmp/export-posts-20101013070448.csv +0 -2
  288. data/test/fixtures/rails_app/tmp/export-posts-20101013070514.csv +0 -2
  289. data/test/fixtures/rails_app/tmp/export-posts-20101013070709.csv +0 -2
  290. data/test/fixtures/rails_app/tmp/export-posts-20101013070745.csv +0 -2
  291. data/test/fixtures/rails_app/tmp/export-posts-20101013070809.csv +0 -2
  292. data/test/fixtures/rails_app/tmp/export-posts-20101013070905.csv +0 -2
  293. data/test/fixtures/rails_app/tmp/export-posts-20101013070955.csv +0 -2
  294. data/test/fixtures/rails_app/tmp/export-posts-20101013071116.csv +0 -2
  295. data/test/fixtures/rails_app/tmp/export-posts-20101013071209.csv +0 -2
  296. data/test/fixtures/rails_app/tmp/export-posts-20101013071335.csv +0 -2
  297. data/test/fixtures/rails_app/tmp/export-posts-20101013071632.csv +0 -2
  298. data/test/fixtures/rails_app/tmp/export-posts-20101013071643.csv +0 -2
  299. data/test/fixtures/rails_app/tmp/export-posts-20101013071735.csv +0 -2
  300. data/test/fixtures/rails_app/tmp/export-posts-20101013071749.csv +0 -2
  301. data/test/fixtures/rails_app/tmp/export-posts-20101013072030.csv +0 -2
  302. data/test/fixtures/rails_app/tmp/export-posts-20101013072050.csv +0 -2
  303. data/test/fixtures/rails_app/tmp/export-posts-20101013072108.csv +0 -2
  304. data/test/fixtures/rails_app/tmp/export-posts-20101013072713.csv +0 -2
  305. data/test/fixtures/rails_app/tmp/export-posts-20101013072751.csv +0 -2
  306. data/test/fixtures/rails_app/tmp/export-posts-20101013072912.csv +0 -2
  307. data/test/fixtures/rails_app/tmp/export-posts-20101013074546.csv +0 -2
  308. data/test/fixtures/rails_app/tmp/export-posts-20101018180512.csv +0 -2
  309. data/test/fixtures/rails_app/tmp/export-posts-20101018183359.csv +0 -2
  310. data/test/fixtures/rails_app/tmp/export-posts-20101018183608.csv +0 -2
  311. data/test/fixtures/rails_app/tmp/export-posts-20101018183759.csv +0 -2
  312. data/test/functional/admin/account_controller_test.rb +0 -90
  313. data/test/functional/admin/assets_controller_test.rb +0 -55
  314. data/test/functional/admin/categories_controller_test.rb +0 -62
  315. data/test/functional/admin/comments_controller_test.rb +0 -21
  316. data/test/functional/admin/dashboard_controller_test.rb +0 -138
  317. data/test/functional/admin/posts_controller_test.rb +0 -548
  318. data/test/functional/admin/session_controller_test.rb +0 -85
  319. data/test/functional/admin/status_controller_test.rb +0 -46
  320. data/test/functional/admin/typus_users_controller_test.rb +0 -159
  321. data/test/helpers/admin/base_helper_test.rb +0 -67
  322. data/test/helpers/admin/dashboard_helper_test.rb +0 -19
  323. data/test/helpers/admin/form_helper_test.rb +0 -117
  324. data/test/helpers/admin/resources_helper_test.rb +0 -64
  325. data/test/helpers/admin/sidebar_helper_test.rb +0 -274
  326. data/test/helpers/admin/table_helper_test.rb +0 -219
  327. data/test/integration/login_test.rb +0 -13
  328. data/test/integration_test_helper.rb +0 -21
  329. data/test/lib/support/active_record_test.rb +0 -86
  330. data/test/lib/support/array_test.rb +0 -11
  331. data/test/lib/support/hash_test.rb +0 -11
  332. data/test/lib/support/string_test.rb +0 -39
  333. data/test/lib/typus/active_record_test.rb +0 -451
  334. data/test/lib/typus/configuration_test.rb +0 -52
  335. data/test/lib/typus/resource_test.rb +0 -17
  336. data/test/lib/typus/routes_test.rb +0 -29
  337. data/test/lib/typus_test.rb +0 -107
  338. data/test/schema.rb +0 -100
  339. data/test/test_helper.rb +0 -16
  340. data/test/unit/admin/mailer_test.rb +0 -32
  341. data/test/unit/typus_user_roles_test.rb +0 -105
  342. data/test/unit/typus_user_test.rb +0 -142
  343. data/typus.gemspec +0 -25
@@ -1,8 +1,8 @@
1
1
  class Admin::SessionController < Admin::BaseController
2
2
 
3
3
  skip_before_filter :reload_config_and_roles
4
- skip_before_filter :set_preferences
5
4
  skip_before_filter :authenticate
5
+ skip_before_filter :set_locale
6
6
 
7
7
  before_filter :create_an_account?, :except => [:destroy]
8
8
 
@@ -12,15 +12,14 @@ class Admin::SessionController < Admin::BaseController
12
12
  def create
13
13
  user = Typus.user_class.authenticate(params[:typus_user][:email], params[:typus_user][:password])
14
14
 
15
- if user
16
- session[:typus_user_id] = user.id
17
- path = params[:back_to] || admin_dashboard_path
18
- else
19
- alert = _t("The email and/or password you entered is invalid.")
20
- path = new_admin_session_path(:back_to => params[:back_to])
21
- end
15
+ path = if user
16
+ session[:typus_user_id] = user.id
17
+ params[:back_to] || admin_dashboard_path
18
+ else
19
+ new_admin_session_path(:back_to => params[:back_to])
20
+ end
22
21
 
23
- redirect_to path, :alert => alert
22
+ redirect_to path
24
23
  end
25
24
 
26
25
  def destroy
@@ -2,16 +2,6 @@ module Admin
2
2
 
3
3
  module BaseHelper
4
4
 
5
- def typus_render(*args)
6
- options = args.extract_options!
7
- options[:resource] ||= @resource.to_resource
8
-
9
- template_file = Rails.root.join("app", "views", "admin", options[:resource], "_#{options[:partial]}.html.erb")
10
- resource = File.exists?(template_file) ? options[:resource] : "resources"
11
-
12
- render "admin/#{resource}/#{options[:partial]}", :options => options
13
- end
14
-
15
5
  def title(page_title)
16
6
  content_for(:title) { page_title }
17
7
  end
@@ -20,33 +10,28 @@ module Admin
20
10
  render "admin/helpers/header"
21
11
  end
22
12
 
13
+ def has_root_path?
14
+ Rails.application.routes.routes.map(&:name).include?("root")
15
+ end
16
+
23
17
  def apps
24
18
  render "admin/helpers/apps"
25
19
  end
26
20
 
27
21
  def login_info
28
- return if [:none, :http_basic].include?(Typus.authentication)
29
-
30
- admin_edit_typus_user_path = { :controller => "/admin/#{Typus.user_class.to_resource}",
31
- :action => 'edit',
32
- :id => current_user.id }
33
-
34
- message = _t("Are you sure you want to sign out and end your session?")
35
-
36
- user_details = if current_user.can?('edit', Typus.user_class_name)
37
- link_to current_user.name, admin_edit_typus_user_path
38
- else
39
- current_user.name
40
- end
41
-
42
- render "admin/helpers/login_info", :message => message, :user_details => user_details
22
+ unless admin_user.is_a?(FakeUser)
23
+ render "admin/helpers/login_info"
24
+ end
43
25
  end
44
26
 
45
27
  def display_flash_message(message = flash)
46
- return if message.empty?
47
- render "admin/helpers/flash_message", :flash_type => message.keys.first, :message => message
28
+ if message.compact.any?
29
+ render "admin/helpers/flash_message",
30
+ :flash_type => message.keys.first,
31
+ :message => message
32
+ end
48
33
  end
49
34
 
50
35
  end
51
36
 
52
- end
37
+ end
@@ -3,20 +3,14 @@ module Admin
3
3
  module DashboardHelper
4
4
 
5
5
  def applications
6
- render File.join(path, "applications")
6
+ render "admin/helpers/dashboard/applications"
7
7
  end
8
8
 
9
- def resources(current_user)
9
+ def resources(admin_user)
10
10
  available = Typus.resources.map do |resource|
11
- resource if current_user.resources.include?(resource)
11
+ resource if admin_user.resources.include?(resource)
12
12
  end.compact
13
- render File.join(path, "resources"), :resources => available
14
- end
15
-
16
- private
17
-
18
- def path
19
- "admin/helpers/dashboard"
13
+ render "admin/helpers/dashboard/resources", :resources => available
20
14
  end
21
15
 
22
16
  end
@@ -0,0 +1,70 @@
1
+ module Admin
2
+
3
+ module FilePreviewHelper
4
+
5
+ def get_type_of_attachment(attachment)
6
+ if defined?(Paperclip) && attachment.is_a?(Paperclip::Attachment)
7
+ :paperclip
8
+ elsif defined?(Dragonfly) && attachment.is_a?(Dragonfly::ActiveModelExtensions::Attachment)
9
+ :dragonfly
10
+ end
11
+ end
12
+
13
+ def link_to_detach_attribute(attribute)
14
+ validators = @item.class.validators.delete_if { |i| i.class != ActiveModel::Validations::PresenceValidator }.map { |i| i.attributes.to_s }.flatten
15
+
16
+ attachment = @item.send(attribute)
17
+
18
+ field = case get_type_of_attachment(attachment)
19
+ when :dragonfly then attribute
20
+ when :paperclip then "#{attribute}_file_name"
21
+ end
22
+
23
+ if !validators.include?(field) && attachment
24
+ attribute_i18n = @item.class.human_attribute_name(attribute)
25
+ message = Typus::I18n.t("Remove")
26
+ label_text = <<-HTML
27
+ #{attribute_i18n}
28
+ <small>#{link_to message, { :action => 'detach', :id => @item.id, :attribute => attribute }, :confirm => Typus::I18n.t("Are you sure?")}</small>
29
+ HTML
30
+ label_text.html_safe
31
+ end
32
+ end
33
+
34
+ def typus_file_preview(item, attribute)
35
+ if (attachment = item.send(attribute))
36
+ case get_type_of_attachment(attachment)
37
+ when :dragonfly
38
+ typus_file_preview_for_dragonfly(attachment)
39
+ when :paperclip
40
+ typus_file_preview_for_paperclip(attachment)
41
+ end
42
+ end
43
+ end
44
+
45
+ def typus_file_preview_for_dragonfly(attachment)
46
+ if attachment.mime_type =~ /^image\/.+/
47
+ render "admin/helpers/file_preview",
48
+ :preview => attachment.process(:thumb, Typus.image_preview_size).url,
49
+ :thumb => attachment.process(:thumb, Typus.image_thumb_size).url
50
+ else
51
+ link_to attachment.name, attachment.url
52
+ end
53
+ end
54
+
55
+ def typus_file_preview_for_paperclip(attachment)
56
+ if attachment.exists?
57
+ styles = attachment.styles.keys
58
+ if styles.include?(Typus.file_preview) && styles.include?(Typus.file_thumbnail)
59
+ render "admin/helpers/file_preview",
60
+ :preview => attachment.url(Typus.file_preview, false),
61
+ :thumb => attachment.url(Typus.file_thumbnail, false)
62
+ else
63
+ link_to attachment.original_filename, attachment.url(:original, false)
64
+ end
65
+ end
66
+ end
67
+
68
+ end
69
+
70
+ end
@@ -7,24 +7,19 @@ module Admin
7
7
 
8
8
  return if typus_filters.empty?
9
9
 
10
- current_request = request.env['QUERY_STRING'] || []
11
-
12
10
  filters = typus_filters.map do |key, value|
13
- filter, items, message = case value
14
- when :boolean then boolean_filter(current_request, key)
15
- when :string then string_filter(current_request, key)
16
- when :date, :datetime then date_filter(current_request, key)
17
- when :belongs_to then relationship_filter(current_request, key)
18
- when :has_many, :has_and_belongs_to_many then
19
- relationship_filter(current_request, key, true)
20
- # when nil then
21
- # Do nothing. This is ugly but for now it's ok.
22
- else
23
- string_filter(current_request, key)
24
- end
25
-
26
- items = items.to_a
27
- items.insert(0, [message, ""])
11
+ items = case value
12
+ when :boolean then boolean_filter(key)
13
+ when :string then string_filter(key)
14
+ when :date, :datetime then date_filter(key)
15
+ when :belongs_to then belongs_to_filter(key)
16
+ when :has_many, :has_and_belongs_to_many then
17
+ has_many_filter(key)
18
+ else
19
+ string_filter(key)
20
+ end
21
+
22
+ filter = set_filter(key, value)
28
23
 
29
24
  { :filter => filter, :items => items }
30
25
  end
@@ -32,46 +27,70 @@ module Admin
32
27
  render "admin/helpers/filters/filters", :filters => filters
33
28
  end
34
29
 
35
- def relationship_filter(request, filter, habtm = false)
30
+ def set_filter(key, value)
31
+ case value
32
+ when :belongs_to
33
+ att_assoc = @resource.reflect_on_association(key.to_sym)
34
+ class_name = att_assoc.options[:class_name] || key.capitalize.camelize
35
+ resource = class_name.typus_constantize
36
+ att_assoc.primary_key_name
37
+ else
38
+ key
39
+ end
40
+ end
41
+
42
+ def belongs_to_filter(filter)
36
43
  att_assoc = @resource.reflect_on_association(filter.to_sym)
37
- class_name = att_assoc.options[:class_name] || ((habtm) ? filter.classify : filter.capitalize.camelize)
38
- model = class_name.constantize
39
- related_fk = (habtm) ? filter : att_assoc.primary_key_name
44
+ class_name = att_assoc.options[:class_name] || filter.capitalize.camelize
45
+ resource = class_name.typus_constantize
40
46
 
41
- params_without_filter = params.dup
42
- %w(controller action page).each { |p| params_without_filter.delete(p) }
43
- params_without_filter.delete(related_fk)
47
+ items = [[Typus::I18n.t("View belongs all %{attribute}", :attribute => @resource.human_attribute_name(filter).downcase.pluralize), ""]]
48
+ items += resource.order(resource.typus_order_by).map { |v| [v.to_label, v.id] }
49
+ end
44
50
 
45
- items = model.all(:order => model.typus_order_by).collect{|v| [v.to_label, v.id] }
46
- message = _t("View all %{attribute}", :attribute => @resource.human_attribute_name(filter).downcase.pluralize)
51
+ def has_many_filter(filter)
52
+ att_assoc = @resource.reflect_on_association(filter.to_sym)
53
+ class_name = att_assoc.options[:class_name] || filter.classify
54
+ resource = class_name.typus_constantize
47
55
 
48
- return related_fk, items, message
56
+ items = [[Typus::I18n.t("View all %{attribute}", :attribute => @resource.human_attribute_name(filter).downcase.pluralize), ""]]
57
+ items += resource.order(resource.typus_order_by).map { |v| [v.to_label, v.id] }
49
58
  end
50
59
 
51
- def date_filter(request, filter)
52
- values = %w(today last_few_days last_7_days last_30_days)
53
- items = values.collect {|v| [_t(v.humanize), v ] }
54
- message = _t("Show all dates")
55
- return filter, items, message
60
+ def date_filter(filter)
61
+ values = %w(today last_few_days last_7_days last_30_days)
62
+ items = [[Typus::I18n.t("Show all dates"), ""]]
63
+ items += values.map { |v| [Typus::I18n.t(v.humanize), v] }
56
64
  end
57
65
 
58
- def boolean_filter(request, filter)
59
- items = @resource.typus_boolean(filter)
60
- message = _t("Show by %{attribute}", :attribute => @resource.human_attribute_name(filter).downcase)
61
- return filter, items, message
66
+ def boolean_filter(filter)
67
+ values = @resource.typus_boolean(filter)
68
+ items = [[Typus::I18n.t("Show by %{attribute}", :attribute => @resource.human_attribute_name(filter).downcase), ""]]
69
+ items += values.map { |k, v| [Typus::I18n.t(k.humanize), v] }
62
70
  end
63
71
 
64
- def string_filter(request, filter)
65
- values = @resource::const_get(filter.to_s.upcase)
66
- items = values.kind_of?(Hash) ? values : values.to_hash_with(values)
67
- message = _t("Show by %{attribute}", :attribute => @resource.human_attribute_name(filter).downcase)
68
- return filter, items, message
72
+ def string_filter(filter)
73
+ values = @resource::const_get(filter.to_s.upcase)
74
+
75
+ items = [[Typus::I18n.t("Show by %{attribute}", :attribute => @resource.human_attribute_name(filter).downcase), ""]]
76
+
77
+ array = case values
78
+ when Hash
79
+ values
80
+ when Array
81
+ if values.first.is_a?(Array)
82
+ keys, values = values.map { |i| i.first }, values.map { |i| i.last }
83
+ keys.to_hash_with(values)
84
+ else
85
+ values.to_hash_with(values)
86
+ end
87
+ end
88
+
89
+ items += array.to_a
69
90
  end
70
91
 
71
- def remove_filter_link(filter = request.env['QUERY_STRING'])
72
- return unless filter && !filter.blank?
73
- message = params.compact.include?(:search) ? "search" : "filter"
74
- link_to _t("Remove #{message}")
92
+ def predefined_filters
93
+ @predefined_filters ||= [["All", "index", "unscoped"]]
75
94
  end
76
95
 
77
96
  end
@@ -3,29 +3,23 @@ module Admin
3
3
  module FormHelper
4
4
 
5
5
  def build_form(fields, form)
6
- html = ""
7
-
8
- fields.each do |key, value|
9
-
10
- if template = @resource.typus_template(key)
11
- html << typus_template_field(key, template, form)
12
- next
6
+ String.new.tap do |html|
7
+ fields.each do |key, value|
8
+ value = :template if (template = @resource.typus_template(key))
9
+ html << case value
10
+ when :belongs_to
11
+ typus_belongs_to_field(key, form)
12
+ when :tree
13
+ typus_tree_field(key, form)
14
+ when :boolean, :date, :datetime, :file, :text, :time, :password, :selector
15
+ typus_template_field(key, value, form)
16
+ when :template
17
+ typus_template_field(key, template, form)
18
+ else
19
+ typus_template_field(key, :string, form)
20
+ end
13
21
  end
14
-
15
- html << case value
16
- when :belongs_to
17
- typus_belongs_to_field(key, form)
18
- when :tree
19
- typus_tree_field(key, form)
20
- when :boolean, :date, :datetime, :string, :text, :time,
21
- :file, :password, :selector
22
- typus_template_field(key, value, form)
23
- else
24
- typus_template_field(key, :string, form)
25
- end
26
22
  end
27
-
28
- return html
29
23
  end
30
24
 
31
25
  def typus_tree_field(attribute, form)
@@ -36,44 +30,33 @@ module Admin
36
30
  :values => expand_tree_into_select_field(@resource.roots, "parent_id")
37
31
  end
38
32
 
39
- # OPTIMIZE: Cleanup the case statement.
33
+ # OPTIMIZE: Cleanup the case statement, using some meta-code.
40
34
  def typus_relationships
41
-
42
35
  @back_to = url_for(:controller => params[:controller], :action => params[:action], :id => params[:id])
43
36
 
44
- html = ""
45
-
46
- @resource.typus_defaults_for(:relationships).each do |relationship|
47
-
48
- association = @resource.reflect_on_association(relationship.to_sym)
49
-
50
- next if current_user.cannot?('read', association.class_name.constantize)
51
-
52
- case association.macro
53
- when :has_and_belongs_to_many
54
- html << typus_form_has_and_belongs_to_many(relationship)
55
- when :has_many
56
- if association.options[:through]
57
- # Here we will shot the relationship. Better this than raising an error.
58
- else
59
- html << typus_form_has_many(relationship)
60
- end
61
- when :has_one
62
- html << typus_form_has_one(relationship)
37
+ String.new.tap do |html|
38
+ @resource.typus_defaults_for(:relationships).each do |relationship|
39
+ association = @resource.reflect_on_association(relationship.to_sym)
40
+ next if admin_user.cannot?('read', association.class_name.typus_constantize)
41
+ html << case association.macro
42
+ when :has_and_belongs_to_many
43
+ typus_form_has_and_belongs_to_many(relationship)
44
+ when :has_many
45
+ typus_form_has_many(relationship)
46
+ when :has_one
47
+ typus_form_has_one(relationship)
48
+ when :belongs_to
49
+ ""
50
+ end
63
51
  end
64
-
65
52
  end
66
-
67
- return html
68
-
69
53
  end
70
54
 
71
55
  def typus_template_field(attribute, template, form)
72
-
73
56
  options = { :start_year => @resource.typus_options_for(:start_year),
74
57
  :end_year => @resource.typus_options_for(:end_year),
75
58
  :minute_step => @resource.typus_options_for(:minute_step),
76
- # :disabled => attribute_disabled?(attribute),
59
+ :disabled => attribute_disabled?(attribute),
77
60
  :include_blank => true }
78
61
 
79
62
  render "admin/templates/#{template}",
@@ -83,30 +66,22 @@ module Admin
83
66
  :html_options => {},
84
67
  :form => form,
85
68
  :label_text => @resource.human_attribute_name(attribute)
86
-
87
69
  end
88
70
 
89
- =begin
90
-
91
- # TODO: Take `attribute_disabled?(attribute)` back.
92
71
  def attribute_disabled?(attribute)
93
- accessible = @resource.accessible_attributes
94
- return accessible.nil? ? false : !accessible.include?(attribute)
72
+ @resource.protected_attributes.include?(attribute)
95
73
  end
96
- =end
97
74
 
98
75
  ##
99
76
  # Tree builder when model +acts_as_tree+
100
77
  #
101
78
  def expand_tree_into_select_field(items, attribute)
102
- html = ""
103
-
104
- items.each do |item|
105
- html << %{<option #{"selected" if @item.send(attribute) == item.id} value="#{item.id}">#{"&nbsp;" * item.ancestors.size * 2} &#8627; #{item.to_label}</option>\n}
106
- html << expand_tree_into_select_field(item.children, attribute) unless item.children.empty?
79
+ String.new.tap do |html|
80
+ items.each do |item|
81
+ html << %{<option #{"selected" if @item.send(attribute) == item.id} value="#{item.id}">#{"&nbsp;" * item.ancestors.size * 2} #{item.to_label}</option>\n}
82
+ html << expand_tree_into_select_field(item.children, attribute) unless item.children.empty?
83
+ end
107
84
  end
108
-
109
- return html
110
85
  end
111
86
 
112
87
  end