def check_recaptcha(view_func):
@wraps(view_func)<EOL>def _wrapped_view(request, *args, **kwargs):<EOL><INDENT>request.recaptcha_is_valid = None<EOL>if request.method == '<STR_LIT:POST>':<EOL><INDENT>recaptcha_response = request.POST.get('<STR_LIT>')<EOL>data = {<EOL>'<STR_LIT>': settings.GOOGLE_RECAPTCHA_SECRET_KEY,<EOL>'<STR_LIT>': recaptcha_response<EOL>}<EOL>r = requests.post(<EOL>'<STR_LIT>',<EOL>data=data<EOL>)<EOL>result = r.json()<EOL>if result['<STR_LIT:success>']:<EOL><INDENT>request.recaptcha_is_valid = True<EOL><DEDENT>else:<EOL><INDENT>request.recaptcha_is_valid = False<EOL>error_message = '<STR_LIT>'<EOL>error_message += str(result['<STR_LIT>'])<EOL>print(error_message)<EOL><DEDENT><DEDENT>return view_func(request, *args, **kwargs)<EOL><DEDENT>return _wrapped_view<EOL>
Chech that the entered recaptcha data is correct