예제 #1
0
def user_register(request):
    registered = False
    if request.method == 'POST':
        if request.POST.get('psw') == request.POST.get('psw-repeat'):
            user_name1 = request.POST.get('username')
            pass_word1 = request.POST.get('psw')
            enc_password = make_password(pass_word1)
            user = User(username=user_name1, password=enc_password)
            user.email = request.POST.get('email')
            try:
                user.save()
                user_obj = USER_LOGIN(
                    first_name=request.POST.get('First_Name'),
                    last_name=request.POST.get('Last_Name'),
                    user_name=request.POST.get('username'),
                    pass_word=request.POST.get('psw'),
                    email_id=request.POST.get('email'),
                    gender=request.POST.get('gender'))
                user_obj.save()

                registered = True
                return index(request)
            except:
                return HttpResponse(
                    "sorry username or email already exist please try with other one!"
                )

        else:
            #messages.warning(request, 'Invalid credentials!')
            return HttpResponse("both passwords are not matched!")

    else:
        return render(request, 'testapp/RegisterPage.html')
예제 #2
0
def Tourist_registration(request):
    registered=False
    if request.method=="POST":
            first_name = request.POST.get('Firstname')
            print(first_name)
            last_name=request.POST.get('Lastname')
            user_name=request.POST.get('Username')
            email_id=request.POST.get('Email')
            pass_word = request.POST.get('Password')
            language=request.POST.get('language')
            gender=request.POST.get('gender')
            age=request.POST.get('age')
            phone_number=request.POST.get('Phonenumber')
            enc_password=make_password(pass_word)
            user=User(username=user_name,password=enc_password)
            user.is_tourist=True
            user.is_guide=False
            user.email=email_id
            try:
                user.save()
                form=Tourist_Registration(first_name=first_name,last_name=last_name,user_name=user_name,email_id=email_id,pass_word=pass_word,language=language,gender=gender,age=age,phone_number=phone_number)
                t=form.save()
            except:
                messages.warning(request, 'username or Email already exists Please Try again with New one')
                return HttpResponseRedirect('testapp/index.html')

            registered = True
            messages.success(request, 'successfully Registered Please Login!')
            return HttpResponseRedirect('testapp/index.html')
    else:
        return render(request,'testapp/index.html')