Exemplo n.º 1
0
def login_openid_complete(request):
    setattr(settings, 'OPENID_CREATE_USERS', False)
    r = openid_views.login_complete(
        request, render_failure=render_openid_login_failure)
    if isinstance(r, http.HttpResponseRedirect):
        try:
            user = request.user.get_profile()
        except UserProfile.DoesNotExist:
            user = request.user
            username = ''
            if user.username[:10] != 'openiduser':
                username = user.username
            form = forms.CreateProfileForm(initial={
                'full_name': ' '.join((user.first_name, user.last_name)),
                'email': user.email,
                'username': username,
            })
            return render_to_response('dashboard/setup_profile.html', {
                'form': form,
            }, context_instance=RequestContext(request))

        redirect_url = _get_redirect_url(request)
        if redirect_url:
            return http.HttpResponseRedirect(redirect_url)

    return r
Exemplo n.º 2
0
def profile_create(request):
    try:
        request.user.get_profile()
        return http.HttpResponseRedirect(reverse('dashboard'))
    except UserProfile.DoesNotExist:
        pass
    form = forms.CreateProfileForm(request.POST)
    if form.is_valid():
        profile = form.save(commit=False)
        profile.user = request.user
        profile.id = profile.user.id
        profile.user.email = profile.email
        profile.user.save()
        profile.confirmation_code = profile.generate_confirmation_code()
        profile.save()
        path = reverse('users_confirm_registration', kwargs={
            'username': profile.username,
            'token': profile.confirmation_code,
        })
        url = request.build_absolute_uri(path)
        profile.email_confirmation_code(url)
        msg = _('Thanks! We have sent an email to %s with '
                'instructions for completing your '
                'registration.') % profile.email
        messages.info(request, msg)
        request.session['send_registration_event'] = True
        return http.HttpResponseRedirect(reverse('dashboard'))
    else:
        messages.error(request, _('There are errors in this form. Please '
                                      'correct them and resubmit.'))
    return render_to_response('dashboard/setup_profile.html', {
        'form': form,
        'domain': Site.objects.get_current().domain,
    }, context_instance=RequestContext(request))
Exemplo n.º 3
0
def profile_create(request):
    if request.method != 'POST':
        return http.HttpResponseRedirect(reverse('dashboard_index'))
    try:
        request.user.get_profile()
        return http.HttpResponseRedirect(reverse('dashboard_index'))
    except UserProfile.DoesNotExist:
        pass
    form = forms.CreateProfileForm(request.POST)
    if form.is_valid():
        profile = form.save(commit=False)
        profile.user = request.user
        profile.confirmation_code = profile.generate_confirmation_code()
        profile.save()
        path = reverse('users_confirm_registration',
                       kwargs={
                           'username': profile.username,
                           'token': profile.confirmation_code,
                       })
        url = request.build_absolute_uri(path)
        profile.email_confirmation_code(url)
        auth.logout(request)
        msg = _('Thanks! We have sent an email to {0} with '
                'instructions for completing your '
                'registration.').format(profile.email)
        messages.info(request, msg)
        return http.HttpResponseRedirect(reverse('dashboard_index'))
    else:
        messages.error(
            request,
            _('There are errors in this form. Please '
              'correct them and resubmit.'))
    return render_to_response('dashboard/setup_profile.html', {
        'form': form,
    },
                              context_instance=RequestContext(request))