@allow_lazy_user<EOL>def convert(request, form_class=None,<EOL>redirect_field_name='<STR_LIT>',<EOL>anonymous_redirect=settings.LOGIN_URL,<EOL>template_name='<STR_LIT>',<EOL>ajax_template_name='<STR_LIT>'):
redirect_to = '<STR_LIT>'<EOL>if form_class is None:<EOL><INDENT>if constants.LAZYSIGNUP_CUSTOM_USER_CREATION_FORM is not None:<EOL><INDENT>form_class = import_string(constants.LAZYSIGNUP_CUSTOM_USER_CREATION_FORM)<EOL><DEDENT>else:<EOL><INDENT>form_class = UserCreationForm<EOL><DEDENT><DEDENT>if request.user.is_anonymous:<EOL><INDENT>return HttpResponseRedirect(anonymous_redirect)<EOL><DEDENT>if request.method == '<STR_LIT:POST>':<EOL><INDENT>redirect_to = request.POST.get(redirect_field_name) or redirect_to<EOL>form = form_class(request.POST, instance=request.user)<EOL>if form.is_valid():<EOL><INDENT>try:<EOL><INDENT>LazyUser.objects.convert(form)<EOL><DEDENT>except NotLazyError:<EOL><INDENT>if request.is_ajax():<EOL><INDENT>return HttpResponseBadRequest(<EOL>content=_(u"<STR_LIT>"))<EOL><DEDENT>else:<EOL><INDENT>return redirect(redirect_to)<EOL><DEDENT><DEDENT>login(request, authenticate(**form.get_credentials()))<EOL>if request.is_ajax():<EOL><INDENT>return HttpResponse()<EOL><DEDENT>else:<EOL><INDENT>return redirect(redirect_to)<EOL><DEDENT><DEDENT>if request.is_ajax():<EOL><INDENT>return HttpResponseBadRequest(content=str(form.errors))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>form = form_class()<EOL><DEDENT>if request.is_ajax():<EOL><INDENT>template_name = [ajax_template_name, template_name]<EOL><DEDENT>return render(<EOL>request,<EOL>template_name,<EOL>{<EOL>'<STR_LIT>': form,<EOL>'<STR_LIT>': redirect_to<EOL>},<EOL>)<EOL>
Convert a temporary user to a real one. Reject users who don't
    appear to be temporary users (ie. they have a usable password)