在我的代码中,我向用户发送电子邮件,询问他们是否要通过向他们发送两个链接来确认或拒绝订单(使 bool 为 false 或 true)。唯一的问题是,他们可以通过单击 true 然后 false true 然后 false 等来不断更改布尔值。我希望它到哪里,如果他们单击 true 链接,他们就不能返回并使其为 false。
这是views.py中的代码:
def confirm(request, itemnum):
item = get_object_or_404(PurchaseOrder, item_number = itemnum)
item.confirmed = True
item.save()
confirm_title = 'Purchase Order %s Confirmed' % item.product
send_mail(confirm_title, 'Check the Product Order System to see the updated list.', 'MyEmail@gmail.com',['YourEmail@gmail.com'], fail_silently=False)
return HttpResponse('Product %s confirmed' % item.product )
def deny(request, itemnum):
item = get_object_or_404 (PurchaseOrder, item_number = itemnum)
item.confirmed = False
item.save()
deny_title = 'Purchase Order %s Denied' % item.product
send_mail(deny_title, 'Check the Product Order System to see the updated list.', 'MyEmail.com', ['YourEmail@gmail.com'], fail_silently = False)
return HttpResponse('Product %s denied' % item.product)