forked from spree/spree
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove r_c from shipments_controller, orders_controller, taxons_contr…
…oller, payments_controller and line_items_controller
- Loading branch information
Showing
15 changed files
with
263 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,64 @@ | ||
class Admin::LineItemsController < Admin::BaseController | ||
resource_controller | ||
belongs_to :order | ||
|
||
actions :all, :except => :index | ||
before_filter :load_order, :except => [:create] | ||
before_filter :load_line_item, :only => [:destroy, :update] | ||
|
||
create.flash nil | ||
update.flash nil | ||
destroy.flash nil | ||
|
||
#override r_c create action as we want to use order#add_variant instead of creating line_item | ||
def create | ||
load_object | ||
variant = Variant.find(params[:line_item][:variant_id]) | ||
|
||
before :create | ||
@taxon = Taxon.find(params[:taxon][:parent_id]) | ||
@taxonomy = Taxonomy.find params[:taxonomy_id] | ||
|
||
variant = Variant.find(params[:line_item][:variant_id]) | ||
@order.add_variant(variant, params[:line_item][:quantity].to_i) | ||
|
||
if @order.save | ||
after :create | ||
set_flash :create | ||
response_for :create | ||
respond_to do |format| | ||
format.html do | ||
render :partial => "admin/orders/form", :locals => {:order => @order.reload}, :layout => false | ||
end | ||
end | ||
else | ||
after :create_fails | ||
set_flash :create_fails | ||
response_for :create_fails | ||
end | ||
end | ||
|
||
def destroy | ||
if @line_item.destroy | ||
respond_to do |format| | ||
format.html { render :partial => "admin/orders/form", :locals => {:order => @order.reload}, :layout => false } | ||
end | ||
else | ||
respond_to do |format| | ||
format.html do | ||
render :partial => "admin/orders/form", :locals => {:order => @order.reload}, :layout => false | ||
end | ||
end | ||
end | ||
end | ||
|
||
destroy.success.wants.html { render :partial => "admin/orders/form", :locals => {:order => @order.reload}, :layout => false } | ||
destroy.failure.wants.html { render :partial => "admin/orders/form", :locals => {:order => @order.reload}, :layout => false } | ||
def new | ||
respond_to do |format| | ||
format.html { render :action => :new, :layout => false } | ||
end | ||
end | ||
|
||
new_action.response do |wants| | ||
wants.html {render :action => :new, :layout => false} | ||
def update | ||
if @line_item.update_attributes(params[:line_item]) | ||
respond_to do |format| | ||
format.html { render :partial => "admin/orders/form", :locals => {:order => @order.reload}, :layout => false} | ||
end | ||
else | ||
respond_to do |format| | ||
format.html { render :partial => "admin/orders/form", :locals => {:order => @order.reload}, :layout => false} | ||
end | ||
end | ||
end | ||
|
||
create.response do |wants| | ||
wants.html { render :partial => "admin/orders/form", :locals => {:order => @order.reload}, :layout => false} | ||
|
||
def load_order | ||
@order = Order.find_by_number! params[:order_id] | ||
end | ||
|
||
update.success.wants.html { render :partial => "admin/orders/form", :locals => {:order => @order.reload}, :layout => false} | ||
update.failure.wants.html { render :partial => "admin/orders/form", :locals => {:order => @order.reload}, :layout => false} | ||
def load_line_item | ||
@line_item = @order.line_items.find params[:id] | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.