typus 1.0.0.pre8 → 1.0.0.pre9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (247) hide show
  1. data/CHANGELOG +4 -6
  2. data/Gemfile +16 -13
  3. data/Gemfile.lock +26 -2
  4. data/Rakefile +2 -3
  5. data/app/controllers/admin/base_controller.rb +3 -5
  6. data/app/controllers/admin/resources_controller.rb +24 -26
  7. data/app/helpers/admin/base_helper.rb +14 -22
  8. data/app/helpers/admin/dashboard_helper.rb +2 -5
  9. data/app/helpers/admin/filters_helper.rb +6 -8
  10. data/app/helpers/admin/form_helper.rb +3 -9
  11. data/app/helpers/admin/preview_helper.rb +4 -6
  12. data/app/helpers/admin/relationships_helper.rb +9 -11
  13. data/app/helpers/admin/resources_helper.rb +6 -24
  14. data/app/helpers/admin/search_helper.rb +1 -1
  15. data/app/helpers/admin/sidebar_helper.rb +12 -15
  16. data/app/helpers/admin/table_helper.rb +13 -13
  17. data/app/views/admin/dashboard/show.html.erb +1 -1
  18. data/app/views/admin/helpers/_apps.html.erb +4 -3
  19. data/app/views/admin/helpers/_header.html.erb +2 -2
  20. data/app/views/admin/helpers/dashboard/_applications.html.erb +3 -3
  21. data/app/views/admin/helpers/dashboard/_resources.html.erb +17 -13
  22. data/app/views/admin/helpers/filters/_filters.html.erb +9 -27
  23. data/app/views/admin/helpers/resources/_pagination.html.erb +8 -9
  24. data/app/views/admin/helpers/search/_search.html.erb +1 -1
  25. data/app/views/admin/mailer/reset_password_link.text.erb +3 -0
  26. data/app/views/admin/resources/_form.html.erb +4 -4
  27. data/app/views/admin/resources/edit.html.erb +2 -3
  28. data/app/views/admin/resources/index.html.erb +15 -13
  29. data/app/views/admin/resources/new.html.erb +2 -2
  30. data/app/views/admin/resources/show.html.erb +1 -2
  31. data/app/views/admin/templates/_boolean.html.erb +1 -1
  32. data/app/views/admin/templates/_has_many.html.erb +2 -4
  33. data/app/views/admin/templates/_has_n.html.erb +1 -1
  34. data/app/views/admin/templates/_selector.html.erb +0 -1
  35. data/app/views/admin/templates/_string.html.erb +1 -1
  36. data/app/views/layouts/admin/session.html.erb +1 -1
  37. data/config/available_locales/ca.yml +3 -5
  38. data/config/available_locales/de.yml +2 -4
  39. data/config/available_locales/es.yml +2 -4
  40. data/config/available_locales/fr.yml +40 -39
  41. data/config/available_locales/fr_models.yml +2 -2
  42. data/config/available_locales/hu.yml +3 -5
  43. data/config/available_locales/it.yml +0 -4
  44. data/config/available_locales/language.yml.template +2 -4
  45. data/config/available_locales/pt-BR.yml +2 -4
  46. data/config/available_locales/ru.yml +2 -4
  47. data/config/routes.rb +1 -0
  48. data/lib/generators/templates/config/initializers/typus.rb +5 -5
  49. data/lib/generators/templates/config/initializers/typus_authentication.rb +5 -5
  50. data/lib/generators/templates/config/initializers/typus_resources.rb +7 -7
  51. data/lib/generators/templates/config/typus/README +11 -13
  52. data/lib/generators/templates/controller.rb +0 -2
  53. data/lib/generators/templates/functional_test.rb +4 -15
  54. data/lib/generators/typus/migration_generator.rb +0 -1
  55. data/lib/support/active_record.rb +18 -9
  56. data/lib/support/fake_user.rb +42 -0
  57. data/lib/support/object.rb +1 -0
  58. data/lib/support/string.rb +0 -32
  59. data/lib/tasks/typus.rake +0 -8
  60. data/lib/typus.rb +34 -18
  61. data/lib/typus/authentication/base.rb +26 -0
  62. data/lib/typus/authentication/http_basic.rb +22 -0
  63. data/lib/typus/authentication/none.rb +19 -0
  64. data/lib/typus/authentication/session.rb +190 -0
  65. data/lib/typus/format.rb +12 -19
  66. data/lib/typus/orm/active_record.rb +13 -51
  67. data/lib/typus/resources.rb +0 -9
  68. data/lib/typus/version.rb +1 -1
  69. data/test/factories.rb +43 -0
  70. data/test/fixtures/rails_app/app/controllers/application_controller.rb +0 -1
  71. data/test/fixtures/rails_app/app/models/page.rb +0 -4
  72. data/test/fixtures/rails_app/config/application.rb +6 -3
  73. data/test/fixtures/rails_app/config/database.yml +12 -20
  74. data/test/fixtures/rails_app/config/typus/application.yml +4 -8
  75. data/test/fixtures/rails_app/db/test.sqlite3 +0 -0
  76. data/test/fixtures/rails_app/log/test.log +227115 -0
  77. data/test/fixtures/rails_app/tmp/export-posts-20101012213057.csv +2 -0
  78. data/test/fixtures/rails_app/tmp/export-posts-20101012213132.csv +2 -0
  79. data/test/fixtures/rails_app/tmp/export-posts-20101012213234.csv +2 -0
  80. data/test/fixtures/rails_app/tmp/export-posts-20101012213506.csv +2 -0
  81. data/test/fixtures/rails_app/tmp/export-posts-20101012215057.csv +2 -0
  82. data/test/fixtures/rails_app/tmp/export-posts-20101012215217.csv +2 -0
  83. data/test/fixtures/rails_app/tmp/export-posts-20101012215415.csv +2 -0
  84. data/test/fixtures/rails_app/tmp/export-posts-20101012215443.csv +2 -0
  85. data/test/fixtures/rails_app/tmp/export-posts-20101012215509.csv +2 -0
  86. data/test/fixtures/rails_app/tmp/export-posts-20101012215528.csv +2 -0
  87. data/test/fixtures/rails_app/tmp/export-posts-20101012215551.csv +2 -0
  88. data/test/fixtures/rails_app/tmp/export-posts-20101012215615.csv +2 -0
  89. data/test/fixtures/rails_app/tmp/export-posts-20101012215640.csv +2 -0
  90. data/test/fixtures/rails_app/tmp/export-posts-20101012215714.csv +2 -0
  91. data/test/fixtures/rails_app/tmp/export-posts-20101012215744.csv +2 -0
  92. data/test/fixtures/rails_app/tmp/export-posts-20101012215814.csv +2 -0
  93. data/test/fixtures/rails_app/tmp/export-posts-20101012215836.csv +2 -0
  94. data/test/fixtures/rails_app/tmp/export-posts-20101012215906.csv +2 -0
  95. data/test/fixtures/rails_app/tmp/export-posts-20101012220659.csv +2 -0
  96. data/test/fixtures/rails_app/tmp/export-posts-20101012221043.csv +2 -0
  97. data/test/fixtures/rails_app/tmp/export-posts-20101012221258.csv +2 -0
  98. data/test/fixtures/rails_app/tmp/export-posts-20101012222558.csv +2 -0
  99. data/test/fixtures/rails_app/tmp/export-posts-20101012222752.csv +2 -0
  100. data/test/fixtures/rails_app/tmp/export-posts-20101012222848.csv +2 -0
  101. data/test/fixtures/rails_app/tmp/export-posts-20101012223433.csv +2 -0
  102. data/test/fixtures/rails_app/tmp/export-posts-20101012223535.csv +2 -0
  103. data/test/fixtures/rails_app/tmp/export-posts-20101012224003.csv +2 -0
  104. data/test/fixtures/rails_app/tmp/export-posts-20101012224052.csv +2 -0
  105. data/test/fixtures/rails_app/tmp/export-posts-20101012224109.csv +2 -0
  106. data/test/fixtures/rails_app/tmp/export-posts-20101012224139.csv +2 -0
  107. data/test/fixtures/rails_app/tmp/export-posts-20101012224205.csv +2 -0
  108. data/test/fixtures/rails_app/tmp/export-posts-20101012224243.csv +2 -0
  109. data/test/fixtures/rails_app/tmp/export-posts-20101012225119.csv +2 -0
  110. data/test/fixtures/rails_app/tmp/export-posts-20101013063215.csv +2 -0
  111. data/test/fixtures/rails_app/tmp/export-posts-20101013063300.csv +2 -0
  112. data/test/fixtures/rails_app/tmp/export-posts-20101013063352.csv +2 -0
  113. data/test/fixtures/rails_app/tmp/export-posts-20101013063427.csv +2 -0
  114. data/test/fixtures/rails_app/tmp/export-posts-20101013063448.csv +2 -0
  115. data/test/fixtures/rails_app/tmp/export-posts-20101013063530.csv +2 -0
  116. data/test/fixtures/rails_app/tmp/export-posts-20101013063559.csv +2 -0
  117. data/test/fixtures/rails_app/tmp/export-posts-20101013063646.csv +2 -0
  118. data/test/fixtures/rails_app/tmp/export-posts-20101013063737.csv +2 -0
  119. data/test/fixtures/rails_app/tmp/export-posts-20101013063822.csv +2 -0
  120. data/test/fixtures/rails_app/tmp/export-posts-20101013063837.csv +2 -0
  121. data/test/fixtures/rails_app/tmp/export-posts-20101013063919.csv +2 -0
  122. data/test/fixtures/rails_app/tmp/export-posts-20101013063939.csv +2 -0
  123. data/test/fixtures/rails_app/tmp/export-posts-20101013063952.csv +2 -0
  124. data/test/fixtures/rails_app/tmp/export-posts-20101013064220.csv +2 -0
  125. data/test/fixtures/rails_app/tmp/export-posts-20101013064253.csv +2 -0
  126. data/test/fixtures/rails_app/tmp/export-posts-20101013064318.csv +2 -0
  127. data/test/fixtures/rails_app/tmp/export-posts-20101013064404.csv +2 -0
  128. data/test/fixtures/rails_app/tmp/export-posts-20101013064452.csv +2 -0
  129. data/test/fixtures/rails_app/tmp/export-posts-20101013064536.csv +2 -0
  130. data/test/fixtures/rails_app/tmp/export-posts-20101013064652.csv +2 -0
  131. data/test/fixtures/rails_app/tmp/export-posts-20101013064845.csv +2 -0
  132. data/test/fixtures/rails_app/tmp/export-posts-20101013065023.csv +2 -0
  133. data/test/fixtures/rails_app/tmp/export-posts-20101013065137.csv +2 -0
  134. data/test/fixtures/rails_app/tmp/export-posts-20101013065713.csv +2 -0
  135. data/test/fixtures/rails_app/tmp/export-posts-20101013065954.csv +2 -0
  136. data/test/fixtures/rails_app/tmp/export-posts-20101013070057.csv +2 -0
  137. data/test/fixtures/rails_app/tmp/export-posts-20101013070116.csv +2 -0
  138. data/test/fixtures/rails_app/tmp/export-posts-20101013070156.csv +2 -0
  139. data/test/fixtures/rails_app/tmp/export-posts-20101013070349.csv +2 -0
  140. data/test/fixtures/rails_app/tmp/export-posts-20101013070429.csv +2 -0
  141. data/test/fixtures/rails_app/tmp/export-posts-20101013070448.csv +2 -0
  142. data/test/fixtures/rails_app/tmp/export-posts-20101013070514.csv +2 -0
  143. data/test/fixtures/rails_app/tmp/export-posts-20101013070709.csv +2 -0
  144. data/test/fixtures/rails_app/tmp/export-posts-20101013070745.csv +2 -0
  145. data/test/fixtures/rails_app/tmp/export-posts-20101013070809.csv +2 -0
  146. data/test/fixtures/rails_app/tmp/export-posts-20101013070905.csv +2 -0
  147. data/test/fixtures/rails_app/tmp/export-posts-20101013070955.csv +2 -0
  148. data/test/fixtures/rails_app/tmp/export-posts-20101013071116.csv +2 -0
  149. data/test/fixtures/rails_app/tmp/export-posts-20101013071209.csv +2 -0
  150. data/test/fixtures/rails_app/tmp/export-posts-20101013071335.csv +2 -0
  151. data/test/fixtures/rails_app/tmp/export-posts-20101013071632.csv +2 -0
  152. data/test/fixtures/rails_app/tmp/export-posts-20101013071643.csv +2 -0
  153. data/test/fixtures/rails_app/tmp/export-posts-20101013071735.csv +2 -0
  154. data/test/fixtures/rails_app/tmp/export-posts-20101013071749.csv +2 -0
  155. data/test/fixtures/rails_app/tmp/export-posts-20101013072030.csv +2 -0
  156. data/test/fixtures/rails_app/tmp/export-posts-20101013072050.csv +2 -0
  157. data/test/fixtures/rails_app/tmp/export-posts-20101013072108.csv +2 -0
  158. data/test/fixtures/rails_app/tmp/export-posts-20101013072713.csv +2 -0
  159. data/test/fixtures/rails_app/tmp/export-posts-20101013072751.csv +2 -0
  160. data/test/fixtures/rails_app/tmp/export-posts-20101013072912.csv +2 -0
  161. data/test/fixtures/rails_app/tmp/export-posts-20101013074546.csv +2 -0
  162. data/test/fixtures/rails_app/tmp/export-posts-20101018180512.csv +2 -0
  163. data/test/fixtures/rails_app/tmp/export-posts-20101018183359.csv +2 -0
  164. data/test/fixtures/rails_app/tmp/export-posts-20101018183608.csv +2 -0
  165. data/test/fixtures/rails_app/tmp/export-posts-20101018183759.csv +2 -0
  166. data/test/functional/admin/account_controller_test.rb +1 -1
  167. data/test/functional/admin/{resources_controller_assets_relationships.rb → assets_controller_test.rb} +12 -16
  168. data/test/functional/admin/categories_controller_test.rb +62 -0
  169. data/test/functional/admin/{resources_controller_comments_toggle_test.rb → comments_controller_test.rb} +0 -0
  170. data/test/functional/admin/dashboard_controller_test.rb +34 -2
  171. data/test/functional/admin/posts_controller_test.rb +548 -0
  172. data/test/functional/admin/session_controller_test.rb +2 -2
  173. data/test/functional/admin/{resources_controller_tableless_resource_test.rb → status_controller_test.rb} +0 -0
  174. data/test/functional/admin/{resources_controller_typus_users_test.rb → typus_users_controller_test.rb} +2 -2
  175. data/test/helpers/admin/base_helper_test.rb +35 -37
  176. data/test/helpers/admin/dashboard_helper_test.rb +4 -8
  177. data/test/helpers/admin/form_helper_test.rb +9 -34
  178. data/test/helpers/admin/resources_helper_test.rb +28 -16
  179. data/test/helpers/admin/sidebar_helper_test.rb +14 -27
  180. data/test/helpers/admin/table_helper_test.rb +24 -68
  181. data/test/integration/login_test.rb +13 -0
  182. data/test/integration_test_helper.rb +21 -0
  183. data/test/lib/support/active_record_test.rb +72 -21
  184. data/test/lib/support/array_test.rb +2 -6
  185. data/test/lib/support/string_test.rb +21 -30
  186. data/test/lib/typus/active_record_test.rb +162 -100
  187. data/test/lib/typus/resource_test.rb +2 -3
  188. data/test/lib/typus_test.rb +25 -22
  189. data/test/test_helper.rb +4 -17
  190. data/test/unit/admin/mailer_test.rb +2 -2
  191. data/test/unit/typus_user_roles_test.rb +23 -23
  192. data/test/unit/typus_user_test.rb +30 -24
  193. data/typus.gemspec +0 -1
  194. metadata +111 -60
  195. data/app/models/admin/fake_user.rb +0 -46
  196. data/lib/generators/templates/model.yml +0 -10
  197. data/lib/typus/authentication.rb +0 -241
  198. data/lib/vendor/paginator.rb +0 -143
  199. data/test/factories/assets.rb +0 -5
  200. data/test/factories/categories.rb +0 -3
  201. data/test/factories/comments.rb +0 -6
  202. data/test/factories/pages.rb +0 -5
  203. data/test/factories/pictures.rb +0 -7
  204. data/test/factories/posts.rb +0 -6
  205. data/test/factories/typus_users.rb +0 -8
  206. data/test/fixtures/rails_app/README +0 -244
  207. data/test/fixtures/rails_app/app/helpers/application_helper.rb +0 -2
  208. data/test/fixtures/rails_app/app/views/layouts/application.html.erb +0 -14
  209. data/test/fixtures/rails_app/config/environments/development.rb +0 -19
  210. data/test/fixtures/rails_app/config/environments/production.rb +0 -42
  211. data/test/fixtures/rails_app/config/initializers/acts_as_list.rb +0 -258
  212. data/test/fixtures/rails_app/config/initializers/acts_as_tree.rb +0 -98
  213. data/test/fixtures/rails_app/config/initializers/backtrace_silencers.rb +0 -7
  214. data/test/fixtures/rails_app/config/initializers/inflections.rb +0 -10
  215. data/test/fixtures/rails_app/config/initializers/mime_types.rb +0 -5
  216. data/test/fixtures/rails_app/config/locales/en.yml +0 -5
  217. data/test/fixtures/rails_app/db/seeds.rb +0 -7
  218. data/test/fixtures/rails_app/public/404.html +0 -26
  219. data/test/fixtures/rails_app/public/422.html +0 -26
  220. data/test/fixtures/rails_app/public/500.html +0 -26
  221. data/test/fixtures/rails_app/public/favicon.ico +0 -0
  222. data/test/fixtures/rails_app/public/images/rails.png +0 -0
  223. data/test/fixtures/rails_app/public/index.html +0 -279
  224. data/test/fixtures/rails_app/public/javascripts/application.js +0 -2
  225. data/test/fixtures/rails_app/public/javascripts/controls.js +0 -965
  226. data/test/fixtures/rails_app/public/javascripts/dragdrop.js +0 -974
  227. data/test/fixtures/rails_app/public/javascripts/effects.js +0 -1123
  228. data/test/fixtures/rails_app/public/javascripts/prototype.js +0 -4874
  229. data/test/fixtures/rails_app/public/javascripts/rails.js +0 -118
  230. data/test/fixtures/rails_app/public/robots.txt +0 -5
  231. data/test/fixtures/rails_app/script/rails +0 -9
  232. data/test/functional/admin/dashboard_controller_http_basic_test.rb +0 -24
  233. data/test/functional/admin/dashboard_controller_none_test.rb +0 -18
  234. data/test/functional/admin/resources_controller_categories_before_test.rb +0 -10
  235. data/test/functional/admin/resources_controller_categories_lists_test.rb +0 -44
  236. data/test/functional/admin/resources_controller_categories_views_test.rb +0 -10
  237. data/test/functional/admin/resources_controller_posts_before_test.rb +0 -10
  238. data/test/functional/admin/resources_controller_posts_crud_custom_test.rb +0 -27
  239. data/test/functional/admin/resources_controller_posts_crud_test.rb +0 -44
  240. data/test/functional/admin/resources_controller_posts_formats_test.rb +0 -39
  241. data/test/functional/admin/resources_controller_posts_forms_test.rb +0 -58
  242. data/test/functional/admin/resources_controller_posts_permissions_test.rb +0 -100
  243. data/test/functional/admin/resources_controller_posts_relationships_test.rb +0 -91
  244. data/test/functional/admin/resources_controller_posts_roles.rb +0 -52
  245. data/test/functional/admin/resources_controller_posts_views_test.rb +0 -143
  246. data/test/lib/vendor/paginator_test.rb +0 -141
  247. data/typus-1.0.0.pre7.gem +0 -0
