コード例 #1
0
def signup_view(request):
    dict={}
    if request.method == 'GET':
        signup_form = SignUpForm()                             # calling & display signup form
        template_name = 'signup.html'                          # rendering to signup.html after get reqst

    elif request.method == 'POST':
        signup_form = SignUpForm(request.POST)                 # calling & process the form data
        if signup_form.is_valid():                             # validate the form data
            username = signup_form.cleaned_data['username']
            name     = signup_form.cleaned_data['name']
            email    = signup_form.cleaned_data['email']
            password = signup_form.cleaned_data['password']
            while len(username) < 4:
                dict['invalid_username']="******"
                return render(request, "signup.html",dict)
            while len(password) < 5:
                dict['invalid_password']="******"
                return render(request, "signup.html",dict)

            new_user = UserModel(name=name, email=email, password=make_password(password), username=username)
            new_user.save()                                    # save data to db
            template_name = 'success.html'                     # rendering to success.html after post req
        else:
            dict={"key":"Pleas fill the form"}
            return render(request,'signup.html',dict)

    return render(request,template_name, {'signup_form': signup_form})
コード例 #2
0
ファイル: views.py プロジェクト: prashararchi/final_project
def signup_view(request):
    dictionary = {}
    if request.method == "GET" :
        signup_form = SignUpForm()
        dictionary['signup'] = signup_form
        return render(request,"signup_1.html" , dictionary)
    elif request.method == 'POST':
        signup_form = SignUpForm(request.POST)
        if signup_form:
            if signup_form.is_valid():
                username = signup_form.cleaned_data.get('username')
                name = signup_form.cleaned_data.get('name')
                email = signup_form.cleaned_data.get('email')
                password = signup_form.cleaned_data.get('password')
                while len(username) < 5:
                    dictionary['invalid_username']="******"
                    return render(request, "signup_1.html", dictionary)
                while len(password) < 5:
                    dictionary['invalid_pass'] = "******"
                    return render(request, "signup_1.html", dictionary)
                #save user to DATABASE...
                user = UserModel(name = name,username=username,email=email,password=make_password(password))
                user.save()
                dictionary['registered'] = signup_form
                return render(request, "registered.html", dictionary)
            else :
                dictionary['invalid'] = "Invalid values, plzz enter again"
                return render(request, "signup_1.html", dictionary)
        else:
            log_in(request)
コード例 #3
0
ファイル: aa.py プロジェクト: JYOTITHAKUROSEM/Final_project
def signup_view(request):
    if request.method == 'GET':
        signup_form = SignUpForm()                             # calling & display signup form
        template_name = 'signup.html'                          # rendering to signup.html after get reqst
    elif request.method == 'POST':
        signup_form = SignUpForm(request.POST)
        print "line 25"# calling & process the form data
        if signup_form.is_valid():
            print "line 27"# validate the form data
            username = signup_form.cleaned_data['username']
            name = signup_form.cleaned_data['name']
            email = signup_form.cleaned_data['email']
            password =signup_form.cleaned_data['password']
            #data validation
            if(len(username)<5):
                new_user = UserModel(name=name, email=email, password=make_password(password), username=username)
                new_user.save()  # save data to db
                template_name = 'success.html'  # rendering to success.html after post req
            else:
                # return redirect('/signup/')
                dict = {"key": "Pleas fill the form"}
                #return render(request, 'signup.html', dict)
                #return render(request, 'error.html')
        else:
            print "line 41"
            dict={"key":"Pleas fill the form"}
            return render(request,'signup.html',dict)
    print "line 44"
    return render(request,template_name, {'signup_form': signup_form})
コード例 #4
0
def signup_view(request):
    if request.method == "POST":
        form = SignUpForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data['username']
            name = form.cleaned_data['name']
            email = form.cleaned_data['email']
            password = form.cleaned_data['password']
            #saving data to DB
            user = UserModel(name=name, password=make_password(password), email=email, username=username)
            user.save()
            return render(request, 'success.html')
            #return redirect('login/')
    else:
        form = SignUpForm()

    return render(request, 'signup.html', {'form' : form})
コード例 #5
0
def signup_view(request):
    #business logic.

    if request.method == 'GET':
        #display signup form
        today = datetime.now()
        form = SignUpForm()
        name1 = ''
        template_name = 'signup.html'
    elif request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data['username']
            email = form.cleaned_data['email']
            name = form.cleaned_data['name']
            password = form.cleaned_data['password']
            # insert data to db
            if username == None or name == None or len(username) < 4 or len(
                    password) < 5:
                name1 = "these fields are incorrect or not entered"
            else:
                name1 = ""
                new_user = UserModel(name=name,
                                     password=make_password(password),
                                     email=email,
                                     username=username)
                new_user.save()
                subject = 'Welcome to Upload To Win'
                message = 'Thanks for joining "Upload ToWIn" where you can view , comment and like photos of your intrest'
                from_email = EMAIL_HOST_USER
                to_email = [new_user.email]
                send_mail(subject, message, from_email, to_email)
                return redirect("/login/")
        else:
            name1 = "these fields are incorrect or not entered"
            return redirect("/signup/")

    return render(request, template_name, {
        'form': form,
        'today': today,
        'name1': name1,
    })
コード例 #6
0
def signup_view(request):
    #------------------------------here is the logic of the functions--------------------------------------------------------
    if request.method == 'POST':
        form = SignUpForms(request.POST)
        if form.is_valid():
            Username = form.cleaned_data['Username']
            Email =form.cleaned_data['Email']
            Name = form.cleaned_data['Name']
            Password = form.cleaned_data['Password']
            # insert data to db
            new_user = UserModel(Name=Name,Password=make_password(Password),Username=Username, Email=Email)
            new_user.save()
     #--------------------------here we give conditions which open success page or failed page ----------------------------------
            template_name = 'success.html'
        else:
            template_name = 'failed.html'
    else:
        form = SignUpForms()
        template_name = 'signup.html'

    return render(request, template_name, {'form':form})