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.
- checksums.yaml +7 -0
- data/app/assets/images/credit_cards/icons/diners_club.png +0 -0
- data/app/assets/javascripts/admin/address_states.js +1 -1
- data/app/assets/javascripts/admin/admin.js.erb +18 -13
- data/app/assets/javascripts/admin/calculator.js +2 -2
- data/app/assets/javascripts/admin/checkouts/edit.js +3 -1
- data/app/assets/javascripts/admin/image_settings.js.erb +5 -5
- data/app/assets/javascripts/admin/orders/edit.js +1 -1
- data/app/assets/javascripts/admin/payments/new.js +9 -2
- data/app/assets/javascripts/admin/spree_core.js +13 -1
- data/app/assets/javascripts/admin/taxon_autocomplete.js.erb +2 -1
- data/app/assets/javascripts/admin/variant_autocomplete.js.erb +23 -19
- data/app/assets/javascripts/spree.js.coffee +37 -0
- data/app/assets/javascripts/store/checkout.js.coffee +8 -0
- data/app/assets/javascripts/store/product.js.coffee +1 -1
- data/app/assets/javascripts/store/spree_core.js +1 -0
- data/app/assets/stylesheets/admin/components/_sidebar.scss +7 -6
- data/app/assets/stylesheets/admin/components/_states.scss +16 -12
- data/app/assets/stylesheets/admin/globals/_variables.scss +102 -96
- data/app/assets/stylesheets/admin/shared/_forms.scss +2 -1
- data/app/assets/stylesheets/admin/shared/_icons.scss +2 -1
- data/app/assets/stylesheets/admin/shared/_layout.scss +4 -1
- data/app/assets/stylesheets/admin/shared/_tables.scss +8 -0
- data/app/assets/stylesheets/store/screen.css.scss +28 -16
- data/app/assets/stylesheets/store/variables.css.scss +4 -2
- data/app/controllers/spree/admin/adjustments_controller.rb +7 -3
- data/app/controllers/spree/admin/base_controller.rb +10 -5
- data/app/controllers/spree/admin/line_items_controller.rb +3 -2
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +3 -2
- data/app/controllers/spree/admin/orders_controller.rb +2 -2
- data/app/controllers/spree/admin/payments_controller.rb +1 -1
- data/app/controllers/spree/admin/resource_controller.rb +5 -5
- data/app/controllers/spree/admin/shipments_controller.rb +1 -1
- data/app/controllers/spree/admin/taxons_controller.rb +1 -1
- data/app/controllers/spree/admin/users_controller.rb +96 -0
- data/app/controllers/spree/checkout_controller.rb +18 -7
- data/app/controllers/spree/locale_controller.rb +1 -1
- data/app/controllers/spree/orders_controller.rb +20 -2
- data/app/controllers/spree/taxons_controller.rb +8 -2
- data/app/helpers/spree/admin/images_helper.rb +6 -2
- data/app/helpers/spree/admin/navigation_helper.rb +23 -3
- data/app/helpers/spree/base_helper.rb +9 -5
- data/app/helpers/spree/orders_helper.rb +13 -0
- data/app/helpers/spree/products_helper.rb +9 -4
- data/app/mailers/spree/base_mailer.rb +16 -0
- data/app/mailers/spree/order_mailer.rb +12 -11
- data/app/mailers/spree/shipment_mailer.rb +4 -7
- data/app/mailers/spree/test_mailer.rb +2 -3
- data/app/models/spree/adjustment.rb +1 -1
- data/app/models/spree/app_configuration.rb +9 -3
- data/app/models/spree/calculator/default_tax.rb +5 -1
- data/app/models/spree/calculator/per_item.rb +1 -1
- data/app/models/spree/classification.rb +7 -0
- data/app/models/spree/credit_card.rb +1 -5
- data/app/models/spree/gateway.rb +10 -2
- data/app/models/spree/gateway/bogus.rb +5 -5
- data/app/models/spree/inventory_unit.rb +4 -4
- data/app/models/spree/line_item.rb +1 -1
- data/app/models/spree/order.rb +15 -35
- data/app/models/spree/order/checkout.rb +52 -0
- data/app/models/spree/order_populator.rb +11 -3
- data/app/models/spree/order_updater.rb +3 -4
- data/app/models/spree/payment.rb +23 -1
- data/app/models/spree/payment/processing.rb +18 -5
- data/app/models/spree/payment_method.rb +4 -0
- data/app/models/spree/price.rb +2 -3
- data/app/models/spree/product.rb +12 -4
- data/app/models/spree/product/scopes.rb +29 -16
- data/app/models/spree/return_authorization.rb +1 -1
- data/app/models/spree/shipment.rb +1 -1
- data/app/models/spree/taxon.rb +21 -6
- data/app/models/spree/variant.rb +7 -2
- data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +2 -2
- data/app/views/spree/admin/countries/index.html.erb +1 -0
- data/app/views/spree/admin/general_settings/edit.html.erb +10 -2
- data/app/views/spree/admin/images/index.html.erb +7 -3
- data/app/views/spree/admin/mail_methods/index.html.erb +2 -2
- data/app/views/spree/admin/orders/_form.html.erb +3 -3
- data/app/views/spree/admin/orders/_line_item.html.erb +1 -1
- data/app/views/spree/admin/orders/customer_details/_form.html.erb +4 -4
- data/app/views/spree/admin/orders/index.html.erb +60 -52
- data/app/views/spree/admin/payment_methods/_form.html.erb +2 -2
- data/app/views/spree/admin/payment_methods/index.html.erb +39 -35
- data/app/views/spree/admin/payments/_list.html.erb +1 -1
- data/app/views/spree/admin/payments/source_forms/_gateway.html.erb +10 -10
- data/app/views/spree/admin/products/_form.html.erb +7 -12
- data/app/views/spree/admin/products/index.html.erb +13 -15
- data/app/views/spree/admin/products/new.html.erb +3 -1
- data/app/views/spree/admin/return_authorizations/_form.html.erb +7 -7
- data/app/views/spree/admin/return_authorizations/edit.html.erb +17 -11
- data/app/views/spree/admin/return_authorizations/index.html.erb +4 -4
- data/app/views/spree/admin/return_authorizations/new.html.erb +13 -6
- data/app/views/spree/admin/shared/_alert.html.erb +1 -1
- data/app/views/spree/admin/shared/_configuration_menu.html.erb +6 -2
- data/app/views/spree/admin/shared/_order_details.html.erb +6 -6
- data/app/views/spree/admin/shared/_order_tabs.html.erb +20 -37
- data/app/views/spree/admin/shared/_routes.html.erb +1 -1
- data/app/views/spree/admin/shared/_tabs.html.erb +1 -2
- data/app/views/spree/admin/shared/_update_order_state.js +1 -1
- data/app/views/spree/admin/shipments/_form.html.erb +24 -24
- data/app/views/spree/admin/shipments/edit.html.erb +13 -13
- data/app/views/spree/admin/shipments/index.html.erb +35 -31
- data/app/views/spree/admin/shipping_methods/index.html.erb +35 -32
- data/app/views/spree/admin/tax_rates/_form.html.erb +2 -1
- data/app/views/spree/admin/taxons/_form.html.erb +17 -0
- data/app/views/spree/admin/taxons/edit.html.erb +3 -1
- data/app/views/spree/admin/trackers/_form.html.erb +2 -2
- data/app/views/spree/admin/trackers/index.html.erb +2 -2
- data/app/views/spree/admin/users/_form.html.erb +37 -0
- data/app/views/spree/admin/users/edit.html.erb +28 -0
- data/app/views/spree/admin/users/index.html.erb +53 -0
- data/app/views/spree/admin/users/new.html.erb +23 -0
- data/app/views/spree/admin/users/show.html.erb +21 -0
- data/app/views/spree/admin/variants/edit.html.erb +6 -4
- data/app/views/spree/admin/variants/index.html.erb +1 -1
- data/app/views/spree/admin/zones/_form.html.erb +4 -4
- data/app/views/spree/admin/zones/index.html.erb +3 -1
- data/app/views/spree/checkout/_delivery.html.erb +1 -1
- data/app/views/spree/checkout/_payment.html.erb +1 -1
- data/app/views/spree/checkout/_summary.html.erb +2 -2
- data/app/views/spree/checkout/payment/_gateway.html.erb +6 -6
- data/app/views/spree/layouts/spree_application.html.erb +0 -1
- data/app/views/spree/order_mailer/cancel_email.text.erb +1 -1
- data/app/views/spree/order_mailer/confirm_email.text.erb +1 -1
- data/app/views/spree/orders/_adjustments.html.erb +1 -1
- data/app/views/spree/orders/_line_item.html.erb +2 -2
- data/app/views/spree/orders/edit.html.erb +1 -1
- data/app/views/spree/payments/_payment.html.erb +16 -0
- data/app/views/spree/products/_cart_form.html.erb +2 -2
- data/app/views/spree/products/_thumbnails.html.erb +3 -3
- data/app/views/spree/products/index.html.erb +1 -1
- data/app/views/spree/shared/_google_analytics.html.erb +1 -1
- data/app/views/spree/shared/_main_nav_bar.html.erb +1 -1
- data/app/views/spree/shared/_order_details.html.erb +10 -24
- data/app/views/spree/shared/_products.html.erb +1 -1
- data/app/views/spree/shared/_search.html.erb +1 -1
- data/app/views/spree/taxons/show.html.erb +1 -1
- data/config/initializers/check_for_orphaned_preferences.rb +5 -2
- data/config/locales/en.yml +24 -5
- data/config/routes.rb +4 -3
- data/db/default/spree/countries.rb +229 -0
- data/db/default/spree/roles.rb +2 -0
- data/db/default/spree/states.rb +57 -0
- data/db/default/spree/zones.rb +17 -0
- data/db/migrate/20130207155350_add_order_id_index_to_payments.rb +9 -0
- data/db/migrate/20130208032954_add_primary_to_spree_products_taxons.rb +5 -0
- data/db/migrate/20130222032153_add_order_id_index_to_shipments.rb +5 -0
- data/db/migrate/20130226032817_change_meta_description_on_spree_products_to_text.rb +5 -0
- data/db/migrate/20130226054936_add_variant_id_index_to_spree_prices.rb +5 -0
- data/db/migrate/20130319062004_change_orders_total_precision.rb +8 -0
- data/db/migrate/20130319063911_change_spree_payments_amount_precision.rb +7 -0
- data/db/migrate/20130319064308_change_spree_return_authorization_amount_precision.rb +7 -0
- data/db/migrate/20130319082943_change_adjustments_amount_precision.rb +7 -0
- data/db/migrate/20130328195253_add_seo_metas_to_taxons.rb +9 -0
- data/lib/generators/spree/dummy/templates/rails/database.yml +9 -6
- data/lib/spree/core/calculated_adjustments.rb +1 -1
- data/lib/spree/core/controller_helpers/auth.rb +3 -3
- data/lib/spree/core/controller_helpers/common.rb +1 -11
- data/lib/spree/core/controller_helpers/order.rb +15 -12
- data/lib/spree/core/engine.rb +5 -1
- data/lib/spree/core/mail_interceptor.rb +4 -6
- data/lib/spree/core/mail_settings.rb +52 -23
- data/lib/spree/core/permalinks.rb +1 -3
- data/lib/spree/core/testing_support/authorization_helpers.rb +1 -1
- data/lib/spree/core/testing_support/capybara_ext.rb +30 -0
- data/lib/spree/core/testing_support/common_rake.rb +8 -0
- data/lib/spree/core/testing_support/factories/payment_factory.rb +1 -1
- data/lib/spree/core/testing_support/factories/product_factory.rb +7 -2
- data/lib/spree/core/testing_support/factories/variant_factory.rb +4 -2
- data/lib/spree/core/validators/email.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/money.rb +14 -3
- data/lib/spree/product_filters.rb +1 -1
- data/vendor/assets/javascripts/jquery.jstree/jquery.jstree.js +3 -2
- data/vendor/assets/javascripts/jsuri.js +2 -0
- data/vendor/assets/javascripts/modernizr.js +3 -3
- metadata +78 -69
- data/db/default/spree/countries.yml +0 -1589
- data/db/default/spree/roles.yml +0 -5
- data/db/default/spree/states.yml +0 -256
- data/db/default/spree/zone_members.yml +0 -169
- 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,
|
182
|
+
color: lighten($color-body-text, 8);
|
182
183
|
}
|
183
184
|
|
184
185
|
.filter-actions {
|
@@ -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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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
|
+
|
@@ -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
|
-
|
16
|
-
record = model_class
|
17
|
-
|
18
|
-
record = Object
|
19
|
+
if respond_to?(:model_class, true) && model_class
|
20
|
+
record = model_class
|
21
|
+
else
|
22
|
+
record = Object
|
19
23
|
end
|
20
|
-
authorize!
|
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 {
|
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!
|
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.
|
29
|
-
|
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!
|
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.
|
@@ -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!
|
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?(
|
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,
|
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?
|
255
|
+
!collection_actions.include? action
|
256
256
|
end
|
257
257
|
|
258
258
|
def new_actions
|
@@ -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
|