data/CHANGELOG CHANGED
@@ -68,6 +68,10 @@
68
68
  [X] Search fields now support exact match, beginning of the field and
69
69
  full-text match which is the default.
70
70
  [X] Do not depend on Rdiscount when rendering content on resources#show.
71
+ [X] Decide where to put the search box.
72
+ [X] Pagination doesn't work properly when having multiple paginators on edit page
73
+ [X] Generator to copy views to `app/views/admin`.
74
+ [X] Clicking on h1 should open website (root_path) when available.
71
75
 
72
76
  [-] Move html code from helpers to partials.
73
77
  [ ] Add `has_many` through relationships.
@@ -79,16 +83,13 @@
79
83
  [ ] Show auto_generated, read_only on string fields. (_string.html.erb)
80
84
  [ ] Pass options hash to form fields.
81
85
  [ ] Fix css to display correctly "select" fields in relationships.
82
- [ ] Ajax pagination. (?)
83
86
  [ ] Add test for `typus_table_selector`.
84
87
  [ ] Forever loop when schema has not been migrated.
85
- [ ] Pagination doesn't work properly when having multiple paginators on edit page
86
88
  [ ] Add support for `has_one` relationships.
87
89
  [ ] Remove all crappy rescues.
88
90
  [ ] Search in multiple models.
