mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Merging in master
This commit is contained in:
@@ -1,16 +1,11 @@
|
||||
Darkswarm.controller "AccordionCtrl", ($scope, storage, $timeout) ->
|
||||
Darkswarm.controller "AccordionCtrl", ($scope, storage, $timeout, CurrentHub) ->
|
||||
$scope.accordion =
|
||||
details: true
|
||||
shipping: false
|
||||
payment: false
|
||||
billing: false
|
||||
storage.bind $scope, "accordion", {storeName: "accordion_#{$scope.order.id}"}
|
||||
storage.bind $scope, "accordion", {storeName: "accordion_#{$scope.order.id}#{CurrentHub.id}#{$scope.order.user_id}"}
|
||||
|
||||
$scope.show = (name)->
|
||||
$scope.accordion[name] = true
|
||||
|
||||
#$timeout =>
|
||||
#if $scope.checkout.$valid
|
||||
#for k, v of $scope.accordion
|
||||
#$scope.accordion[k] = false
|
||||
|
||||
|
||||
@@ -8,4 +8,4 @@ Darkswarm.controller "BillingCtrl", ($scope, $timeout) ->
|
||||
$scope.order.bill_address.city,
|
||||
$scope.order.bill_address.zipcode]
|
||||
|
||||
#$timeout $scope.onTimeout
|
||||
$timeout $scope.onTimeout
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Darkswarm.directive "ofnEmptiesCart", (CurrentHub, CurrentOrder, Navigation) ->
|
||||
Darkswarm.directive "ofnEmptiesCart", (CurrentHub, CurrentOrder, Navigation, storage) ->
|
||||
restrict: "A"
|
||||
scope:
|
||||
hub: '=ofnEmptiesCart'
|
||||
@@ -10,6 +10,7 @@ Darkswarm.directive "ofnEmptiesCart", (CurrentHub, CurrentOrder, Navigation) ->
|
||||
elm.bind 'click', (ev)->
|
||||
ev.preventDefault()
|
||||
if confirm "Are you sure? This will change your selected Hub and remove any items in you shopping cart."
|
||||
storage.clearAll() # One day this will have to be moar GRANULAR
|
||||
Navigation.go scope.hub.path
|
||||
else
|
||||
scope.action = attr.shop
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
Darkswarm.directive "ofnFlash", (flash, $timeout)->
|
||||
Darkswarm.directive "ofnFlash", (flash, $timeout, RailsFlashLoader)->
|
||||
# Mappings between flash types (left) and Foundation classes
|
||||
typePairings =
|
||||
info: "standard"
|
||||
info: "info"
|
||||
error: "alert"
|
||||
success: "success"
|
||||
scope: {}
|
||||
restrict: 'AE'
|
||||
restrict: 'E'
|
||||
templateUrl: "flash.html"
|
||||
controller: ($scope)->
|
||||
$scope.closeAlert = (index)->
|
||||
@@ -21,3 +22,4 @@ Darkswarm.directive "ofnFlash", (flash, $timeout)->
|
||||
$scope.flashes.shift()
|
||||
|
||||
flash.subscribe(show)
|
||||
RailsFlashLoader.initFlash()
|
||||
|
||||
@@ -2,5 +2,7 @@ Darkswarm.factory 'CurrentOrder', (currentOrder) ->
|
||||
new class CurrentOrder
|
||||
constructor: ->
|
||||
@[k] = v for k, v of currentOrder
|
||||
@cart_count ?= 0
|
||||
|
||||
empty: =>
|
||||
@line_items.length == 0
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
Darkswarm.factory 'Flash', (flash)->
|
||||
new class Flash
|
||||
loadFlash: (rails_flash)->
|
||||
for type, message of rails_flash
|
||||
switch type
|
||||
when "notice"
|
||||
flash.info = message
|
||||
else
|
||||
flash[type] = message
|
||||
@@ -6,6 +6,7 @@ Darkswarm.factory "OfnMap", (enterprisesForMap, MapModal)->
|
||||
# Adding methods to each enterprise
|
||||
extend: (enterprise)->
|
||||
new class MapMarker
|
||||
<<<<<<< HEAD
|
||||
icon: "/test.opng"
|
||||
constructor: ->
|
||||
@[k] = v for k, v of enterprise
|
||||
@@ -13,4 +14,9 @@ Darkswarm.factory "OfnMap", (enterprisesForMap, MapModal)->
|
||||
reveal: =>
|
||||
|
||||
console.log @
|
||||
=======
|
||||
constructor: ->
|
||||
@[k] = v for k, v of enterprise
|
||||
reveal: =>
|
||||
>>>>>>> master
|
||||
MapModal.open @
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
Darkswarm.factory 'RailsFlashLoader', (flash, railsFlash)->
|
||||
new class RailsFlashLoader
|
||||
initFlash: ->
|
||||
@loadFlash railsFlash
|
||||
loadFlash: (rails_flash)->
|
||||
for type, message of rails_flash
|
||||
flash[type] = message
|
||||
@@ -2,7 +2,8 @@
|
||||
.small-12.columns.producer-hero
|
||||
%h3.producer-name
|
||||
%i.ofn-i_036-producers
|
||||
{{ producer.name }}
|
||||
{{ enterprise.name }}
|
||||
{{ enterprise.id }}
|
||||
%img.producer-hero-img{"ng-src" => "{{enterprise.promo_image}}"}
|
||||
|
||||
.row
|
||||
|
||||
@@ -37,7 +37,7 @@ class ApplicationController < ActionController::Base
|
||||
session[:expired_order_cycle_id] = current_order_cycle.id
|
||||
current_order.empty!
|
||||
current_order.set_order_cycle! nil
|
||||
flash[:notice] = "The order cycle you've selected has just closed. Please try again!"
|
||||
flash[:info] = "The order cycle you've selected has just closed. Please try again!"
|
||||
redirect_to root_url
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ class CheckoutController < Spree::CheckoutController
|
||||
end
|
||||
end
|
||||
if @order.state == "complete" || @order.completed?
|
||||
flash.notice = t(:order_processed_successfully)
|
||||
flash[:success] = t(:order_processed_successfully)
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
respond_with(@order, :location => order_path(@order))
|
||||
|
||||
@@ -356,19 +356,12 @@ Spree::Admin::ReportsController.class_eval do
|
||||
end
|
||||
params[:q][:meta_sort] ||= "completed_at.desc"
|
||||
|
||||
q = params[:q].dup
|
||||
if q[:order_cycle_id_eq] == '-1'
|
||||
q[:order_cycle_id_null] = true
|
||||
q[:order_cycle_id_eq] = nil
|
||||
end
|
||||
|
||||
# -- Search
|
||||
@search = Spree::Order.complete.not_state(:canceled).managed_by(spree_current_user).search(q)
|
||||
|
||||
@search = Spree::Order.complete.not_state(:canceled).managed_by(spree_current_user).search(params[:q])
|
||||
orders = @search.result
|
||||
@line_items = orders.map do |o|
|
||||
lis = o.line_items.managed_by(spree_current_user)
|
||||
lis = lis.supplied_by(params[:supplier_id]) if params[:supplier_id].present?
|
||||
lis = lis.supplied_by_any(params[:supplier_id_in]) if params[:supplier_id_in].present?
|
||||
lis
|
||||
end.flatten
|
||||
#payments = orders.map { |o| o.payments.select { |payment| payment.completed? } }.flatten # Only select completed payments
|
||||
@@ -393,7 +386,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
table_items = @line_items
|
||||
@include_blank = 'All'
|
||||
|
||||
header = ["Supplier", "Product", "Variant", "Amount", "Curr. Cost per Unit", "Total Cost", "Status", "Incoming Transport"]
|
||||
header = ["Producer", "Product", "Variant", "Amount", "Curr. Cost per Unit", "Total Cost", "Status", "Incoming Transport"]
|
||||
|
||||
columns = [ proc { |line_items| line_items.first.variant.product.supplier.name },
|
||||
proc { |line_items| line_items.first.variant.product.name },
|
||||
@@ -415,7 +408,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
table_items = @line_items
|
||||
@include_blank = 'All'
|
||||
|
||||
header = ["Supplier", "Product", "Variant", "To Distributor", "Amount", "Curr. Cost per Unit", "Total Cost", "Shipping Method"]
|
||||
header = ["Producer", "Product", "Variant", "To Hub", "Amount", "Curr. Cost per Unit", "Total Cost", "Shipping Method"]
|
||||
|
||||
columns = [ proc { |line_items| line_items.first.variant.product.supplier.name },
|
||||
proc { |line_items| line_items.first.variant.product.name },
|
||||
@@ -447,7 +440,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
table_items = @line_items
|
||||
@include_blank = 'All'
|
||||
|
||||
header = ["Distributor", "Supplier", "Product", "Variant", "Amount", "Curr. Cost per Unit", "Total Cost", "Total Shipping Cost", "Shipping Method"]
|
||||
header = ["Hub", "Producer", "Product", "Variant", "Amount", "Curr. Cost per Unit", "Total Cost", "Total Shipping Cost", "Shipping Method"]
|
||||
|
||||
columns = [ proc { |line_items| line_items.first.order.distributor.name },
|
||||
proc { |line_items| line_items.first.variant.product.supplier.name },
|
||||
@@ -481,12 +474,16 @@ Spree::Admin::ReportsController.class_eval do
|
||||
table_items = @line_items
|
||||
@include_blank = 'All'
|
||||
|
||||
header = ["Distributor", "Customer", "Email", "Phone", "Product", "Variant", "Amount", "Item ($)", "Ship ($)", "Total ($)", "Paid?", "Packed?", "Shipped?"]
|
||||
header = ["Hub", "Customer", "Email", "Phone", "Producer", "Product", "Variant", "Amount", "Item ($)", "Dist ($)", "Ship ($)", "Total ($)", "Paid?",
|
||||
"Shipping", "Delivery?", "Ship street", "Ship street 2", "Ship city", "Ship postcode", "Ship state"]
|
||||
|
||||
rsa = proc { |line_items| line_items.first.order.shipping_method.andand.require_ship_address }
|
||||
|
||||
columns = [ proc { |line_items| line_items.first.order.distributor.name },
|
||||
proc { |line_items| line_items.first.order.bill_address.firstname + " " + line_items.first.order.bill_address.lastname },
|
||||
proc { |line_items| line_items.first.order.email },
|
||||
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.sum { |li| li.quantity } },
|
||||
@@ -495,13 +492,21 @@ Spree::Admin::ReportsController.class_eval do
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| "" } ]
|
||||
|
||||
proc { |line_items| line_items.first.order.shipping_method.andand.name },
|
||||
proc { |line_items| rsa.call(line_items) ? 'Y' : 'N' },
|
||||
proc { |line_items| line_items.first.order.ship_address.andand.address1 if rsa.call(line_items) },
|
||||
proc { |line_items| line_items.first.order.ship_address.andand.address2 if rsa.call(line_items) },
|
||||
proc { |line_items| line_items.first.order.ship_address.andand.city if rsa.call(line_items) },
|
||||
proc { |line_items| line_items.first.order.ship_address.andand.zipcode if rsa.call(line_items) },
|
||||
proc { |line_items| line_items.first.order.ship_address.andand.state if rsa.call(line_items) }]
|
||||
|
||||
rules = [ { group_by: proc { |line_item| line_item.order.distributor },
|
||||
sort_by: proc { |distributor| distributor.name } },
|
||||
{ group_by: proc { |line_item| line_item.order },
|
||||
sort_by: proc { |order| order.bill_address.lastname + " " + order.bill_address.firstname },
|
||||
summary_columns: [ proc { |line_items| "" },
|
||||
summary_columns: [ proc { |line_items| line_items.first.order.distributor.name },
|
||||
proc { |line_items| line_items.first.order.bill_address.firstname + " " + line_items.first.order.bill_address.lastname },
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| "" },
|
||||
@@ -509,11 +514,19 @@ Spree::Admin::ReportsController.class_eval do
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| line_items.sum { |li| li.quantity * li.price } },
|
||||
proc { |line_items| line_items.map { |li| li.order }.uniq.sum { |o| o.distribution_total } },
|
||||
proc { |line_items| line_items.map { |li| li.order }.uniq.sum { |o| o.ship_total } },
|
||||
proc { |line_items| line_items.map { |li| li.order }.uniq.sum { |o| o.total } },
|
||||
proc { |line_items| line_items.map { |li| li.order.paid? }.all? { |paid| paid == true } ? "Yes" : "No" },
|
||||
proc { |line_items| line_items.all? { |li| li.order.paid? } ? "Yes" : "No" },
|
||||
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| "" } ] },
|
||||
|
||||
{ group_by: proc { |line_item| line_item.variant.product },
|
||||
sort_by: proc { |product| product.name } },
|
||||
{ group_by: proc { |line_item| line_item.variant },
|
||||
@@ -523,7 +536,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
table_items = @line_items
|
||||
@include_blank = 'All'
|
||||
|
||||
header = ["Supplier", "Product", "Variant", "Amount", "Curr. Cost per Unit", "Total Cost", "Status", "Incoming Transport"]
|
||||
header = ["Producer", "Product", "Variant", "Amount", "Curr. Cost per Unit", "Total Cost", "Status", "Incoming Transport"]
|
||||
|
||||
columns = [ proc { |line_items| line_items.first.variant.product.supplier.name },
|
||||
proc { |line_items| line_items.first.variant.product.name },
|
||||
|
||||
@@ -5,7 +5,7 @@ class UserPasswordsController < Spree::UserPasswordsController
|
||||
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
|
||||
|
||||
if resource.errors.empty?
|
||||
set_flash_message(:notice, :send_instructions) if is_navigational_format?
|
||||
set_flash_message(:success, :send_instructions) if is_navigational_format?
|
||||
respond_with resource, :location => spree.login_path
|
||||
else
|
||||
respond_to do |format|
|
||||
|
||||
@@ -4,7 +4,7 @@ class UserRegistrationsController < Spree::UserRegistrationsController
|
||||
def create
|
||||
@user = build_resource(params[:spree_user])
|
||||
if resource.save
|
||||
set_flash_message(:notice, :signed_up)
|
||||
set_flash_message(:success, :signed_up)
|
||||
sign_in(:spree_user, @user)
|
||||
session[:spree_user_signup] = true
|
||||
associate_user
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
module CheckoutHelper
|
||||
def checkout_adjustments_for_summary(order)
|
||||
def checkout_adjustments_for_summary(order, opts={})
|
||||
adjustments = order.adjustments.eligible
|
||||
|
||||
# Remove empty tax adjustments and (optionally) shipping fees
|
||||
adjustments.reject! { |a| a.originator_type == 'Spree::TaxRate' && a.amount == 0 }
|
||||
adjustments.reject! { |a| a.originator_type == 'Spree::ShippingMethod' } if opts[:exclude_shipping]
|
||||
|
||||
enterprise_fee_adjustments = adjustments.select { |a| a.originator_type == 'EnterpriseFee' }
|
||||
adjustments.reject! { |a| a.originator_type == 'EnterpriseFee' }
|
||||
|
||||
@@ -18,4 +18,8 @@ Spree::LineItem.class_eval do
|
||||
joins(:product).
|
||||
where('spree_products.supplier_id = ?', enterprise)
|
||||
}
|
||||
scope :supplied_by_any, lambda { |enterprises|
|
||||
joins(:product).
|
||||
where('spree_products.supplier_id IN (?)', enterprises)
|
||||
}
|
||||
end
|
||||
|
||||
@@ -75,6 +75,13 @@ Spree::Order.class_eval do
|
||||
errors.add(:distributor_id, "cannot supply the products in your cart") unless DistributionChangeValidator.new(self).can_change_to_distributor?(distributor)
|
||||
end
|
||||
end
|
||||
|
||||
def empty_with_clear_shipping_and_payments!
|
||||
empty_without_clear_shipping_and_payments!
|
||||
payments.clear
|
||||
update_attributes(shipping_method_id: nil)
|
||||
end
|
||||
alias_method_chain :empty!, :clear_shipping_and_payments
|
||||
|
||||
def set_order_cycle!(order_cycle)
|
||||
unless self.order_cycle == order_cycle
|
||||
@@ -127,7 +134,11 @@ Spree::Order.class_eval do
|
||||
end
|
||||
|
||||
def line_item_variants
|
||||
line_items.map { |li| li.variant }
|
||||
line_items.map(&:variant)
|
||||
end
|
||||
|
||||
def distribution_total
|
||||
adjustments.eligible.where(originator_type: 'EnterpriseFee').sum(&:amount)
|
||||
end
|
||||
|
||||
# Show payment methods for this distributor
|
||||
@@ -140,6 +151,8 @@ Spree::Order.class_eval do
|
||||
def available_shipping_methods(display_on = nil)
|
||||
Spree::ShippingMethod.all_available(self, display_on)
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def shipping_address_from_distributor
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
required: true,
|
||||
"ng-model" => "order.payment_method_id"
|
||||
= method.name
|
||||
.row{"ng-show" => "order.payment_method_id == #{method.id}"}
|
||||
.row{"ng-if" => "order.payment_method_id == #{method.id}"}
|
||||
.small-12.columns
|
||||
= render partial: "spree/checkout/payment/#{method.method_type}", :locals => { :payment_method => method }
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
%th Produce
|
||||
%td= current_order.display_item_total
|
||||
|
||||
- checkout_adjustments_for_summary(current_order).each do |adjustment|
|
||||
- checkout_adjustments_for_summary(current_order, exclude_shipping: true).each do |adjustment|
|
||||
%tr
|
||||
%th= adjustment.label
|
||||
%td= adjustment.display_amount.to_html
|
||||
|
||||
2
app/views/json/_flash.rabl
Normal file
2
app/views/json/_flash.rabl
Normal file
@@ -0,0 +1,2 @@
|
||||
object OpenStruct.new(flash)
|
||||
attributes :info, :success, :error
|
||||
@@ -21,12 +21,12 @@
|
||||
= inject_json "currentHub", "current_hub"
|
||||
= inject_json "currentOrder", "current_order"
|
||||
= inject_json "user", "current_user"
|
||||
= inject_json "railsFlash", "flash"
|
||||
|
||||
.off-canvas-wrap{offcanvas: true}
|
||||
.inner-wrap
|
||||
= render partial: "shared/menu/menu"
|
||||
|
||||
= display_flash_messages
|
||||
%ofn-flash
|
||||
|
||||
%section{ role: "main" }
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
%span.nav-primary Hubs
|
||||
%li.divider
|
||||
%li
|
||||
%a{href: map_path}
|
||||
%a{href: main_app.map_path}
|
||||
%span.nav-primary Map
|
||||
%li.divider
|
||||
%li
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
%i.ofn-i_040-hub
|
||||
Hubs
|
||||
%li
|
||||
%a{href: ""}
|
||||
%a{href: main_app.map_path}
|
||||
%span.nav-primary
|
||||
%i.ofn-i_037-map
|
||||
Map
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
.small-12.large-9.columns
|
||||
%p= current_distributor.long_description.andand.html_safe
|
||||
|
||||
- if current_distributor.promo_image.exists?
|
||||
.small-12.large-3.columns
|
||||
%img.about.right{src: current_distributor.promo_image.url(:large)}
|
||||
-#- if current_distributor.promo_image.exists?
|
||||
-#.small-12.large-3.columns
|
||||
-#%img.about.right{src: current_distributor.promo_image.url(:large)}
|
||||
|
||||
|
||||
@@ -1,33 +1,39 @@
|
||||
= form_for @search, :url => spree.orders_and_fulfillment_admin_reports_path do |f|
|
||||
= label_tag nil, t(:date_range)
|
||||
%br
|
||||
.date-range-filter
|
||||
.row.date-range-filter
|
||||
= label_tag nil, t(:date_range)
|
||||
%br
|
||||
= label_tag nil, t(:start), :class => 'inline'
|
||||
= f.text_field :completed_at_gt, :class => 'datetimepicker datepicker-from'
|
||||
%span.range-divider
|
||||
%i.icon-arrow-right
|
||||
= f.text_field :completed_at_lt, :class => 'datetimepicker datepicker-to'
|
||||
= label_tag nil, t(:end), :class => 'inline'
|
||||
%br
|
||||
= label_tag nil, "Distributor: "
|
||||
= f.collection_select(:distributor_id_eq, @distributors, :id, :name, :include_blank => @include_blank)
|
||||
%br
|
||||
= label_tag nil, "Supplier: "
|
||||
= select_tag(:supplier_id, options_from_collection_for_select(@suppliers, :id, :name, params[:supplier_id]), :prompt => @include_blank)
|
||||
%br
|
||||
= label_tag nil, "Order Cycle: "
|
||||
- order_cycles_select = [['No Order Cycle', '-1']]
|
||||
- order_cycles_select += @order_cycles.collect {|oc| [ "#{oc.name} (#{oc.orders_open_at.to_s(:short)} - #{oc.orders_close_at.to_s(:short)})".html_safe, oc.id ] }
|
||||
= f.select(:order_cycle_id_eq, order_cycles_select, include_blank: @include_blank, selected: params[:q][:order_cycle_id_eq])
|
||||
%br
|
||||
= label_tag nil, "Report Type: "
|
||||
= select_tag(:report_type, options_for_select(@report_types, @report_type))
|
||||
%br
|
||||
%br
|
||||
= check_box_tag :csv
|
||||
= label_tag :csv, "Download as csv"
|
||||
%br
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, "Hubs: "
|
||||
.omega.fourteen.columns= f.collection_select(:distributor_id_in, @distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, "Producers: "
|
||||
.omega.fourteen.columns= select_tag(:supplier_id_in, options_from_collection_for_select(@suppliers, :id, :name, params[:supplier_id_in]), {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, "Order Cycles: "
|
||||
.omega.fourteen.columns
|
||||
- order_cycles_select = @order_cycles.collect {|oc| [ "#{oc.name} (#{oc.orders_open_at.to_s(:short)} - #{oc.orders_close_at.to_s(:short)})".html_safe, oc.id ] }
|
||||
= f.select(:order_cycle_id_in, order_cycles_select, {selected: params[:q][:order_cycle_id_in]}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, "Report Type: "
|
||||
.omega.fourteen.columns= select_tag(:report_type, options_for_select(@report_types, @report_type))
|
||||
|
||||
.row
|
||||
= check_box_tag :csv
|
||||
= label_tag :csv, "Download as csv"
|
||||
|
||||
.row
|
||||
= button t(:search)
|
||||
|
||||
%br
|
||||
%br
|
||||
%table#listing_orders.index
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
.row
|
||||
.small-6.columns
|
||||
%label
|
||||
First Name
|
||||
%input{type: :text, disabled: true, "ng-value" => "order.bill_address.firstname"}
|
||||
|
||||
.small-6.columns
|
||||
%label
|
||||
Last Name
|
||||
%input{type: :text, disabled: true, "ng-value" => "order.bill_address.lastname"}
|
||||
|
||||
.small-6.columns
|
||||
= validated_input "Card Number", "secrets.card_number", required: true, maxlength: 19, autocomplete: "off"
|
||||
.small-6.columns
|
||||
@@ -13,4 +23,3 @@
|
||||
%select{"ng-model" => "secrets.card_month", "ng-options" => "number as name for (number, name) in months", name: "secrets.card_month", required: true}
|
||||
.small-6.columns
|
||||
%select{"ng-model" => "secrets.card_year", "ng-options" => "year for year in years", name: "secrets.card_year", required: true}
|
||||
|
||||
|
||||
@@ -3,7 +3,11 @@ Openfoodnetwork::Application.routes.draw do
|
||||
|
||||
get "/#/login", to: "home#index", as: :spree_login
|
||||
|
||||
get "/map", to: "map#index", as: :map
|
||||
if Rails.env.production?
|
||||
get "/map", to: "home#index", as: :map
|
||||
else
|
||||
get "/map", to: "map#index", as: :map
|
||||
end
|
||||
|
||||
resource :shop, controller: "shop" do
|
||||
get :products
|
||||
|
||||
@@ -16,6 +16,6 @@ describe BaseController do
|
||||
oc.stub(:closed?).and_return true
|
||||
get :index
|
||||
response.should redirect_to root_url
|
||||
flash[:notice].should == "The order cycle you've selected has just closed. Please try again!"
|
||||
flash[:info].should == "The order cycle you've selected has just closed. Please try again!"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -107,7 +107,7 @@ describe Spree::Admin::ReportsController do
|
||||
end
|
||||
|
||||
it "only shows the selected order cycle" do
|
||||
spree_get :orders_and_fulfillment, q: {order_cycle_id_eq: ocA.id}
|
||||
spree_get :orders_and_fulfillment, q: {order_cycle_id_in: [ocA.id.to_s]}
|
||||
|
||||
assigns(:search).result.should include(orderA1)
|
||||
assigns(:search).result.should_not include(orderB1)
|
||||
|
||||
@@ -91,12 +91,12 @@ feature %q{
|
||||
|
||||
scenario "should not be able to see system configuration" do
|
||||
visit '/admin/general_settings/edit'
|
||||
page.should have_content 'Authorization Failure'
|
||||
page.should have_content 'Unauthorized'
|
||||
end
|
||||
|
||||
scenario "should not be able to see user management" do
|
||||
visit '/admin/users'
|
||||
page.should have_content 'Authorization Failure'
|
||||
page.should have_content 'Unauthorized'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -146,6 +146,21 @@ feature "As a consumer I want to check out my cart", js: true do
|
||||
place_order
|
||||
page.should have_content "Your order has been processed successfully"
|
||||
end
|
||||
|
||||
it "shows the payment processing failed message when submitted with an invalid credit card" do
|
||||
toggle_payment
|
||||
fill_in 'Card Number', with: "9999999988887777"
|
||||
select 'February', from: 'secrets.card_month'
|
||||
select (Date.today.year+1).to_s, from: 'secrets.card_year'
|
||||
fill_in 'Security Code', with: '123'
|
||||
|
||||
place_order
|
||||
page.should have_content "Payment could not be processed, please check the details you entered"
|
||||
|
||||
# Does not show duplicate shipping fee
|
||||
visit checkout_path
|
||||
page.all("th", text: "Shipping").count.should == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,21 +3,27 @@ require 'spec_helper'
|
||||
module Spree
|
||||
describe LineItem do
|
||||
describe "scopes" do
|
||||
let(:o) { create(:order) }
|
||||
|
||||
let(:s1) { create(:supplier_enterprise) }
|
||||
let(:s2) { create(:supplier_enterprise) }
|
||||
|
||||
let(:p1) { create(:simple_product, supplier: s1) }
|
||||
let(:p2) { create(:simple_product, supplier: s2) }
|
||||
|
||||
let(:li1) { create(:line_item, order: o, product: p1) }
|
||||
let(:li2) { create(:line_item, order: o, product: p2) }
|
||||
|
||||
it "finds line items for products supplied by a particular enterprise" do
|
||||
o = create(:order)
|
||||
|
||||
s1 = create(:supplier_enterprise)
|
||||
s2 = create(:supplier_enterprise)
|
||||
|
||||
p1 = create(:simple_product, supplier: s1)
|
||||
p2 = create(:simple_product, supplier: s2)
|
||||
|
||||
li1 = create(:line_item, order: o, product: p1)
|
||||
li2 = create(:line_item, order: o, product: p2)
|
||||
|
||||
LineItem.supplied_by(s1).should == [li1]
|
||||
LineItem.supplied_by(s2).should == [li2]
|
||||
end
|
||||
|
||||
it "finds line items for products supplied by one of a number of enterprises" do
|
||||
LineItem.supplied_by_any([s1]).should == [li1]
|
||||
LineItem.supplied_by_any([s2]).should == [li2]
|
||||
LineItem.supplied_by_any([s1, s2]).sort.should == [li1, li2].sort
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -141,6 +141,37 @@ describe Spree::Order do
|
||||
end
|
||||
end
|
||||
|
||||
describe "getting the distribution charge" do
|
||||
let(:o) { create(:order) }
|
||||
let(:li) { create(:line_item, order: o) }
|
||||
|
||||
it "returns the sum of eligible enterprise fee adjustments" do
|
||||
ef = create(:enterprise_fee)
|
||||
ef.calculator.set_preference :amount, 123.45
|
||||
a = ef.create_locked_adjustment("adjustment", li.order, li, true)
|
||||
|
||||
o.distribution_total.should == 123.45
|
||||
end
|
||||
|
||||
it "does not include ineligible adjustments" do
|
||||
ef = create(:enterprise_fee)
|
||||
ef.calculator.set_preference :amount, 123.45
|
||||
a = ef.create_locked_adjustment("adjustment", li.order, li, true)
|
||||
|
||||
a.update_column :eligible, false
|
||||
|
||||
o.distribution_total.should == 0
|
||||
end
|
||||
|
||||
it "does not include adjustments that do not originate from enterprise fees" do
|
||||
sm = create(:shipping_method)
|
||||
sm.calculator.set_preference :amount, 123.45
|
||||
sm.create_adjustment("adjustment", li.order, li, true)
|
||||
|
||||
o.distribution_total.should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "setting the distributor" do
|
||||
it "sets the distributor when no order cycle is set" do
|
||||
d = create(:distributor_enterprise)
|
||||
@@ -180,6 +211,22 @@ describe Spree::Order do
|
||||
end
|
||||
end
|
||||
|
||||
describe "emptying the order" do
|
||||
it "removes shipping method" do
|
||||
subject.shipping_method = create(:shipping_method)
|
||||
subject.save!
|
||||
subject.empty!
|
||||
subject.shipping_method.should == nil
|
||||
end
|
||||
|
||||
it "removes payments" do
|
||||
subject.payments << create(:payment)
|
||||
subject.save!
|
||||
subject.empty!
|
||||
subject.payments.should == []
|
||||
end
|
||||
end
|
||||
|
||||
describe "setting the order cycle" do
|
||||
let(:oc) { create(:simple_order_cycle) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user