Example #1
0
def signup(request, **kwargs):

    form_class = kwargs.pop("form_class", SignupForm)
    template_name = kwargs.pop("template_name", "account/signup.html")
    redirect_field_name = kwargs.pop("redirect_field_name", "next")
    success_url = kwargs.pop("success_url", None)

    if success_url is None:
        success_url = get_default_redirect(request, redirect_field_name)

    if request.method == "POST":
        form = form_class(request.POST)
        if form.is_valid():
            user = form.save(request=request)
            return complete_signup(request, user, success_url)
    else:
        form = form_class()
    ctx = {
        "form":
        form,
        "login_url":
        passthrough_login_redirect_url(request, reverse("account_login")),
        "redirect_field_name":
        redirect_field_name,
        "redirect_field_value":
        request.REQUEST.get(redirect_field_name)
    }
    return render_to_response(template_name, RequestContext(request, ctx))
Example #2
0
def signup(request, **kwargs):
    
    form_class = kwargs.pop("form_class", SignupForm)
    template_name = kwargs.pop("template_name", "account/signup.html")
    redirect_field_name = kwargs.pop("redirect_field_name", "next")
    success_url = kwargs.pop("success_url", None)
    
    group, bridge = group_and_bridge(kwargs)
    ctx = group_context(group, bridge)
    
    if success_url is None:
        success_url = get_default_redirect(request, redirect_field_name)
    
    if request.method == "POST":
        form = form_class(request.POST, group=group)
        if form.is_valid():
            user = form.save(request=request)
            return complete_signup(request, user, success_url)
    else:
        form = form_class(group=group)
    
    ctx.update({
        "form": form,
        "redirect_field_name": redirect_field_name,
        "redirect_field_value": request.REQUEST.get(redirect_field_name),
    })
    
    return render_to_response(template_name, RequestContext(request, ctx))
Example #3
0
def signup(request, **kwargs):
    
    form_class = kwargs.pop("form_class", SignupForm)
    template_name = kwargs.pop("template_name", "account/signup.html")
    redirect_field_name = kwargs.pop("redirect_field_name", "next")
    success_url = kwargs.pop("success_url", None)
    
    if success_url is None:
        success_url = get_default_redirect(request, redirect_field_name)
    
    if request.method == "POST":
        form = form_class(request.POST)
        if form.is_valid():
            user = form.save(request=request)
            # Begin default profile creation
            profile = UserProfile(user=user)
            profile.save()
            # End default profile creation
            return complete_signup(request, user, success_url)
    else:
        form = form_class()
    ctx = {"signuppage": True,
           "form": form,
           "login_url": passthrough_login_redirect_url(request,
                                                       reverse("account_login")),
           "redirect_field_name": redirect_field_name,
           "redirect_field_value": request.REQUEST.get(redirect_field_name) }
    return render_to_response(template_name, RequestContext(request, ctx))
Example #4
0
def signup(request, **kwargs):

    form_class = kwargs.pop("form_class", SignupForm)
    template_name = kwargs.pop("template_name", "account/signup.html")
    redirect_field_name = kwargs.pop("redirect_field_name", "next")
    success_url = kwargs.pop("success_url", None)

    if success_url is None:
        success_url = get_default_redirect(request, redirect_field_name)

    if request.method == "POST":
        form = form_class(request.POST, request=request)
        if form.is_valid():
            user = form.save(request=request)
            return complete_signup(request, user, success_url, provider='email')
    else:
        form = form_class(initial=request.GET)

    extra_context = kwargs.pop('extra_context', {})
    if extra_context is None:
        extra_context = {}
    ctx = {"form": form,
           "login_url": passthrough_login_redirect_url(request,
                                                       reverse("account_login")),
           "redirect_field_name": redirect_field_name,
           "redirect_field_value": request.REQUEST.get(redirect_field_name) }
    ctx.update(extra_context)
    return render_to_response(template_name, RequestContext(request, ctx))