89
91
  [ ] Nested models.
90
92
  [ ] Contextual content depending on the logged user.
91
- [ ] Include dashboard#sidebar in the generator so use can easily overwrite it.
92
93
  [ ] Verify generator is working properly.
93
94
  [ ] Test generator?
94
95
  [ ] Added comment on all FIXME tests. Try to fix them first.
@@ -97,8 +98,5 @@
97
98
  [ ] Convert plugin to engine.
98
99
  [ ] Verify lightbox is working as expected.
99
100
  [ ] Fix footer to the bottom.
100
- [ ] Show sort arrow on hover.
101
- [ ] Clicking on h1 should open website (root_path) when available.
102
101
  [ ] `Typus.applications` should become `Typus.groups`.
103
- [ ] Decide where to put the search box.
104
102
  [ ] Removing an item should redirect to back without the page params.
data/Gemfile CHANGED
@@ -1,17 +1,20 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- # gemspec
4
-
5
- gem "rails", "3.0.0"
6
- gem "fastercsv", "1.5.3"
7
-
8
- gem "sqlite3-ruby"
9
- gem "mysql"
10
- gem "pg"
11
- gem "factory_girl"
12
- gem "acts_as_tree"
13
3
  gem "acts_as_list"
4
+ gem "acts_as_tree"
14
5
  gem "paperclip"
