def new_order(request): from website.forms import NewOrderForm form = NewOrderForm(request.POST or None) if form.is_valid(): staff = request.user.get_profile() order = Order( staff=staff, tourist=form.cleaned_data['tourist'], country=form.cleaned_data['country'], dt_in=form.cleaned_data['dt_in'], oper=form.cleaned_data['oper'], order_value=form.cleaned_data['order_value'], currency=form.cleaned_data['currency'], comment=form.cleaned_data['order_comment']) order.save() pay = Payment( payment_type=form.cleaned_data['pay_type'], order=order, staff=staff, pay=form.cleaned_data['pay'], rate=form.cleaned_data['rate'], comment=form.cleaned_data['pay_comment']) pay.save() messages.add_message(request, messages.SUCCESS, u"Заявка успешно зарегистрирована под номером - %d." % order.id) return redirect('message_list') return render(request, 'new_order.html', {'form': form})
def order_info(request, pk): from website.forms import NewPaymentForm object_detail = get_object_or_404(Order, pk=pk) form = NewPaymentForm(request.POST or None) if request.POST: if form.is_valid(): pay = Payment(payment_type=form.cleaned_data['pay_type'], order=object_detail, staff=request.account, pay=form.cleaned_data['pay'], rate=form.cleaned_data['rate'], comment=form.cleaned_data['pay_comment']) pay.save() messages.add_message(request, messages.SUCCESS, u"Оплата уcпешно добавлена") return HttpResponse('') else: return HttpResponse(simplejson.dumps({'errors': form.errors}), mimetype='text/javascript') return render(request, 'boxes/order_info_box.html', {'object_detail': object_detail, 'form': form})