mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-23 05:28:53 +00:00
Merge branch 'bug-herd' into working
This commit is contained in:
@@ -113,7 +113,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
columns = [ proc { |lis| lis.first.variant.product.supplier.name },
|
||||
proc { |lis| lis.first.variant.product.name },
|
||||
proc { |lis| lis.first.variant.product.group_buy ? (lis.first.variant.product.group_buy_unit_size || 0.0) : "" },
|
||||
proc { |lis| lis.first.variant.options_text },
|
||||
proc { |lis| lis.first.variant.full_name },
|
||||
proc { |lis| lis.first.variant.weight || 0 },
|
||||
proc { |lis| lis.sum { |li| li.quantity } },
|
||||
proc { |lis| lis.sum { |li| li.max_quantity || 0 } },
|
||||
@@ -134,7 +134,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
proc { |lis| ( (lis.first.variant.product.group_buy_unit_size || 0).zero? ? 0 : ( lis.sum { |li| ( [li.max_quantity || 0, li.quantity || 0].max ) * (li.variant.weight || 0) } / lis.first.variant.product.group_buy_unit_size ) ).floor },
|
||||
proc { |lis| lis.sum { |li| ( [li.max_quantity || 0, li.quantity || 0].max) * (li.variant.weight || 0) } - ( ( (lis.first.variant.product.group_buy_unit_size || 0).zero? ? 0 : ( lis.sum { |li| ( [li.max_quantity || 0, li.quantity || 0].max) * (li.variant.weight || 0) } / lis.first.variant.product.group_buy_unit_size ) ).floor * (lis.first.variant.product.group_buy_unit_size || 0) ) } ] },
|
||||
{ group_by: proc { |li| li.variant },
|
||||
sort_by: proc { |variant| variant.options_text } } ]
|
||||
sort_by: proc { |variant| variant.full_name } } ]
|
||||
|
||||
when "bulk_coop_allocation"
|
||||
|
||||
@@ -143,7 +143,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
columns = [ proc { |lis| lis.first.order.bill_address.firstname + " " + lis.first.order.bill_address.lastname },
|
||||
proc { |lis| lis.first.variant.product.name },
|
||||
proc { |lis| lis.first.variant.product.group_buy ? (lis.first.variant.product.group_buy_unit_size || 0.0) : "" },
|
||||
proc { |lis| lis.first.variant.options_text },
|
||||
proc { |lis| lis.first.variant.full_name },
|
||||
proc { |lis| lis.first.variant.weight || 0 },
|
||||
proc { |lis| lis.sum { |li| li.quantity } },
|
||||
proc { |lis| lis.sum { |li| li.max_quantity || 0 } },
|
||||
@@ -162,7 +162,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
proc { |lis| ( (lis.first.variant.product.group_buy_unit_size || 0).zero? ? 0 : ( lis.sum { |li| ( [li.max_quantity || 0, li.quantity || 0].max ) * (li.variant.weight || 0) } / lis.first.variant.product.group_buy_unit_size ) ).floor * (lis.first.variant.product.group_buy_unit_size || 0) },
|
||||
proc { |lis| lis.sum { |li| ( [li.max_quantity || 0, li.quantity || 0].max ) * (li.variant.weight || 0) } - ( ( (lis.first.variant.product.group_buy_unit_size || 0).zero? ? 0 : ( lis.sum { |li| ( [li.max_quantity || 0, li.quantity || 0].max ) * (li.variant.weight || 0) } / lis.first.variant.product.group_buy_unit_size ) ).floor * (lis.first.variant.product.group_buy_unit_size || 0) ) } ] },
|
||||
{ group_by: proc { |li| li.variant },
|
||||
sort_by: proc { |variant| variant.options_text } },
|
||||
sort_by: proc { |variant| variant.full_name } },
|
||||
{ group_by: proc { |li| li.order },
|
||||
sort_by: proc { |order| order.to_s } } ]
|
||||
|
||||
@@ -172,13 +172,13 @@ Spree::Admin::ReportsController.class_eval do
|
||||
|
||||
columns = [ proc { |lis| lis.first.order.bill_address.firstname + " " + lis.first.order.bill_address.lastname },
|
||||
proc { |lis| lis.first.variant.product.name },
|
||||
proc { |lis| lis.first.variant.options_text },
|
||||
proc { |lis| lis.first.variant.full_name },
|
||||
proc { |lis| lis.sum { |li| li.quantity } } ]
|
||||
|
||||
rules = [ { group_by: proc { |li| li.variant.product },
|
||||
sort_by: proc { |product| product.name } },
|
||||
{ group_by: proc { |li| li.variant },
|
||||
sort_by: proc { |variant| variant.options_text } },
|
||||
sort_by: proc { |variant| variant.full_name } },
|
||||
{ group_by: proc { |li| li.order },
|
||||
sort_by: proc { |order| order.to_s } } ]
|
||||
|
||||
@@ -202,7 +202,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
columns = [ proc { |lis| lis.first.variant.product.supplier.name },
|
||||
proc { |lis| lis.first.variant.product.name },
|
||||
proc { |lis| lis.first.variant.product.group_buy ? (lis.first.variant.product.group_buy_unit_size || 0.0) : "" },
|
||||
proc { |lis| lis.first.variant.options_text },
|
||||
proc { |lis| lis.first.variant.full_name },
|
||||
proc { |lis| lis.first.variant.weight || 0 },
|
||||
proc { |lis| lis.sum { |li| li.quantity } },
|
||||
proc { |lis| lis.sum { |li| li.max_quantity || 0 } },
|
||||
@@ -223,7 +223,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
proc { |lis| ( (lis.first.variant.product.group_buy_unit_size || 0).zero? ? 0 : ( lis.sum { |li| ( [li.max_quantity || 0, li.quantity || 0].max ) * (li.variant.weight || 0) } / lis.first.variant.product.group_buy_unit_size ) ).floor },
|
||||
proc { |lis| lis.sum { |li| ( [li.max_quantity || 0, li.quantity || 0].max ) * (li.variant.weight || 0) } - ( ( (lis.first.variant.product.group_buy_unit_size || 0).zero? ? 0 : ( lis.sum { |li| ( [li.max_quantity || 0, li.quantity || 0].max ) * (li.variant.weight || 0) } / lis.first.variant.product.group_buy_unit_size ) ).floor * (lis.first.variant.product.group_buy_unit_size || 0) ) } ] },
|
||||
{ group_by: proc { |li| li.variant },
|
||||
sort_by: proc { |variant| variant.options_text } } ]
|
||||
sort_by: proc { |variant| variant.full_name } } ]
|
||||
|
||||
end
|
||||
|
||||
@@ -390,7 +390,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
|
||||
columns = [ proc { |line_items| line_items.first.variant.product.supplier.name },
|
||||
proc { |line_items| line_items.first.variant.product.name },
|
||||
proc { |line_items| line_items.first.variant.options_text },
|
||||
proc { |line_items| line_items.first.variant.full_name },
|
||||
proc { |line_items| line_items.sum { |li| li.quantity } },
|
||||
proc { |line_items| line_items.first.variant.price },
|
||||
proc { |line_items| line_items.sum { |li| li.quantity * li.price } },
|
||||
@@ -402,7 +402,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
{ group_by: proc { |line_item| line_item.variant.product },
|
||||
sort_by: proc { |product| product.name } },
|
||||
{ group_by: proc { |line_item| line_item.variant },
|
||||
sort_by: proc { |variant| variant.options_text } } ]
|
||||
sort_by: proc { |variant| variant.full_name } } ]
|
||||
|
||||
when "order_cycle_supplier_totals_by_distributor"
|
||||
table_items = @line_items
|
||||
@@ -412,7 +412,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
|
||||
columns = [ proc { |line_items| line_items.first.variant.product.supplier.name },
|
||||
proc { |line_items| line_items.first.variant.product.name },
|
||||
proc { |line_items| line_items.first.variant.options_text },
|
||||
proc { |line_items| line_items.first.variant.full_name },
|
||||
proc { |line_items| line_items.first.order.distributor.name },
|
||||
proc { |line_items| line_items.sum { |li| li.quantity } },
|
||||
proc { |line_items| line_items.first.variant.price },
|
||||
@@ -424,7 +424,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
{ group_by: proc { |line_item| line_item.variant.product },
|
||||
sort_by: proc { |product| product.name } },
|
||||
{ group_by: proc { |line_item| line_item.variant },
|
||||
sort_by: proc { |variant| variant.options_text },
|
||||
sort_by: proc { |variant| variant.full_name },
|
||||
summary_columns: [ proc { |line_items| "" },
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| "" },
|
||||
@@ -445,7 +445,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
columns = [ proc { |line_items| line_items.first.order.distributor.name },
|
||||
proc { |line_items| line_items.first.variant.product.supplier.name },
|
||||
proc { |line_items| line_items.first.variant.product.name },
|
||||
proc { |line_items| line_items.first.variant.options_text },
|
||||
proc { |line_items| line_items.first.variant.full_name },
|
||||
proc { |line_items| line_items.sum { |li| li.quantity } },
|
||||
proc { |line_items| line_items.first.variant.price },
|
||||
proc { |line_items| line_items.sum { |li| li.quantity * li.price } },
|
||||
@@ -468,7 +468,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
{ group_by: proc { |line_item| line_item.variant.product },
|
||||
sort_by: proc { |product| product.name } },
|
||||
{ group_by: proc { |line_item| line_item.variant },
|
||||
sort_by: proc { |variant| variant.options_text } } ]
|
||||
sort_by: proc { |variant| variant.full_name } } ]
|
||||
|
||||
when "order_cycle_customer_totals"
|
||||
table_items = @line_items
|
||||
@@ -485,7 +485,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
proc { |line_items| line_items.first.order.bill_address.phone },
|
||||
proc { |line_items| line_items.first.variant.product.supplier.name },
|
||||
proc { |line_items| line_items.first.variant.product.name },
|
||||
proc { |line_items| line_items.first.variant.options_text },
|
||||
proc { |line_items| line_items.first.variant.full_name },
|
||||
proc { |line_items| line_items.sum { |li| li.quantity } },
|
||||
proc { |line_items| line_items.sum { |li| li.quantity * li.price } },
|
||||
proc { |line_items| "" },
|
||||
@@ -530,7 +530,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
{ group_by: proc { |line_item| line_item.variant.product },
|
||||
sort_by: proc { |product| product.name } },
|
||||
{ group_by: proc { |line_item| line_item.variant },
|
||||
sort_by: proc { |variant| variant.options_text } } ]
|
||||
sort_by: proc { |variant| variant.full_name } } ]
|
||||
|
||||
else
|
||||
table_items = @line_items
|
||||
@@ -540,7 +540,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
|
||||
columns = [ proc { |line_items| line_items.first.variant.product.supplier.name },
|
||||
proc { |line_items| line_items.first.variant.product.name },
|
||||
proc { |line_items| line_items.first.variant.options_text },
|
||||
proc { |line_items| line_items.first.variant.full_name },
|
||||
proc { |line_items| line_items.sum { |li| li.quantity } },
|
||||
proc { |line_items| line_items.first.variant.price },
|
||||
proc { |line_items| line_items.sum { |li| li.quantity * li.price } },
|
||||
@@ -552,7 +552,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
{ group_by: proc { |line_item| line_item.variant.product },
|
||||
sort_by: proc { |product| product.name } },
|
||||
{ group_by: proc { |line_item| line_item.variant },
|
||||
sort_by: proc { |variant| variant.options_text } } ]
|
||||
sort_by: proc { |variant| variant.full_name } } ]
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -45,6 +45,11 @@ Spree::Variant.class_eval do
|
||||
self.option_values.destroy ovs
|
||||
end
|
||||
|
||||
def full_name
|
||||
return unit_to_display if display_name.blank?
|
||||
display_name + " (" + unit_to_display + ")"
|
||||
end
|
||||
|
||||
def name_to_display
|
||||
display_name || product.name
|
||||
end
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
Deface::Override.new(:virtual_path => "spree/admin/shared/_product_sub_menu",
|
||||
:name => "add_bulk_edit_tab_to_products_admin_sub_menu",
|
||||
:insert_bottom => "[data-hook='admin_product_sub_tabs']",
|
||||
:text => "<%= tab :bulk_product_edit, :url => bulk_edit_admin_products_path, :match_path => '/products/bulk_edit' %>")
|
||||
@@ -0,0 +1,3 @@
|
||||
/ replace "code[erb-loud]:contains('button_link_to t(:back_to_products_list)')"
|
||||
|
||||
= button_link_to t(:back_to_products_list), bulk_edit_admin_products_path, :icon => 'icon-arrow-left'
|
||||
@@ -73,7 +73,7 @@
|
||||
= button "Create And Add Another", 'icon-repeat', :submit, value: 'add_another'
|
||||
%span.or
|
||||
= t(:or)
|
||||
= link_to_with_icon 'icon-remove', t('actions.cancel'), collection_url, :class => 'button'
|
||||
= link_to_with_icon 'icon-remove', t('actions.cancel'), bulk_edit_admin_products_path, :class => 'button'
|
||||
|
||||
|
||||
:javascript
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/ replace_contents "title"
|
||||
|
||||
= "OFN #{t(:administration)}:"
|
||||
= t(controller.controller_name, :default => controller.controller_name.titleize)
|
||||
@@ -0,0 +1,4 @@
|
||||
/ insert_bottom "[data-hook='admin_product_sub_tabs']"
|
||||
|
||||
- if spree_current_user.admin?
|
||||
= tab :spree_products, url: admin_products_path, :match_path => '/products'
|
||||
@@ -0,0 +1,3 @@
|
||||
/ replace "code[erb-loud]:contains('tab :products')"
|
||||
|
||||
= tab :products, url: bulk_edit_admin_products_path, :match_path => '/products'
|
||||
@@ -126,19 +126,19 @@
|
||||
.omega.eight.columns
|
||||
= f.text_field :website, { placeholder: "eg. www.truffles.com"}
|
||||
.row
|
||||
.alpha.two.columns
|
||||
.alpha.three.columns
|
||||
= f.label :facebook, 'Facebook'
|
||||
.omega.four.columns
|
||||
.omega.eight.columns
|
||||
= f.text_field :facebook
|
||||
.row
|
||||
.alpha.two.columns
|
||||
.alpha.three.columns
|
||||
= f.label :instagram, 'Instagram'
|
||||
.omega.four.columns
|
||||
.omega.eight.columns
|
||||
= f.text_field :instagram
|
||||
.row
|
||||
.alpha.two.columns
|
||||
.alpha.three.columns
|
||||
= f.label :linkedin, 'LinkedIn'
|
||||
.omega.four.columns
|
||||
.omega.eight.columns
|
||||
= f.text_field :linkedin
|
||||
.row
|
||||
.alpha.three.columns
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
- content_for :page_actions do
|
||||
%li#new_product_link
|
||||
= button_link_to "New Enterprise", main_app.new_admin_enterprise_path, :icon => 'add', :id => 'admin_new_enterprise_link'
|
||||
= button_link_to "New Enterprise", main_app.new_admin_enterprise_path, :icon => 'icon-plus', :id => 'admin_new_enterprise_link'
|
||||
|
||||
= render 'admin/shared/enterprises_sub_menu'
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
= f.fields_for :collection do |enterprise_form|
|
||||
- enterprise = enterprise_form.object
|
||||
%tr{class: "enterprise-#{enterprise.id}"}
|
||||
%td= link_to enterprise.name, main_app.admin_enterprise_path(enterprise)
|
||||
%td= link_to enterprise.name, main_app.edit_admin_enterprise_path(enterprise)
|
||||
%td
|
||||
- if enterprise.is_primary_producer && enterprise.is_distributor
|
||||
Producer & Distributor
|
||||
Producer & Distributor
|
||||
- elsif enterprise.is_distributor
|
||||
Distributor
|
||||
- elsif enterprise.is_primary_producer
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
%h1 Enterprise
|
||||
%table
|
||||
%tr
|
||||
%th Name:
|
||||
%td= @enterprise.name
|
||||
%tr
|
||||
%th Description:
|
||||
%td= @enterprise.description
|
||||
%tr{"data-hook" => "long_description"}
|
||||
%th Extended Description:
|
||||
%td= @enterprise.long_description.andand.html_safe
|
||||
%tr
|
||||
%th Primary producer?
|
||||
%td= @enterprise.is_primary_producer ? 'Yes' : 'No'
|
||||
%tr
|
||||
%th Distributor?
|
||||
%td= @enterprise.is_distributor ? 'Yes' : 'No'
|
||||
%tr
|
||||
%th Contact person:
|
||||
%td= @enterprise.contact
|
||||
%tr
|
||||
%th Phone number:
|
||||
%td= @enterprise.phone
|
||||
%tr
|
||||
%th Email:
|
||||
%td= @enterprise.email
|
||||
%tr
|
||||
%th Website:
|
||||
%td= @enterprise.website
|
||||
%tr
|
||||
%th Twitter:
|
||||
%td= @enterprise.twitter
|
||||
%tr
|
||||
%th ABN:
|
||||
%td= @enterprise.abn
|
||||
%tr
|
||||
%th ACN:
|
||||
%td= @enterprise.acn
|
||||
%tr
|
||||
%th Address:
|
||||
%td= render 'spree/shared/address', :address => @enterprise.address
|
||||
%tr
|
||||
%th Regular pickup times:
|
||||
%td= @enterprise.pickup_times
|
||||
%tr
|
||||
%th Next collection date/time:
|
||||
%td= @enterprise.next_collection_at
|
||||
%p
|
||||
= link_to :Edit, main_app.edit_admin_enterprise_path(@enterprise), :class => 'edit_enterprise'
|
||||
= t(:or)
|
||||
= link_to t(:back), main_app.admin_enterprises_path
|
||||
@@ -21,5 +21,7 @@
|
||||
%br/
|
||||
%span.with-tip{'data-powertip' => variant_images}= "#{order_cycle.variants.count} variants"
|
||||
|
||||
%td.actions
|
||||
= link_to '', main_app.edit_admin_order_cycle_path(order_cycle), class: 'edit-order-cycle icon-edit no-text'
|
||||
%td.actions
|
||||
= link_to '', main_app.clone_admin_order_cycle_path(order_cycle), class: 'clone-order-cycle icon-copy no-text'
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
= content_for :page_actions do
|
||||
%li#new_order_cycle_link
|
||||
= button_link_to "New Order Cycle", main_app.new_admin_order_cycle_path, :icon => 'add', :id => 'admin_new_order_cycle_link'
|
||||
= button_link_to "New Order Cycle", main_app.new_admin_order_cycle_path, :icon => 'icon-plus', :id => 'admin_new_order_cycle_link'
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
%col
|
||||
%col
|
||||
%col
|
||||
%col
|
||||
|
||||
%thead
|
||||
%tr
|
||||
@@ -29,6 +30,7 @@
|
||||
%th Distributors
|
||||
%th Products
|
||||
%th.actions
|
||||
%th.actions
|
||||
|
||||
%tbody
|
||||
= f.fields_for :collection do |order_cycle_form|
|
||||
|
||||
@@ -26,7 +26,7 @@ module OpenFoodNetwork
|
||||
variant.product.supplier.address.city,
|
||||
variant.product.name,
|
||||
variant.product.properties.map(&:name).join(", "),
|
||||
variant.options_text,
|
||||
variant.full_name,
|
||||
variant.price,
|
||||
variant.product.group_buy_unit_size,
|
||||
""
|
||||
|
||||
@@ -99,9 +99,7 @@ feature %q{
|
||||
context "additional fields" do
|
||||
it "should have a notes field" do
|
||||
product = create(:simple_product, supplier: @supplier2)
|
||||
click_link 'Products'
|
||||
within('#sub_nav') { click_link 'Products' }
|
||||
click_link product.name
|
||||
visit spree.edit_admin_product_path product
|
||||
page.should have_content "Notes"
|
||||
end
|
||||
end
|
||||
@@ -132,9 +130,7 @@ feature %q{
|
||||
scenario "editing product distributions" do
|
||||
product = create(:simple_product, supplier: @supplier2)
|
||||
|
||||
click_link 'Products'
|
||||
within('#sub_nav') { click_link 'Products' }
|
||||
click_link product.name
|
||||
visit spree.edit_admin_product_path product
|
||||
within('#sidebar') { click_link 'Product Distributions' }
|
||||
|
||||
check @distributors[0].name
|
||||
|
||||
@@ -13,10 +13,7 @@ feature %q{
|
||||
|
||||
# When I create a variant on the product
|
||||
login_to_admin_section
|
||||
click_link 'Products'
|
||||
within('#sub_nav') { click_link 'Products' }
|
||||
click_link p.name
|
||||
click_link 'Variants'
|
||||
visit spree.admin_product_variants_path p
|
||||
click_link 'New Variant'
|
||||
|
||||
fill_in 'variant_unit_value', with: '1'
|
||||
@@ -38,10 +35,7 @@ feature %q{
|
||||
|
||||
# When I view the variant
|
||||
login_to_admin_section
|
||||
click_link 'Products'
|
||||
within('#sub_nav') { click_link 'Products' }
|
||||
click_link p.name
|
||||
click_link 'Variants'
|
||||
visit spree.admin_product_variants_path p
|
||||
page.find('table.index .icon-edit').click
|
||||
|
||||
# Then I should not see a traditional option value field for the unit-related option value
|
||||
@@ -73,10 +67,7 @@ feature %q{
|
||||
|
||||
# When I view the variant
|
||||
login_to_admin_section
|
||||
click_link 'Products'
|
||||
within('#sub_nav') { click_link 'Products' }
|
||||
click_link p.name
|
||||
click_link 'Variants'
|
||||
visit spree.admin_product_variants_path p
|
||||
page.find('table.index .icon-edit').click
|
||||
|
||||
# Then I should not see unit value and description fields
|
||||
|
||||
@@ -27,7 +27,7 @@ module OpenFoodNetwork
|
||||
|
||||
it "should build a table from a list of variants" do
|
||||
variant = double(:variant, sku: "sku",
|
||||
options_text: "Variant Name",
|
||||
full_name: "Variant Name",
|
||||
count_on_hand: 10,
|
||||
price: 100)
|
||||
variant.stub_chain(:product, :supplier, :name).and_return("Supplier")
|
||||
|
||||
Reference in New Issue
Block a user