def _delete_notification(request, notification):
if request.user != notification.user:
return HttpResponseForbidden()
if request.method == 'POST':
form = DeleteNotificationForm(request.POST)
if form.is_valid():
if request.POST['action'] == 'Delete':
notification.delete()
return HttpResponseRedirect('/notifications')
else:
form = DeleteNotificationForm()
return render(
request,
'notification/delete_notification.html',
context={
'form': form,
'notification': notification,
'notification_type': notification.__class__.__name__.replace(
'Notification',
'',
),
},
)
评论列表
文章目录