15
- gem "shoulda"
16
- gem "mocha"
17
- gem 'leftright'
6
+ gem "fastercsv", "1.5.3" unless RUBY_VERSION >= '1.9'
7
+ gem "paginator", "1.1.1"
8
+
9
+ group :test do
10
+ gem "capybara"
11
+ gem "factory_girl"
12
+ gem "mysql"
13
+ gem "paperclip"
14
+ gem "pg"
15
+ gem "rails", "3.0.0"
16
+ gem "shoulda"
17
+ gem "sqlite3-ruby"
18
+
19
+ gem "mocha"
20
+ end
data/Gemfile.lock CHANGED
@@ -33,12 +33,25 @@ GEM
33
33
  arel (1.0.1)
34
34
  activesupport (~> 3.0.0)
35
35
  builder (2.1.2)
36
+ capybara (0.3.9)
37
+ culerity (>= 0.2.4)
38
+ mime-types (>= 1.16)
39
+ nokogiri (>= 1.3.3)
40
+ rack (>= 1.0.0)
41
+ rack-test (>= 0.5.4)
42
+ selenium-webdriver (>= 0.0.3)
43
+ culerity (0.2.12)
36
44
  erubis (2.6.6)
37
45
  abstract (>= 1.0.0)
38
46
  factory_girl (1.3.2)
