Merge branch 'master' into redesign

Conflicts:
	app/assets/javascripts/templates/product_modal.html.haml
This commit is contained in:
Rohan Mitchell
2015-05-13 09:53:20 +10:00
42 changed files with 557 additions and 114 deletions

View File

@@ -0,0 +1,8 @@
Spree::Admin::LineItemsController.class_eval do
private
def load_order
@order = Spree::Order.find_by_number!(params[:order_id])
authorize! :update, @order
end
end

View File

@@ -9,6 +9,13 @@ Spree::Admin::OrdersController.class_eval do
# in an auth failure as the @order object is nil for collection actions
before_filter :check_authorization, :except => :bulk_management
# After updating an order, the fees should be updated as well
# Currently, adding or deleting line items does not trigger updating the
# fees! This is a quick fix for that.
# TODO: update fees when adding/removing line items
# instead of the update_distribution_charge method.
after_filter :update_distribution_charge, :only => :update
respond_override :index => { :html =>
{ :success => lambda {
# Filter orders to only show those distributed by current user (or all for admin user)
@@ -17,4 +24,17 @@ Spree::Admin::OrdersController.class_eval do
page(params[:page]).
per(params[:per_page] || Spree::Config[:orders_per_page])
} } }
# Overwrite to use confirm_email_for_customer instead of confirm_email.
# This uses a new template. See mailers/spree/order_mailer_decorator.rb.
def resend
Spree::OrderMailer.confirm_email_for_customer(@order.id, true).deliver
flash[:success] = t(:order_email_resent)
respond_with(@order) { |format| format.html { redirect_to :back } }
end
def update_distribution_charge
@order.update_distribution_charge!
end
end

View File

@@ -323,7 +323,7 @@ Spree::Admin::ReportsController.class_eval do
sort_by: proc { |payment_state| payment_state } },
{ group_by: proc { |payment| payment.order.distributor },
sort_by: proc { |distributor| distributor.name } },
{ group_by: proc { |payment| payment.payment_method },
{ group_by: proc { |payment| Spree::PaymentMethod.unscoped { payment.payment_method } },
sort_by: proc { |method| method.name } } ]
when "itemised_payment_totals"

View File

@@ -6,15 +6,18 @@ Spree::Admin::VariantsController.class_eval do
@variants = Spree::Variant.ransack(search_params.merge(:m => 'or')).result
if params[:distributor_id].present?
distributor = Enterprise.find params[:distributor_id]
@variants = @variants.in_distributor(distributor)
end
if params[:order_cycle_id].present?
order_cycle = OrderCycle.find params[:order_cycle_id]
@variants = @variants.in_order_cycle(order_cycle)
end
if params[:distributor_id].present?
distributor = Enterprise.find params[:distributor_id]
@variants = @variants.in_distributor(distributor)
# Perform scoping after all filtering is done.
# Filtering could be a problem on scoped variants.
@variants.each { |v| v.scope_to_hub(distributor) }
end
end
def destroy