def about(request, context={}):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        captcha_response = captcha.submit(request.POST['recaptcha_challenge_field'],
                    request.POST['recaptcha_response_field'], settings.RECAPTCHA_PRIVATE_KEY,
                    request.META['REMOTE_ADDR'])
        if captcha_response.is_valid:
            if form.is_valid():
                subject = form.cleaned_data['subject']
                msg_content = form.cleaned_data['message']
                sender = form.cleaned_data['sender']
                receiver = ['[email protected]']
                EmailMessage(subject, msg_content, sender, receiver,
                             headers={'Reply-To': sender}).send()
                # send_mail(subject, msg_content, sender, receiver)
                return HttpResponseRedirect('/contact/success/')
            else:
                messages.error(request, _("An error has occured. Correct entered data."))
                # return about(request, {'subject':
                # form.cleaned_data['subject'], 'msg_content':
                # form.cleaned_data['message'], 'sender':
                # form.cleaned_data['sender']})
                context.update(get_context(request))
                context.update({'contactform': form, 'captcha':
                        captcha.displayhtml(settings.RECAPTCHA_PUBLIC_KEY)})
                return render_to_response('common/about.html', context,
                                          RequestContext(request))
        else:
            messages.error(request, _('Wrong captcha.'))
            # return about(request, {'subject': form.cleaned_data['subject'],
            # 'msg_content': form.cleaned_data['message'], 'sender':
            # form.cleaned_data['sender']})
            context.update(get_context(request))
            context.update({'contactform': form, 'captcha':
                        captcha.displayhtml(settings.RECAPTCHA_PUBLIC_KEY)})
            return render_to_response('common/about.html', context,
                                      RequestContext(request))
    else:
        form = ContactForm()
    context.update(get_context(request))
    context.update({'contactform': form, 'captcha': captcha.displayhtml(settings.RECAPTCHA_PUBLIC_KEY)})
    return render_to_response('common/about.html', context,
                              RequestContext(request))
def register(request):
    form = None
    if request.method == 'POST':
        captcha_response = captcha.submit(request.POST['recaptcha_challenge_field'],
                    request.POST['recaptcha_response_field'], settings.RECAPTCHA_PRIVATE_KEY,
                    request.META['REMOTE_ADDR'])
        if captcha_response.is_valid:
            form = UserCreationFormExtended(request.POST)
            if form.is_valid():
                form.save()
                messages.success(request, _('Success! You can log in now.'))
                return HttpResponseRedirect('/')
            else:
                messages.error(request, _("An error has occured. Correct entered data."))
        else:
            messages.error(request, _("Wrong captcha, try again."))
    form = UserCreationFormExtended(request.POST)
    context = get_context(request)
    context.update({'form': form, 'captcha': captcha.displayhtml(settings.RECAPTCHA_PUBLIC_KEY)})
    return render_to_response("common/register.html", context,
                              context_instance=RequestContext(request))