The page to request a user profile on the site.

def request_profile_view(request):
    ''' The page to request a user profile on the site. '''
    page_name = "Profile Request Page"
    redirect_to = request.GET.get('next', reverse('homepage'))
    if request.user.is_authenticated() and request.user.username != ANONYMOUS_USERNAME:
        return HttpResponseRedirect(redirect_to)
    form = ProfileRequestForm(
        request.POST or None,
        )
    if form.is_valid():
        username = form.cleaned_data['username']
        first_name = form.cleaned_data['first_name']
        last_name = form.cleaned_data['last_name']
        email = form.cleaned_data['email']
        if User.objects.filter(username=username).count():
            reset_url = request.build_absolute_uri(reverse('reset_pw'))
            form_add_error(form, 'username',
                           MESSAGES["USERNAME_TAKEN"].format(username=username))
            messages.add_message(request, messages.INFO,
                                 MESSAGES['RESET_MESSAGE'].format(reset_url=reset_url))
        elif User.objects.filter(email=email).count():
            reset_url = request.build_absolute_uri(reverse('reset_pw'))
            messages.add_message(request, messages.INFO,
                                 MESSAGES['RESET_MESSAGE'].format(reset_url=reset_url))
            form_add_error(form, "email", MESSAGES["EMAIL_TAKEN"])
        elif ProfileRequest.objects.filter(first_name=first_name, last_name=last_name).count():
            form_add_error(
                form, '__all__',
                MESSAGES["PROFILE_TAKEN"].format(first_name=first_name,
                                                 last_name=last_name))
        elif User.objects.filter(first_name=first_name, last_name=last_name).count():
            reset_url = request.build_absolute_uri(reverse('reset_pw'))
            messages.add_message(request, messages.INFO, MESSAGES['PROFILE_REQUEST_RESET'].format(reset_url=reset_url))
        else:
            form.save()
            messages.add_message(request, messages.SUCCESS, MESSAGES['PROFILE_SUBMITTED'])
            if settings.SEND_EMAILS and (email not in settings.EMAIL_BLACKLIST):
                submission_subject = SUBMISSION_SUBJECT.format(house=settings.HOUSE_NAME)
                submission_email = SUBMISSION_EMAIL.format(house=settings.HOUSE_NAME, full_name=first_name + " " + last_name, admin_name=settings.ADMINS[0][0],
                    admin_email=settings.ADMINS[0][1])
                try:
                    send_mail(submission_subject, submission_email, settings.EMAIL_HOST_USER, [email], fail_silently=False)
                    # Add logging here
                except SMTPException:
                    pass # Add logging here
            return HttpResponseRedirect(redirect_to)
    return render(request, 'request_profile.html', {
        'form': form,
        'page_name': page_name,
        'oauth_providers': _get_oauth_providers(),
        'redirect_to': redirect_to,
        })