def acceptOrder(request): order=Order.objects.get(pk=int(request.POST['pk'])) if order.user != None: inform_user(user=order.user, message=render_to_string('mail/order_accepted.html', {'order': order}), subject='سفارش شما تایید شد') inform_warehouse_manager( message=render_to_string('mail/order_warehouse_manager.html', {'order': order}), subject='سفارش نیازمند بررسی است') columns = ["status"] return changeQuerySet(request,columns,Order.objects)
def addOrder(request): c = request.POST tableData = json.loads( c['tableData']); today = jDateField(); today = today.to_python(datetime.datetime.now()) order = Order(submitDate=today) status = OrderItem.ORDER_ITEM_STATUS_CHOICES[0][0] order.user = request.user isforall = 'isforall' in request.POST and request.POST['isforall'] if request.user.is_superuser: order.status = 'A' if isforall: status = 'P' order.user = None order.save() #print tableData for order_item in tableData: #print order_item[2] if order_item[3] == '': category = None else: category = Category.objects.filter(pk=order_item[3])[0] orderitem=OrderItem(order=order, category=category, quantity=int(order_item[1]), description = order_item[4], status= status #if it's admin and the order belongs to the public ..., if it's admin the order is accepted ) orderitem.save() if request.user.is_superuser and isforall: inform_purchase_agent(subject='سفارش نیازمند خرید است',message=render_to_string('mail/buy_orderitem.html',{'orderitem' : orderitem})) c = {'rlink' : '../../myorders/' , 'success' : "سفارش شما با موفقیت ثبت شد تا لحظاتی دیگر به فهرست سفارشاتتان خواهید رفت"} if request.user.is_superuser: if not isforall : inform_warehouse_manager( message=render_to_string('mail/order_warehouse_manager.html', {'order': order}), subject='سفارش نیازمند بررسی است') else: inform_admin('سفارش جدید', render_to_string('mail/order_added.html', {'order': order})) return render_to_response("success.html",c);