def process_interstitial(request: Request, choices: t.List[Choice], *args, **kwargs):
"""Check if user pressed any of the buttons on form and the choice accordingly.
For example use case see :py:class:`websauna.system.crud.views.Delete`.
:param args: Passed to choice callback
:param kwargs: Passed to choice callback
:return: HTTP response given by a choice callback
"""
assert request.method == "POST"
# Force CSRF check always
check_csrf_token(request)
for c in choices:
if c.id in request.POST:
return c.callback(*args, **kwargs)
raise HTTPBadRequest("Unknown choice made")
评论列表
文章目录