39
47
  fastercsv (1.5.3)
48
+ ffi (0.6.3)
49
+ rake (>= 0.8.7)
50
+ hoe (2.6.2)
51
+ rake (>= 0.8.7)
52
+ rubyforge (>= 2.0.4)
40
53
  i18n (0.4.1)
41
- leftright (0.0.6)
54
+ json_pure (1.4.6)
42
55
  mail (2.2.5)
43
56
  activesupport (>= 2.3.6)
44
57
  mime-types
@@ -47,6 +60,9 @@ GEM
47
60
  mocha (0.9.8)
48
61
  rake
49
62
  mysql (2.8.1)
63
+ nokogiri (1.4.3.1)
64
+ paginator (1.1.1)
65
+ hoe (>= 1.6.0)
50
66
  paperclip (2.3.3)
51
67
  activerecord
52
68
  activesupport
@@ -71,6 +87,13 @@ GEM
71
87
  rake (>= 0.8.4)
72
88
  thor (~> 0.14.0)
73
89
  rake (0.8.7)
90
+ rubyforge (2.0.4)
91
+ json_pure (>= 1.1.7)
92
+ rubyzip (0.9.4)
93
+ selenium-webdriver (0.0.28)
94
+ ffi (>= 0.6.1)
95
+ json_pure
96
+ rubyzip
74
97
  shoulda (2.11.3)
