spree_core 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. checksums.yaml +7 -0
  2. data/app/assets/images/credit_cards/icons/diners_club.png +0 -0
  3. data/app/assets/javascripts/admin/address_states.js +1 -1
  4. data/app/assets/javascripts/admin/admin.js.erb +18 -13
  5. data/app/assets/javascripts/admin/calculator.js +2 -2
  6. data/app/assets/javascripts/admin/checkouts/edit.js +3 -1
  7. data/app/assets/javascripts/admin/image_settings.js.erb +5 -5
  8. data/app/assets/javascripts/admin/orders/edit.js +1 -1
  9. data/app/assets/javascripts/admin/payments/new.js +9 -2
  10. data/app/assets/javascripts/admin/spree_core.js +13 -1
  11. data/app/assets/javascripts/admin/taxon_autocomplete.js.erb +2 -1
  12. data/app/assets/javascripts/admin/variant_autocomplete.js.erb +23 -19
  13. data/app/assets/javascripts/spree.js.coffee +37 -0
  14. data/app/assets/javascripts/store/checkout.js.coffee +8 -0
  15. data/app/assets/javascripts/store/product.js.coffee +1 -1
  16. data/app/assets/javascripts/store/spree_core.js +1 -0
  17. data/app/assets/stylesheets/admin/components/_sidebar.scss +7 -6
  18. data/app/assets/stylesheets/admin/components/_states.scss +16 -12
  19. data/app/assets/stylesheets/admin/globals/_variables.scss +102 -96
  20. data/app/assets/stylesheets/admin/shared/_forms.scss +2 -1
  21. data/app/assets/stylesheets/admin/shared/_icons.scss +2 -1
  22. data/app/assets/stylesheets/admin/shared/_layout.scss +4 -1
  23. data/app/assets/stylesheets/admin/shared/_tables.scss +8 -0
  24. data/app/assets/stylesheets/store/screen.css.scss +28 -16
  25. data/app/assets/stylesheets/store/variables.css.scss +4 -2
  26. data/app/controllers/spree/admin/adjustments_controller.rb +7 -3
  27. data/app/controllers/spree/admin/base_controller.rb +10 -5
  28. data/app/controllers/spree/admin/line_items_controller.rb +3 -2
  29. data/app/controllers/spree/admin/orders/customer_details_controller.rb +3 -2
  30. data/app/controllers/spree/admin/orders_controller.rb +2 -2
  31. data/app/controllers/spree/admin/payments_controller.rb +1 -1
  32. data/app/controllers/spree/admin/resource_controller.rb +5 -5
  33. data/app/controllers/spree/admin/shipments_controller.rb +1 -1
  34. data/app/controllers/spree/admin/taxons_controller.rb +1 -1
  35. data/app/controllers/spree/admin/users_controller.rb +96 -0
  36. data/app/controllers/spree/checkout_controller.rb +18 -7
  37. data/app/controllers/spree/locale_controller.rb +1 -1
  38. data/app/controllers/spree/orders_controller.rb +20 -2
  39. data/app/controllers/spree/taxons_controller.rb +8 -2
  40. data/app/helpers/spree/admin/images_helper.rb +6 -2
  41. data/app/helpers/spree/admin/navigation_helper.rb +23 -3
  42. data/app/helpers/spree/base_helper.rb +9 -5
  43. data/app/helpers/spree/orders_helper.rb +13 -0
  44. data/app/helpers/spree/products_helper.rb +9 -4
  45. data/app/mailers/spree/base_mailer.rb +16 -0
  46. data/app/mailers/spree/order_mailer.rb +12 -11
  47. data/app/mailers/spree/shipment_mailer.rb +4 -7
  48. data/app/mailers/spree/test_mailer.rb +2 -3
  49. data/app/models/spree/adjustment.rb +1 -1
  50. data/app/models/spree/app_configuration.rb +9 -3
  51. data/app/models/spree/calculator/default_tax.rb +5 -1
  52. data/app/models/spree/calculator/per_item.rb +1 -1
  53. data/app/models/spree/classification.rb +7 -0
  54. data/app/models/spree/credit_card.rb +1 -5
  55. data/app/models/spree/gateway.rb +10 -2
  56. data/app/models/spree/gateway/bogus.rb +5 -5
  57. data/app/models/spree/inventory_unit.rb +4 -4
  58. data/app/models/spree/line_item.rb +1 -1
  59. data/app/models/spree/order.rb +15 -35
  60. data/app/models/spree/order/checkout.rb +52 -0
  61. data/app/models/spree/order_populator.rb +11 -3
  62. data/app/models/spree/order_updater.rb +3 -4
  63. data/app/models/spree/payment.rb +23 -1
  64. data/app/models/spree/payment/processing.rb +18 -5
  65. data/app/models/spree/payment_method.rb +4 -0
  66. data/app/models/spree/price.rb +2 -3
  67. data/app/models/spree/product.rb +12 -4
  68. data/app/models/spree/product/scopes.rb +29 -16
  69. data/app/models/spree/return_authorization.rb +1 -1
  70. data/app/models/spree/shipment.rb +1 -1
  71. data/app/models/spree/taxon.rb +21 -6
  72. data/app/models/spree/variant.rb +7 -2
  73. data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +2 -2
  74. data/app/views/spree/admin/countries/index.html.erb +1 -0
  75. data/app/views/spree/admin/general_settings/edit.html.erb +10 -2
  76. data/app/views/spree/admin/images/index.html.erb +7 -3
  77. data/app/views/spree/admin/mail_methods/index.html.erb +2 -2
  78. data/app/views/spree/admin/orders/_form.html.erb +3 -3
  79. data/app/views/spree/admin/orders/_line_item.html.erb +1 -1
  80. data/app/views/spree/admin/orders/customer_details/_form.html.erb +4 -4
  81. data/app/views/spree/admin/orders/index.html.erb +60 -52
  82. data/app/views/spree/admin/payment_methods/_form.html.erb +2 -2
  83. data/app/views/spree/admin/payment_methods/index.html.erb +39 -35
  84. data/app/views/spree/admin/payments/_list.html.erb +1 -1
  85. data/app/views/spree/admin/payments/source_forms/_gateway.html.erb +10 -10
  86. data/app/views/spree/admin/products/_form.html.erb +7 -12
  87. data/app/views/spree/admin/products/index.html.erb +13 -15
  88. data/app/views/spree/admin/products/new.html.erb +3 -1
  89. data/app/views/spree/admin/return_authorizations/_form.html.erb +7 -7
  90. data/app/views/spree/admin/return_authorizations/edit.html.erb +17 -11
  91. data/app/views/spree/admin/return_authorizations/index.html.erb +4 -4
  92. data/app/views/spree/admin/return_authorizations/new.html.erb +13 -6
  93. data/app/views/spree/admin/shared/_alert.html.erb +1 -1
  94. data/app/views/spree/admin/shared/_configuration_menu.html.erb +6 -2
  95. data/app/views/spree/admin/shared/_order_details.html.erb +6 -6
  96. data/app/views/spree/admin/shared/_order_tabs.html.erb +20 -37
  97. data/app/views/spree/admin/shared/_routes.html.erb +1 -1
  98. data/app/views/spree/admin/shared/_tabs.html.erb +1 -2
  99. data/app/views/spree/admin/shared/_update_order_state.js +1 -1
  100. data/app/views/spree/admin/shipments/_form.html.erb +24 -24
  101. data/app/views/spree/admin/shipments/edit.html.erb +13 -13
  102. data/app/views/spree/admin/shipments/index.html.erb +35 -31
  103. data/app/views/spree/admin/shipping_methods/index.html.erb +35 -32
  104. data/app/views/spree/admin/tax_rates/_form.html.erb +2 -1
  105. data/app/views/spree/admin/taxons/_form.html.erb +17 -0
  106. data/app/views/spree/admin/taxons/edit.html.erb +3 -1
  107. data/app/views/spree/admin/trackers/_form.html.erb +2 -2
  108. data/app/views/spree/admin/trackers/index.html.erb +2 -2
  109. data/app/views/spree/admin/users/_form.html.erb +37 -0
  110. data/app/views/spree/admin/users/edit.html.erb +28 -0
  111. data/app/views/spree/admin/users/index.html.erb +53 -0
  112. data/app/views/spree/admin/users/new.html.erb +23 -0
  113. data/app/views/spree/admin/users/show.html.erb +21 -0
  114. data/app/views/spree/admin/variants/edit.html.erb +6 -4
  115. data/app/views/spree/admin/variants/index.html.erb +1 -1
  116. data/app/views/spree/admin/zones/_form.html.erb +4 -4
  117. data/app/views/spree/admin/zones/index.html.erb +3 -1
  118. data/app/views/spree/checkout/_delivery.html.erb +1 -1
  119. data/app/views/spree/checkout/_payment.html.erb +1 -1
  120. data/app/views/spree/checkout/_summary.html.erb +2 -2
  121. data/app/views/spree/checkout/payment/_gateway.html.erb +6 -6
  122. data/app/views/spree/layouts/spree_application.html.erb +0 -1
  123. data/app/views/spree/order_mailer/cancel_email.text.erb +1 -1
  124. data/app/views/spree/order_mailer/confirm_email.text.erb +1 -1
  125. data/app/views/spree/orders/_adjustments.html.erb +1 -1
  126. data/app/views/spree/orders/_line_item.html.erb +2 -2
  127. data/app/views/spree/orders/edit.html.erb +1 -1
  128. data/app/views/spree/payments/_payment.html.erb +16 -0
  129. data/app/views/spree/products/_cart_form.html.erb +2 -2
  130. data/app/views/spree/products/_thumbnails.html.erb +3 -3
  131. data/app/views/spree/products/index.html.erb +1 -1
  132. data/app/views/spree/shared/_google_analytics.html.erb +1 -1
  133. data/app/views/spree/shared/_main_nav_bar.html.erb +1 -1
  134. data/app/views/spree/shared/_order_details.html.erb +10 -24
  135. data/app/views/spree/shared/_products.html.erb +1 -1
  136. data/app/views/spree/shared/_search.html.erb +1 -1
  137. data/app/views/spree/taxons/show.html.erb +1 -1
  138. data/config/initializers/check_for_orphaned_preferences.rb +5 -2
  139. data/config/locales/en.yml +24 -5
  140. data/config/routes.rb +4 -3
  141. data/db/default/spree/countries.rb +229 -0
  142. data/db/default/spree/roles.rb +2 -0
  143. data/db/default/spree/states.rb +57 -0
  144. data/db/default/spree/zones.rb +17 -0
  145. data/db/migrate/20130207155350_add_order_id_index_to_payments.rb +9 -0
  146. data/db/migrate/20130208032954_add_primary_to_spree_products_taxons.rb +5 -0
  147. data/db/migrate/20130222032153_add_order_id_index_to_shipments.rb +5 -0
  148. data/db/migrate/20130226032817_change_meta_description_on_spree_products_to_text.rb +5 -0
  149. data/db/migrate/20130226054936_add_variant_id_index_to_spree_prices.rb +5 -0
  150. data/db/migrate/20130319062004_change_orders_total_precision.rb +8 -0
  151. data/db/migrate/20130319063911_change_spree_payments_amount_precision.rb +7 -0
  152. data/db/migrate/20130319064308_change_spree_return_authorization_amount_precision.rb +7 -0
  153. data/db/migrate/20130319082943_change_adjustments_amount_precision.rb +7 -0
  154. data/db/migrate/20130328195253_add_seo_metas_to_taxons.rb +9 -0
  155. data/lib/generators/spree/dummy/templates/rails/database.yml +9 -6
  156. data/lib/spree/core/calculated_adjustments.rb +1 -1
  157. data/lib/spree/core/controller_helpers/auth.rb +3 -3
  158. data/lib/spree/core/controller_helpers/common.rb +1 -11
  159. data/lib/spree/core/controller_helpers/order.rb +15 -12
  160. data/lib/spree/core/engine.rb +5 -1
  161. data/lib/spree/core/mail_interceptor.rb +4 -6
  162. data/lib/spree/core/mail_settings.rb +52 -23
  163. data/lib/spree/core/permalinks.rb +1 -3
  164. data/lib/spree/core/testing_support/authorization_helpers.rb +1 -1
  165. data/lib/spree/core/testing_support/capybara_ext.rb +30 -0
  166. data/lib/spree/core/testing_support/common_rake.rb +8 -0
  167. data/lib/spree/core/testing_support/factories/payment_factory.rb +1 -1
  168. data/lib/spree/core/testing_support/factories/product_factory.rb +7 -2
  169. data/lib/spree/core/testing_support/factories/variant_factory.rb +4 -2
  170. data/lib/spree/core/validators/email.rb +1 -1
  171. data/lib/spree/core/version.rb +1 -1
  172. data/lib/spree/money.rb +14 -3
  173. data/lib/spree/product_filters.rb +1 -1
  174. data/vendor/assets/javascripts/jquery.jstree/jquery.jstree.js +3 -2
  175. data/vendor/assets/javascripts/jsuri.js +2 -0
  176. data/vendor/assets/javascripts/modernizr.js +3 -3
  177. metadata +78 -69
  178. data/db/default/spree/countries.yml +0 -1589
  179. data/db/default/spree/roles.yml +0 -5
  180. data/db/default/spree/states.yml +0 -256
  181. data/db/default/spree/zone_members.yml +0 -169
  182. data/db/default/spree/zones.yml +0 -13
