The page to modify a user.

def custom_modify_user_view(request, targetUsername):
    ''' The page to modify a user. '''
    if targetUsername == ANONYMOUS_USERNAME:
        messages.add_message(request, messages.WARNING, MESSAGES['ANONYMOUS_EDIT'])
    page_name = "Admin - Modify User"
    targetUser = get_object_or_404(User, username=targetUsername)
    targetProfile = get_object_or_404(UserProfile, user=targetUser)

    update_user_form = UpdateUserForm(
        request.POST if "update_user_profile" in request.POST else None,
        instance=targetUser,
        profile = UserProfile.objects.get(user=request.user),
        prefix="user",
        )
    update_profile_form = FullProfileForm(
        request.POST if "update_user_profile" in request.POST else None,
        instance=targetProfile,
        prefix="profile",
        )
    change_user_password_form = AdminPasswordChangeForm(
        targetUser,
        request.POST if "change_user_password" in request.POST else None,
        )
    delete_user_form = DeleteUserForm(
        request.POST if "delete_user" in request.POST else None,
        user=targetUser,
        request=request,
        )
    if update_user_form.is_valid() and update_profile_form.is_valid():
        update_user_form.save()
        update_profile_form.save()
        messages.add_message(
            request, messages.SUCCESS,
            MESSAGES['USER_PROFILE_SAVED'].format(username=targetUser.username),
            )
        return HttpResponseRedirect(reverse(
            'custom_modify_user', kwargs={'targetUsername': targetUsername}
            ))
    if change_user_password_form.is_valid():
        change_user_password_form.save()
        messages.add_message(
            request, messages.SUCCESS,
            MESSAGES['USER_PW_CHANGED'].format(username=targetUser.username),
            )
        return HttpResponseRedirect(reverse(
            'custom_modify_user', kwargs={'targetUsername': targetUsername})
            )
    if delete_user_form.is_valid():
        delete_user_form.save()
        messages.add_message(
            request, messages.SUCCESS,
            MESSAGES['USER_DELETED'].format(username=targetUser.username),
            )
        return HttpResponseRedirect(reverse("custom_manage_users"))

    template_dict = {
        'targetUser': targetUser,
        'targetProfile': targetProfile,
        'page_name': page_name,
        'update_user_form': update_user_form,
        'update_profile_form': update_profile_form,
        'change_user_password_form': change_user_password_form,
        'delete_user_form': delete_user_form,
        }

    if "wiki" in settings.INSTALLED_APPS:
        from wiki.models import Revision
        template_dict["revision_count"] = \
          Revision.objects.filter(created_by=targetUser).count()

    template_dict['thread_count'] = \
      Thread.objects.filter(owner=targetProfile).count()
    template_dict['message_count'] = \
      Message.objects.filter(owner=targetProfile).count()
    template_dict['request_count'] = \
      Request.objects.filter(owner=targetProfile).count()
    template_dict['response_count'] = \
      Response.objects.filter(owner=targetProfile).count()
    template_dict['announcement_count'] = \
      Announcement.objects.filter(incumbent=targetProfile).count()
    template_dict['event_count'] = \
      Event.objects.filter(owner=targetProfile).count()

    return render_to_response(
        'custom_modify_user.html',
        template_dict,
        context_instance=RequestContext(request),
        )