#NEWLINE# @ staff_member_required #NEWLINE# def orderline_cancel( request , order_pk , line_pk ) : #NEWLINE# #INDENT# order = get_object_or_404 ( Order , pk = order ) #NEWLINE# item = get_object_or_404 ( OrderedItem . objects . filter ( delivery_group__order = order ) , pk = line_pk ) #NEWLINE# form = CancelItemsForm ( data = ( request . POST or None ) , item = item ) #NEWLINE# status = 200 #NEWLINE# if form . is_valid ( ) : #NEWLINE# #INDENT# msg = ( _ ( 'Cancelled item %s' ) % item ) #NEWLINE# with transaction . atomic ( ) : #NEWLINE# #INDENT# form . cancel_item ( ) #NEWLINE# order . create_history_entry ( comment = msg , user = request . user ) #NEWLINE# #UNINDENT# return redirect ( 'dashboard:order-details' , order_pk = order . pk ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if form . errors : #NEWLINE# #INDENT# status = 400 #NEWLINE# #UNINDENT# #UNINDENT# ctx = { #NEWLINE# #INDENT# 'order' : order , #NEWLINE# 'item' : item , #NEWLINE# 'form' : form , #NEWLINE# #UNINDENT# } #NEWLINE# return TemplateResponse ( request , 'dashboard/order/modal_cancel_line.html' , ctx , status = status )