@@ -175,10 +175,11 @@ fieldset {
175
175
  text-transform: uppercase;
176
176
  text-align: center;
177
177
  padding: 8px 15px;
178
+ -webkit-font-smoothing: antialiased;
178
179
  }
179
180
 
180
181
  label {
181
- color: lighten($color-body-text, 5);
182
+ color: lighten($color-body-text, 8);
182
183
  }
183
184
 
184
185
  .filter-actions {
@@ -18,4 +18,5 @@
18
18
  .icon-cancel:before,
19
19
  .icon-void:before { @extend .icon-remove:before }
20
20
 
21
- .icon-capture:before { @extend .icon-ok:before }
21
+ .icon-capture:before { @extend .icon-ok:before }
22
+ .icon-credit:before { @extend .icon-ok:before }
@@ -65,10 +65,13 @@
65
65
 
66
66
  .page-title {
67
67
  font-size: 20px;
68
+ -webkit-font-smoothing: antialiased;
68
69
  }
69
70
  .page-actions {
70
71
  text-align: right;
71
-
72
+ form {
73
+ display: inline-block;
74
+ }
72
75
  .button {
73
76
  font-size: 85%;
74
77
  }
@@ -18,6 +18,14 @@ table {
18
18
  border-left: 1px solid $color-border;
19
19
  }
20
20
 
21
+ a {
22
+ border-bottom: 1px dotted lighten($color-link, 10);
23
+
24
+ &:hover {
25
+ border-color: lighten($color-link-hover, 10);
26
+ }
27
+ }
28
+
21
29
  &.actions {
22
30
  background-color: transparent;
23
31
  border: none !important;
@@ -19,7 +19,7 @@ hr {
19
19
  background-color: transparent;
20
20
  color: transparent;
21
21
  border: none;
22
- border-bottom: 1px solid $border_color;
22
+ border-bottom: $default_border;
23
23
  }
24
24
 
25
25
  /* Custom text-selection colors (remove any text shadows: twitter.com/miketaylr/status/12228805301) */
@@ -72,7 +72,7 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
72
72
  padding: 5px;
73
73
 
74
74
  &.odd {
75
- background-color: lighten($body_text_color, 60);
75
+ background-color: $table_head_color;
76
76
  }
77
77
  }
78
78
  dt {
@@ -215,7 +215,7 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
215
215
  /*--------------------------------------*/
216
216
  footer#footer {
217
217
  padding: 10px 0;
218
- border-top: 1px solid lighten($body_text_color, 60);
218
+ border-top: $default_border;
219
219
  }
220
220
 
221
221
  /*--------------------------------------*/
@@ -230,7 +230,7 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
230
230
  /*--------------------------------------*/
231
231
  table {
232
232
  thead {
233
- background-color: lighten($body_text_color, 60);
233
+ background-color: $table_head_color;
234
234
  text-transform: uppercase;
235
235
 
236
236
  tr {
@@ -242,7 +242,7 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
242
242
 
243
243
  tbody, tfoot {
244
244
  tr {
245
- border-bottom: 1px solid lighten($body_text_color, 60);
245
+ border-bottom: $default_border;
246
246
 
247
247
  td {
248
248
  vertical-align: middle;
@@ -281,7 +281,7 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
281
281
  text-transform: uppercase;
282
282
  font-weight: bold;
283
283
  margin-top: 20px;
284
- border-bottom: 1px solid lighten($body_text_color, 60);
284
+ border-bottom: $default_border;
285
285
  padding-bottom: 6px;
286
286
 
287
287
  li {
@@ -318,7 +318,7 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
318
318
  .amount {
319
319
  font-size: $horizontal_navigation_font_size + 2;
320
320
  font-weight: bold;
321
- border-left: 1px solid lighten($body_text_color, 60);
321
+ border-left: $default_border;
322
322
  padding-left: 5px;
323
323
  padding-bottom: 5px;
324
324
  }
@@ -330,7 +330,7 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
330
330
  nav#taxonomies {
331
331
  .taxonomy-root {
332
332
  text-transform: uppercase;
333
- border-bottom: 1px solid lighten($body_text_color, 60);
333
+ border-bottom: $default_border;
334
334
  margin-bottom: 5px;
335
335
  font-size: $main_navigation_header_font_size;
336
336
  }
@@ -345,7 +345,7 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
345
345
  }
346
346
 
347
347
  #breadcrumbs {
348
- border-bottom: 1px solid lighten($body_text_color, 60);
348
+ border-bottom: $default_border;
349
349
  padding: 3px 0;
350
350
  margin-bottom: 15px;
351
351
 
@@ -473,7 +473,7 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
473
473
  margin-top: 5px;
474
474
  font-size: $product_list_name_font_size;
475
475
  color: $product_link_text_color;
476
- border-bottom: 1px solid lighten($body_text_color, 60);
476
+ border-bottom: $default_border;
477
477
  overflow: hidden;
478
478
  }
479
479
  }
@@ -513,7 +513,7 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
513
513
 
514
514
  .search-results-title {
515
515
  text-transform: uppercase;
516
- border-bottom: 1px solid lighten($body_text_color, 60);
516
+ border-bottom: $default_border;
517
517
  margin-bottom: 10px;
518
518
  }
519
519
 
@@ -558,7 +558,7 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
558
558
 
559
559
  #product-description {
560
560
  .product-title {
561
- border-bottom: 1px solid lighten($body_text_color, 60);
561
+ border-bottom: $default_border;
562
562
  margin-bottom: 15px;
563
563
  color: $product_title_text_color;
564
564
  font-size: $product_detail_name_font_size;
@@ -641,7 +641,7 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
641
641
  }
642
642
 
643
643
  &.completed-first, &.completed {
644
- background-color: lighten($body_text_color, 60);
644
+ background-color: $table_head_color;
645
645
  color: $layout_background_color;
646
646
 
647
647
  a {
@@ -684,7 +684,7 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
684
684
  h3 {
685
685
  text-transform: uppercase;
686
686
  font-size: $base_font_size + 2;
687
- border-bottom: 1px solid lighten($body_text_color, 60);
687
+ border-bottom: $default_border;
688
688
  }
689
689
 
690
690
  table {
@@ -760,7 +760,7 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
760
760
  color: $body_text_color;
761
761
 
762
762
  tr {
763
- border-top: 1px solid lighten($body_text_color, 60);
763
+ border-top: $default_border;
764
764
 
765
765
  td {
766
766
  padding: 10px;
@@ -780,7 +780,7 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
780
780
  }
781
781
 
782
782
  h6 {
783
- border-bottom: 1px solid lighten($body_text_color, 60);
783
+ border-bottom: $default_border;
784
784
  margin-bottom: 5px;
785
785
  }
786
786
  }
@@ -788,6 +788,14 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
788
788
 
789
789
  #shipping_method {
790
790
  p {
791
+ &#minstrs {
792
+ clear: both;
793
+
794
+ label {
795
+ width: 100%;
796
+ }
797
+ }
798
+
791
799
  label {
792
800
  float: left;
793
801
  font-weight: bold;
@@ -878,6 +886,10 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
878
886
  margin-bottom: 15px;
879
887
  border: $default_border;
880
888
  padding: 10px;
889
+
890
+ dd {
891
+ margin-left: 0px;
892
+ }
881
893
  }
882
894
 
883
895
  /*--------------------------------------*/
@@ -55,6 +55,8 @@ $ff_base: 'Ubuntu', sans-serif !default;
55
55
  $button_font_size: 12px !default;
56
56
  $input_box_font_size: 13px !default;
57
57
  $base_font_size: 12px !default;
58
- $border_color: lighten($body_text_color, 60);
59
- $default_border: 1px solid $border_color;
58
+ $border_color: lighten($body_text_color, 60) !default;
59
+ $default_border: 1px solid $border_color !default;
60
60
  $button_border_color: rgba(0, 138, 189, .75) !default;
61
+ $table_head_color: lighten($body_text_color, 60) !default;
62
+
@@ -5,9 +5,13 @@ module Spree
5
5
  destroy.after :reload_order
6
6
 
7
7
  private
8
- def reload_order
9
- @order.reload
10
- end
8
+ def reload_order
9
+ @order.reload
10
+ end
11
+
12
+ def collection
13
+ parent.adjustments.eligible
14
+ end
11
15
  end
12
16
  end
13
17
  end
@@ -11,13 +11,18 @@ module Spree
11
11
  before_filter :authorize_admin
12
12
 
13
13
  protected
14
+ def action
15
+ params[:action].to_sym
16
+ end
17
+
14
18
  def authorize_admin
15
- begin
16
- record = model_class.new
17
- rescue
18
- record = Object.new
19
+ if respond_to?(:model_class, true) && model_class
20
+ record = model_class
21
+ else
22
+ record = Object
19
23
  end
20
- authorize! params[:action].to_sym, record
24
+ authorize! :admin, record
25
+ authorize! action, record
21
26
  end
22
27
 
23
28
  def check_alerts
@@ -26,7 +26,8 @@ module Spree
26
26
  def destroy
27
27
  @line_item.destroy
28
28
  respond_with(@line_item) do |format|
29
- format.html { render :partial => 'spree/admin/orders/form', :locals => { :order => @order.reload } }
29
+ format.html { redirect_to edit_admin_order_path(@order) }
30
+ format.js { @order.reload }
30
31
  end
31
32
  end
32
33
 
@@ -46,7 +47,7 @@ module Spree
46
47
 
47
48
  def load_order
48
49
  @order = Order.find_by_number!(params[:order_id])
49
- authorize! params[:action], @order
50
+ authorize! action, @order
50
51
  end
51
52
 
52
53
  def load_line_item
@@ -25,14 +25,15 @@ module Spree
25
25
  @order.user_id = params[:user_id]
26
26
  @order.user true
27
27
  end
28
- @order.save
29
- @order.create_shipment!
28
+ while @order.next; end
29
+
30
30
  flash[:success] = t('customer_details_updated')
31
31
  redirect_to edit_admin_order_shipment_path(@order, @order.shipment)
32
32
  else
33
33
  flash[:error] = t('errors.messages.no_shipping_methods_available')
34
34
  redirect_to admin_order_customer_path(@order)
35
35
  end
36
+
36
37
  else
37
38
  render :action => :edit
38
39
  end
@@ -101,7 +101,7 @@ module Spree
101
101
  end
102
102
 
103
103
  def resend
104
- OrderMailer.confirm_email(@order, true).deliver
104
+ OrderMailer.confirm_email(@order.id, true).deliver
105
105
  flash[:success] = t(:order_email_resent)
106
106
 
107
107
  respond_with(@order) { |format| format.html { redirect_to :back } }
@@ -111,7 +111,7 @@ module Spree
111
111
 
112
112
  def load_order
113
113
  @order = Order.find_by_number!(params[:id], :include => :adjustments) if params[:id]
114
- authorize! params[:action], @order
114
+ authorize! action, @order
115
115
  end
116
116
 
117
117
  # Used for extensions which need to provide their own custom event links on the order details view.
@@ -88,7 +88,7 @@ module Spree
88
88
 
89
89
  def load_order
90
90
  @order = Order.find_by_number!(params[:order_id])
91
- authorize! params[:action], @order
91
+ authorize! action, @order
92
92
  end
93
93
 
94
94
  def load_payment
@@ -2,7 +2,7 @@ require 'spree/core/action_callbacks'
2
2
 
3
3
  class Spree::Admin::ResourceController < Spree::Admin::BaseController
4
4
  helper_method :new_object_url, :edit_object_url, :object_url, :collection_url
5
- before_filter :load_resource
5
+ before_filter :load_resource, :except => [:update_positions]
6
6
  rescue_from ActiveRecord::RecordNotFound, :with => :resource_not_found
7
7
 
8
8
  respond_to :html
@@ -139,7 +139,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
139
139
  # call authorize! a third time (called twice already in Admin::BaseController)
140
140
  # this time we pass the actual instance so fine-grained abilities can control
141
141
  # access to individual records, not just entire models.
142
- authorize! params[:action], @object
142
+ authorize! action, @object
143
143
 
144
144
  instance_variable_set("@#{object_name}", @object)
145
145
  else
@@ -153,7 +153,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
153
153
  end
154
154
 
155
155
  def load_resource_instance
156
- if new_actions.include?(params[:action].to_sym)
156
+ if new_actions.include?(action)
157
157
  build_resource
158
158
  elsif params[:id]
159
159
  find_resource
@@ -192,7 +192,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
192
192
  def collection
193
193
  return parent.send(controller_name) if parent_data.present?
194
194
  if model_class.respond_to?(:accessible_by) && !current_ability.has_block?(params[:action], model_class)
195
- model_class.accessible_by(current_ability, params[:action])
195
+ model_class.accessible_by(current_ability, action)
196
196
  else
197
197
  model_class.scoped
198
198
  end
@@ -252,7 +252,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
252
252
  end
253
253
 
254
254
  def member_action?
255
- !collection_actions.include? params[:action].to_sym
255
+ !collection_actions.include? action
256
256
  end
257
257
 
258
258
  def new_actions
@@ -79,7 +79,7 @@ module Spree
79
79
 
80
80
  def order
81
81
  @order ||= Order.find_by_number(params[:order_id])
82
- authorize! params[:action], @order
82
+ authorize! action, @order
83
83
  end
84
84
 
85
85
  def shipment
@@ -106,7 +106,7 @@ module Spree
106
106
  def destroy
107
107
  @taxon = Taxon.find(params[:id])
108
108
  @taxon.destroy
109
- respond_with(@taxon) { |format| format.json { render :json => '' } }
109
+ render :text => "", :status => 204
110
110
  end
111
111
 
112
112
  end
@@ -0,0 +1,96 @@
1
+ module Spree
2
+ module Admin
3
+ class UsersController < ResourceController
4
+
5
+ if Spree.user_class.const_defined?("DestroyWithOrdersError")
6
+ rescue_from "#{Spree.user_class}::DestroyWithOrdersError".constantize, :with => :user_destroy_with_orders_error
7
+ end
8
+
9
+ # http://spreecommerce.com/blog/2010/11/02/json-hijacking-vulnerability/
10
+ before_filter :check_json_authenticity, :only => :index
11
+ before_filter :load_roles, :only => [:edit, :new, :update, :create, :generate_api_key, :clear_api_key]
12
+ update.after :sign_in_if_change_own_password
13
+ before_filter :load_roles, :only => [:edit, :new, :update, :create]
14
+
15
+ def index
16
+ respond_with(@collection) do |format|
17
+ format.html
18
+ format.json { render :json => json_data }
19
+ end
20
+ end
21
+
22
+ def generate_api_key
23
+ if @user.generate_spree_api_key!
24
+ flash.notice = t('key_generated', :scope => 'spree.api')
25
+ end
26
+ redirect_to edit_admin_user_path(@user)
27
+ end
28
+
29
+ def clear_api_key
30
+ if @user.clear_spree_api_key!
31
+ flash.notice = t('key_cleared', :scope => 'spree.api')
32
+ end
33
+ redirect_to edit_admin_user_path(@user)
34
+ end
35
+
36
+ protected
37
+
38
+ def sign_in_if_change_own_password
39
+ if spree_current_user == @user && @user.password.present?
40
+ sign_in(@user, :event => :authentication, :bypass => true)
41
+ end
42
+ end
43
+
44
+ def load_roles
45
+ @roles = Spree::Role.scoped
46
+ end
47
+
48
+ def model_class
49
+ Spree.user_class
50
+ end
51
+
52
+ def collection
53
+ return @collection if @collection.present?
54
+ unless request.xhr?
55
+ @search = Spree.user_class.registered.ransack(params[:q])
56
+ @collection = @search.result.page(params[:page]).per(Spree::Config[:admin_products_per_page])
57
+ else
58
+ #disabling proper nested include here due to rails 3.1 bug
59
+ #@collection = User.includes(:bill_address => [:state, :country], :ship_address => [:state, :country]).
60
+ @collection = Spree.user_class.includes(:bill_address, :ship_address).
61
+ where("spree_users.email #{LIKE} :search
62
+ OR (spree_addresses.firstname #{LIKE} :search AND spree_addresses.id = spree_users.bill_address_id)
63
+ OR (spree_addresses.lastname #{LIKE} :search AND spree_addresses.id = spree_users.bill_address_id)
64
+ OR (spree_addresses.firstname #{LIKE} :search AND spree_addresses.id = spree_users.ship_address_id)
65
+ OR (spree_addresses.lastname #{LIKE} :search AND spree_addresses.id = spree_users.ship_address_id)",
66
+ { :search => "#{params[:q].strip}%" }).
67
+ limit(params[:limit] || 100)
68
+ end
69
+ end
70
+
71
+ private
72
+
73
+ # handling raise from Spree::Admin::ResourceController#destroy
74
+ def user_destroy_with_orders_error
75
+ invoke_callbacks(:destroy, :fails)
76
+ render :status => :forbidden, :text => t(:error_user_destroy_with_orders)
77
+ end
78
+
79
+ # Allow different formats of json data to suit different ajax calls
80
+ def json_data
81
+ json_format = params[:json_format] or 'default'
82
+ case json_format
83
+ when 'basic'
84
+ collection.map { |u| { 'id' => u.id, 'name' => u.email } }.to_json
85
+ else
86
+ address_fields = [:firstname, :lastname, :address1, :address2, :city, :zipcode, :phone, :state_name, :state_id, :country_id]
87
+ includes = { :only => address_fields , :include => { :state => { :only => :name }, :country => { :only => :name } } }
88
+
89
+ collection.to_json(:only => [:id, :email], :include =>
90
+ { :bill_address => includes, :ship_address => includes })
91
+ end
92
+ end
93
+
94
+ end
95
+ end
96
+ end