diff --git a/app/controllers/spree/admin/reports_controller_decorator.rb b/app/controllers/spree/admin/reports_controller_decorator.rb index 150a766cc5..8234c40216 100644 --- a/app/controllers/spree/admin/reports_controller_decorator.rb +++ b/app/controllers/spree/admin/reports_controller_decorator.rb @@ -18,6 +18,8 @@ Spree::Admin::ReportsController.class_eval do render_to_string(partial: 'orders_and_fulfillment_description', layout: false, locals: {report_types: REPORT_TYPES[:orders_and_fulfillment]}).html_safe @reports[:products_and_inventory][:description] = render_to_string(partial: 'products_and_inventory_description', layout: false, locals: {report_types: REPORT_TYPES[:products_and_inventory]}).html_safe + @reports[:customers][:description] = + render_to_string(partial: 'customers_description', layout: false, locals: {report_types: REPORT_TYPES[:customers]}).html_safe } } } # OVERRIDING THIS so we use a method not a constant for available reports diff --git a/app/views/spree/admin/reports/_customers_description.html.haml b/app/views/spree/admin/reports/_customers_description.html.haml new file mode 100644 index 0000000000..85f93a82c0 --- /dev/null +++ b/app/views/spree/admin/reports/_customers_description.html.haml @@ -0,0 +1,4 @@ +%ul{style: "margin-left: 12pt"} + - report_types.each do |report_type| + %li + = link_to report_type[0], "#{customers_admin_reports_url}?report_type=#{report_type[1]}" diff --git a/app/views/spree/admin/reports/customers.html.haml b/app/views/spree/admin/reports/customers.html.haml index d2a1a7be57..9a5f114754 100644 --- a/app/views/spree/admin/reports/customers.html.haml +++ b/app/views/spree/admin/reports/customers.html.haml @@ -6,3 +6,16 @@ %br %br %table#listing_customers.index + %thead + %tr{'data-hook' => "orders_header"} + - @report.header.each do |heading| + %th=heading + %tbody + - @report.table.each do |row| + %tr + - row.each do |column| + %td= column + - if @report.table.empty? + %tr + %td{:colspan => "2"}= t(:none) + diff --git a/lib/open_food_network/customers_report.rb b/lib/open_food_network/customers_report.rb index 61c2d1dcc3..315b7b5ad5 100644 --- a/lib/open_food_network/customers_report.rb +++ b/lib/open_food_network/customers_report.rb @@ -23,15 +23,15 @@ module OpenFoodNetwork order.billing_address.city] else ba = order.billing_address - da = order.distributor.address + da = order.distributor.andand.address [ba.firstname, ba.lastname, [ba.address1, ba.address2, ba.city].join(" "), order.email, ba.phone, - order.distributor.name, - [da.address1, da.address2, da.city].join(" "), - order.shipping_method.name + order.distributor.andand.name, + [da.andand.address1, da.andand.address2, da.andand.city].join(" "), + order.shipping_method.andand.name ] end end diff --git a/spec/features/admin/reports_spec.rb b/spec/features/admin/reports_spec.rb index 30dc60e7b8..ce0248e381 100644 --- a/spec/features/admin/reports_spec.rb +++ b/spec/features/admin/reports_spec.rb @@ -29,12 +29,18 @@ feature %q{ end end - scenario "customers report" do - login_to_admin_section - click_link "Reports" - click_link "Customers" - page.should have_content "Customers" - page.should have_content "Mailing List" + describe "Customers report" do + before do + login_to_admin_section + click_link "Reports" + end + scenario "customers report" do + click_link "Mailing List" + end + + scenario "customers report" do + click_link "Addresses" + end end scenario "orders and distributors report" do