Esempio n. 1
0
def user_created(sender, user, request, **kwargs):
    request.session.set_expiry(1800)
    form = UserRegistrationForm(request.POST)
    logger.debug("I am in the backend")
    data2 = BFName()
    data2.domain = Domain.objects.get(team=request.session["bfteam"], domain_name=form.data["domainname"])
    data2.bfname = form.data["bfname"].lower()
    data2.product = Product.objects.get(product_name=form.data["plan"])
    request.session["BigFanObj"] = data2

    # data2.save()
    data3 = CustomerAnswer()
    data3.customer = request.user
    data3.security_question = SecurityQuestion.objects.get(id=form.data["sec_question1"])
    data3.answer = form.data["sec_answer1"]
    data3.save()
    #   data4 = CustomerAnswer()
    #   data4.customer = request.user
    #   data4.security_question = SecurityQuestion.objects.get(id=form.data["sec_question2"])
    #   data4.answer = form.data["sec_answer2"]
    #   data4.save()
    bfacct = Account()
    bfacct.customer = request.user
    bfacct.bfname = data2
    # bfacct.save()
    request.session["BigFanAcct"] = bfacct
Esempio n. 2
0
def bfname_registration(request, form_class=None):
    if request.user.username:
        form = form_class({
            'first_name': request.user.first_name,
            'last_name': request.user.last_name,
            })

    #variables directly from the form
    local_name = request.POST['nickname']
    domain = request.POST['select_domain']

    #get stuff
    first_name = request.user.first_name
    last_name = request.user.last_name

    #variables generated from the form
    bfmail = local_name + domain
    first_initial = first_name[0:1]
    last_initial = last_name[0:1]
    suggest1 = local_name + str(randint(100,999))
    suggest2 = first_initial + request.user.last_name
    suggest3 = first_name + "." + last_name
    suggest4 = local_name + first_initial + last_initial

    try:
        get_bfname = BFName.objects.get(bfname=local_name)
    except BFName.DoesNotExist:
        get_bfname = 'DoesNotExist'

    if(get_bfname != 'DoesNotExist'):
        return render(request, 'search/username_registration.html',{
            'suggest1': suggest1,
            'suggest2': suggest2,
            'suggest3': suggest3,
            'suggest4': suggest4,
            'local_name': local_name,
            'domain': domain,
            'bfmail': bfmail,
            })
    else:
        data2 = BFName()
        data2.domain_id = Domain.objects.get(domain_name=domain)
        data2.bfname = local_name #form.data["bfname"]
        data2.product = Product.objects.get(pk=1)
        data2.save()
        return HttpResponse("User " + bfmail + " successfully registered")