75
98
  sqlite3-ruby (1.3.1)
76
99
  thor (0.14.0)
@@ -84,11 +107,12 @@ PLATFORMS
84
107
  DEPENDENCIES
85
108
  acts_as_list
86
109
  acts_as_tree
110
+ capybara
87
111
  factory_girl
88
112
  fastercsv (= 1.5.3)
89
- leftright
90
113
  mocha
91
114
  mysql
115
+ paginator (= 1.1.1)
92
116
  paperclip
93
117
  pg
94
118
  rails (= 3.0.0)
data/Rakefile CHANGED
@@ -36,10 +36,9 @@ task :release => :build do
36
36
 
37
37
  system "git commit -m 'Bump version to #{Typus::VERSION}' lib/typus/version.rb"
38
38
  system "git tag v#{version}"
39
- system "git push"
40
- system "git push --tags"
39
+ system "git push && git push --tags"
41
40
 
42
41
  system "gem push typus-#{version}.gem"
43
42
 
44
- system "git clean -fd"
43
+ system "git clean -fd && rm -f typus-#{version}.gem"
45
44
  end
@@ -1,20 +1,18 @@
1
- require "typus/authentication"
2
-
3
1
  class Admin::BaseController < ActionController::Base
4
2
 
5
- unloadable
3
+ include Typus::Authentication::const_get(Typus.authentication.to_s.classify)
6
4
 
7
5
  before_filter :reload_config_and_roles
8
6
  before_filter :authenticate
9
7
 
8
+ helper_method :current_user
9
+
10
10
  protected
11
11
 
12
12
  def reload_config_and_roles
13
13
  Typus.reload! unless Rails.env.production?
14
14
  end
15
15
 
16
- include Typus::Authentication
17
-
18
16
  def set_path
19
17
  @back_to || request.referer || admin_dashboard_path
20
18
  end
@@ -26,11 +26,10 @@ class Admin::ResourcesController < Admin::BaseController
26
26
  :only => [ :index, :new, :edit, :create, :update, :show ]
27
27
 
28
28
  ##
29
- # This is the main index of the model. With filters, conditions
30
- # and more.
29
+ # This is the main index of the model. With filters, conditions and more.
31
30
  #
32
- # By default application can respond_to html, csv and xml, but you
33
- # can add your formats.
31
+ # By default application can respond_to html, csv and xml, but you can add
32
+ # your formats.
34
33
  #
35
34
  def index
36
35
  @conditions, @joins = @resource.build_conditions(params)
@@ -55,9 +54,9 @@ class Admin::ResourcesController < Admin::BaseController
55
54
  end
56
55
 
57
56
  ##
58
- # Create new items. There's an special case when we create an
59
- # item from another item. In this case, after the item is
60
- # created we also create the relationship between these items.
57
+ # Create new items. There's an special case when we create an item from
58
+ # another item. In this case, after the item is created we also create the
59
+ # relationship between these items.
61
60
  #
62
61
  def create
63
62
  @item = @resource.new(params[@object_name])
@@ -110,13 +109,12 @@ class Admin::ResourcesController < Admin::BaseController
110
109
  end
111
110
 
112
111
  ##
113
- # Change item position. This only works if acts_as_list is
114
- # installed. We can then move items:
112
+ # Change item position. This only works if acts_as_list is installed. We can
113
+ # then move items:
115
114
  #
116
115
  # params[:go] = 'move_to_top'
117
116
  #
118
- # Available positions are move_to_top, move_higher, move_lower,
119
- # move_to_bottom.
117
+ # Available positions are move_to_top, move_higher, move_lower, move_to_bottom.
120
118
  #
121
119
  def position
122
120
  @item.send(params[:go])
