예제 #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')
예제 #3
0
def adduser(request):
    if request.method == "POST":
        name = request.POST.get('U_name')
        pass1 = request.POST.get('U_pass')
        print(name, pass1)
        u = User(U_name=name, U_pass=pass1)
        u.save()
        return HttpResponse("User has been added!")
예제 #4
0
 def test_cache_query_set(self):
     """Basic cache test: second get comes from cache."""
     self.assertEquals(len(User.objects.all()), 2)
     user = User(name="test01")
     user.save()
     for x in User.objects.all():
         print x.name
     self.assertEquals(len(User.objects.all()), 3)
def showdata(request):
    if request.method == 'POST':
        # print('ye post method se aa ra hai ')
        # print(request.POST.get('email'))
        # print(request.POST.get('passward'))

        nm = request.POST.get('email')
        pw = request.POST.get('passward')
        reg = User(email=nm, passward=pw)
        reg.save()

    else:
        return render(request, 'testapp/index.html')
    return render(request, 'testapp/index.html')
예제 #6
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('main.home'))
    form = RegistrationForm()
    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user = User(username=form.username.data,
                    email=form.email.data,
                    password=hashed_password)
        db.session.add(user)
        db.session.commit()
        flash('Your account has been created! You are now able to log in',
              'success')
        return redirect(url_for('users.login'))
    return render_template('register.html', title='Register', form=form)