Example #5
0
def signup(request, **kwargs):
    form_class = kwargs.pop("form_class", SignupForm)
    template_name = kwargs.pop("template_name", "account/signup.html")
    redirect_field_name = kwargs.pop("redirect_field_name", "next")
    success_url = kwargs.pop("success_url", None)
    
    if success_url is None:
        success_url = get_default_redirect(request, redirect_field_name)
    
    if request.method == "POST":
        form = form_class(request.POST)
        if form.is_valid():
            user = form.save(request=request)
            return complete_signup(request, user, success_url)
        if request.is_ajax():
            return HttpResponse(simplejson.dumps(
                {
                    'status': 'error',
                    'errors': form.errors,
                    'prefix': form.prefix,
                }),
                mimetype="application/json"
            )
    else:
        form = form_class()
    ctx = {"form": form,
           "redirect_field_name": redirect_field_name,
           "redirect_field_value": request.REQUEST.get(redirect_field_name) }
    return render_to_response(template_name, RequestContext(request, ctx))
Example #6
0
def signup(request, **kwargs):

    form_class = kwargs.pop("form_class", SignupForm)
    success_url = get_default_redirect(request, "next")

    if request.method == "POST":
        form = form_class(request.POST)
        if form.is_valid():
            user = form.save(request)
            return complete_signup(request, user, success_url)
    else:
        form = form_class()
    return shared_sign(request, signup_form=form)
Example #7
0
 def form_valid(self, form):
     user = form.save(self.request)
     return complete_signup(self.request, user, self.get_success_url())
Example #8
0
def signup(request,**kwargs):
    member_login = get_member_login_object(request)
    if member_login:
        return HttpResponseRedirect("/")
    if 'sent' in request.GET:
        #template_name = kwargs.pop("template_name", "account/signup_sent_mail.html")
        template_name = 'auth_template/page/signup_sent_mail.html'
        return render_to_response(template_name, RequestContext(request, {}))
    else:
        if 'profile' in request.GET:
            form_class = kwargs.pop("form_class", ProfileSignupForm)
            #template_name = kwargs.pop("template_name", "account/signup_profile.html")
            template_name = 'auth_template/page/signup_profile.html'
            redirect_field_name = kwargs.pop("redirect_field_name", "next")
            success_url = kwargs.pop("success_url", None)            
            
            if request.method == "POST":
                form = form_class(request.POST)
                if form.is_valid():
                    username = request.session['signup_username']
                    user = form.save(username)
                    return complete_signup(request, user, success_url)
            else:
                form = form_class()
            ctx = {"form": form,'current_url': request.get_full_path}
            return render_to_response(template_name, RequestContext(request, ctx))
        elif 'key' in request.GET:
            confirmation_key = request.GET['key']
            e = EmailConfirmation.objects.filter(confirmation_key=confirmation_key)
            if len(e) == 0:
                #template_name = kwargs.pop("template_name", "account/signup_wrong_url.html")
                template_name = 'auth_template/page/signup_wrong_url.html'
                return render_to_response(template_name, RequestContext(request, {}))
            else:
                form_class = kwargs.pop("form_class", CompleteSignupForm)
                #template_name = kwargs.pop("template_name", "account/signup_complete.html")
                template_name = 'auth_template/page/signup_complete.html'
                if request.method == "POST":
                    form = form_class(request.POST)
                    if form.is_valid():
                        email = e[0].email_address
                        user = form.create_user(email)
                        request.session['signup_username'] = user.username
                        return HttpResponseRedirect('/signup/?profile')
                else:
                    form = form_class()
                ctx = {"form": form,'current_url': request.get_full_path}
                return render_to_response(template_name, RequestContext(request, ctx))
        else:
            form_class = kwargs.pop("form_class", InitSignupForm)
            #template_name = kwargs.pop("template_name", "account/signup_init.html")
            template_name = 'auth_template/page/signup_init.html'
            if request.method == "POST":
                form = form_class(request.POST)
                if form.is_valid():
                    form.send_activate_mail()
                    return HttpResponseRedirect('/signup/?sent')
            else:
                form = form_class()
            ctx = {"form": form}
            return render_to_response(template_name, RequestContext(request, ctx))