@@ -156,20 +154,24 @@ class Admin::ResourcesController < Admin::BaseController
156
154
 
157
155
  # We consider that we are unrelating a has_many or has_and_belongs_to_many
158
156
 
159
- macro = @resource.reflect_on_association(resource_class.table_name.to_sym).try(:macro)
157
+ reflection = @resource.reflect_on_association(resource_class.table_name.to_sym)
158
+ macro = reflection.try(:macro)
159
+ options = reflection.try(:options)
160
160
 
161
161
  case macro
162
162
  # when :has_one
163
163
  # attribute = resource_tableized.singularize
164
164
  # saved_succesfully = @item.update_attribute attribute, nil
165
165
  when :has_many
166
- ##
167
- # We have to verify we can unrelate. For example: A Category which
168
- # has many posts and Post validates_presence_of Category should not
169
- # be removed.
170
- #
171
- attribute = @resource.table_name.singularize
172
- saved_succesfully = resource.update_attributes(attribute => nil)
166
+ if options.has_key?(:as) # We are in a polymorphic relationship
167
+ interface = options[:as]
168
+ saved_succesfully = resource.update_attributes("#{interface}_type" => nil, "#{interface}_id" => nil)
169
+ else
170
+ # We have to verify we can unrelate. For example: A Category which has
171
+ # many posts and Post validates_presence_of Category should not be removed.
172
+ attribute = @resource.table_name.singularize
173
+ saved_succesfully = resource.update_attributes(attribute => nil)
174
+ end
173
175
  when :has_and_belongs_to_many
174
176
  attribute = resource_tableized
175
177
  saved_succesfully = @item.send(attribute).delete(resource)
@@ -214,10 +216,6 @@ class Admin::ResourcesController < Admin::BaseController
214
216
  @object_name = ActiveModel::Naming.singular(@resource)
215
217
  end
216
218
 
217
- ##
218
- # Find model when performing an edit, update, destroy, relate,
219
- # unrelate ...
220
- #
221
219
  def get_object
222
220
  @item = @resource.find(params[:id])
223
221
  end
@@ -299,9 +297,9 @@ class Admin::ResourcesController < Admin::BaseController
299
297
 
300
298
  end
301
299
 
302
- def select_template(template = params[:action], resource = @resource.to_resource)
303
- folder = (File.exist?("app/views/admin/#{resource}/#{template}.html.erb")) ? resource : 'resources'
304
- render "admin/#{folder}/#{template}"
300
+ def select_template(action = params[:action], resource = @resource.to_resource)
301
+ folder = File.exist?("app/views/admin/#{resource}/#{action}.html.erb") ? resource : 'resources'
302
+ render "admin/#{folder}/#{action}"
305
303
  end
306
304
 
307
305
  end
@@ -2,22 +2,14 @@ module Admin
2
2
 
3
3
  module BaseHelper
4
4
 
5
- def typus_block(resource = @resource.to_resource, partial = params[:action])
6
- partials_path = "admin/#{resource}"
7
- resources_partials_path = "admin/resources"
8
-
9
- partials = ActionController::Base.view_paths.map do |view_path|
10
- Dir["#{view_path}/#{partials_path}/*"].map { |f| File.basename(f, '.html.erb') }
11
- end.flatten
12
- resources_partials = Dir[Rails.root.join("app/views/#{resources_partials_path}/*").to_s].map do |file|
13
- File.basename(file, ".html.erb")
14
- end
15
-
16
- path = if partials.include?("_#{partial}") then partials_path
17
- elsif resources_partials.include?(partial) then resources_partials_path
18
- end
19
-
20
- render "#{path}/#{partial}" if path
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
21
13
  end
22
14
 
23
15
  def title(page_title)
@@ -32,19 +24,19 @@ module Admin
32
24
  render "admin/helpers/apps"
33
25
  end
34
26
 
35
- def login_info(user = @current_user)
36
- return if user.kind_of?(Admin::FakeUser)
27
+ def login_info
28
+ return if [:none, :http_basic].include?(Typus.authentication)
37
29
 
38
30
  admin_edit_typus_user_path = { :controller => "/admin/#{Typus.user_class.to_resource}",
39
31
  :action => 'edit',
40
- :id => user.id }
32
+ :id => current_user.id }
41
33
 
42
34
  message = _t("Are you sure you want to sign out and end your session?")
43
35
 
44
- user_details = if user.can?('edit', Typus.user_class_name)
45
- link_to user.name, admin_edit_typus_user_path
36
+ user_details = if current_user.can?('edit', Typus.user_class_name)
37
+ link_to current_user.name, admin_edit_typus_user_path
46
38
  else
47
- user.name
39
+ current_user.name
48
40
  end
49
41
 
50
42
  render "admin/helpers/login_info", :message => message, :user_details => user_details
@@ -6,13 +6,10 @@ module Admin
6
6
  render File.join(path, "applications")
7
7
  end
8
8
 
9
- def resources
9
+ def resources(current_user)
10
10
  available = Typus.resources.map do |resource|
11
- resource if @current_user.resources.include?(resource)
11
+ resource if current_user.resources.include?(resource)
12
12
  end.compact
13
-
14
- return if available.empty?
15
-
16
13
  render File.join(path, "resources"), :resources => available
17
14
  end
18
15
 
@@ -3,8 +3,8 @@ module Admin
3
3
  module FiltersHelper
4
4
 
5
5
  def build_filters(resource = @resource)
6
-
7
6
  typus_filters = resource.typus_filters
7
+
8
8
  return if typus_filters.empty?
9
9
 
10
10
  current_request = request.env['QUERY_STRING'] || []
@@ -23,8 +23,10 @@ module Admin
23
23
  string_filter(current_request, key)
24
24
  end
25
25
 
26
- { :filter => filter, :items => items, :message => message }
26
+ items = items.to_a
27
+ items.insert(0, [message, ""])
27
28
 
29
+ { :filter => filter, :items => items }
28
30
  end
29
31
 
30
32
  render "admin/helpers/filters/filters", :filters => filters
@@ -40,10 +42,7 @@ module Admin
40
42
  %w(controller action page).each { |p| params_without_filter.delete(p) }
41
43
  params_without_filter.delete(related_fk)
42
44
 
43
- values = model.all(:order => model.typus_order_by)
44
- values_labelized = values.map { |v| v.to_label }
45
- items = values.map(&:id).to_hash_with(values_labelized)
46
-
45
+ items = model.all(:order => model.typus_order_by).collect{|v| [v.to_label, v.id] }
47
46
  message = _t("View all %{attribute}", :attribute => @resource.human_attribute_name(filter).downcase.pluralize)
48
47
 
49
48
  return related_fk, items, message
@@ -51,8 +50,7 @@ module Admin
51
50
 
52
51
  def date_filter(request, filter)
53
52
  values = %w(today last_few_days last_7_days last_30_days)
54
- values_humanized = values.map { |v| _t(v.humanize) }
55
- items = values.to_hash_with(values_humanized)
53
+ items = values.collect {|v| [_t(v.humanize), v ] }
56
54
  message = _t("Show all dates")
57
55
  return filter, items, message
58
56
  end
@@ -28,14 +28,6 @@ module Admin
28
28
  return html
29
29
  end
30
30
 
31
- def form_partial
32
- resource = @resource.to_resource
33
- template_file = Rails.root.join("app/views/admin/#{resource}/_form.html.erb")
34
- partial = File.exists?(template_file) ? resource : "resources"
35
-
36
- return "admin/#{partial}/form"
37
- end
38
-
39
31
  def typus_tree_field(attribute, form)
40
32
  render "admin/templates/tree",
41
33
  :attribute => attribute,
@@ -55,7 +47,7 @@ module Admin
55
47
 
56
48
  association = @resource.reflect_on_association(relationship.to_sym)
57
49
 
58
- next if @current_user.cannot?('read', association.class_name.constantize)
50
+ next if current_user.cannot?('read', association.class_name.constantize)
59
51
 
60
52
  case association.macro
61
53
  when :has_and_belongs_to_many
@@ -95,6 +87,8 @@ module Admin
95
87
  end
96
88
 
97
89
  =begin
90
+
91
+ # TODO: Take `attribute_disabled?(attribute)` back.
98
92
  def attribute_disabled?(attribute)
99
93
  accessible = @resource.accessible_attributes
100
94
  return accessible.nil? ? false : !accessible.include?(attribute)
@@ -14,13 +14,11 @@ module Admin
14
14
  return link
15
15
  end
16
16
 
17
- file = { :preview => Typus.file_preview, :thumbnail => Typus.file_thumbnail }
18
-
19
- has_file_preview = item.send(attribute).styles.member?(file[:preview])
20
- has_file_thumbnail = item.send(attribute).styles.member?(file[:thumbnail])
17
+ has_file_preview = item.send(attribute).styles.member?(Typus.file_preview)
18
+ has_file_thumbnail = item.send(attribute).styles.member?(Typus.file_thumbnail)
21
19
 
22
20
  href = if has_file_preview && file_preview_is_image
23
- url = item.send(attribute).url(file[:preview])
21
+ url = item.send(attribute).url(Typus.file_preview)
24
22
  # FIXME: This has changed on Rails3.
25
23
  # ActionController::Base.relative_url_root + url
26
24
  else
@@ -28,7 +26,7 @@ module Admin
28
26
  end
29
27
 
30
28
  content = if has_file_thumbnail && file_preview_is_image
31
- image_tag item.send(attribute).url(file[:thumbnail])
29
+ image_tag item.send(attribute).url(Typus.file_thumbnail)
32
30
  else
33
31
  item.send(attribute)
34
32
  end