示例#1
0
def register():
    form = RegisterForm()
    if form.validate_on_submit():
        user = User(username=form.username.data, email=form.email.data)
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()
        return redirect(url_for('login'))
    return render_template('register.html', title="Kaydol", form=form)
示例#2
0
def register():
    form = RegisterForm()
    # On GET request, return false
    if form.validate_on_submit():
        flash('Registered visitor: {}'.format(form.user_name.data))
        visitor = User(user_name = form.user_name.data)
        session.add(visitor)
        session.commit()
        return redirect(url_for('index'))
    return render_template('register.html', form=form)
示例#3
0
def register(request):
    ''' Регистрация нового пользователя '''
    print(request.POST)
    form = RegisterForm(request.POST)
    if form.is_valid():
        cd = form.cleaned_data
        user = User.objects.create_user(**cd)
        token = Token.objects.get(user=user)
        return HttpResponse(json.dumps({'token': token.key,
                             'username': cd['username']}),
                            content_type='application/json')
    return HttpResponse(form.errors)
示例#4
0
def register(request):
    if request.method == "POST":
       #Get the posted form
       form = RegisterForm(request.POST)
       username = form['username'].value()
       password = form['password'].value()
       args=(username,password)
       ## ADD to database and check if user already exists
       sql = "SELECT * FROM USERS WHERE user_id = \'"+username+"\'"
       cursor.execute(sql)
       if not cursor.rowcount:
           s = "INSERT INTO USERS  VALUES (%s,%s);"
           cursor.execute(s,args)
           daba.commit()
           request.session['LoginMessage'] = "Success! Please login Now."
           return redirect(login)
       else:
           request.session['LoginMessage'] = "You've already registered! Please login now"
           return redirect(login)



    if request.method == "GET":
        if request.session.has_key('username') and request.session['username'] != None :
           return redirect('/')
        else:
           return render(request, 'register.html', {"message" : "Please Signup"})
示例#5
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = RegisterForm()
    if form.validate_on_submit():
        user = User(username=form.username.data,
                    email=form.email.data,
                    is_admin=True)

        user.set_password(form.password.data)
        # veritabanına kayıt için session'a kullanıcıyı ekle
        db.session.add(user)
        # veritabanına gönder
        db.session.commit()
        return redirect(url_for('login'))

    return render_template('register.html', title="Kaydol", form=form)
def register():
    if request.method == 'GET':
        form = RegisterForm()
        return render_template('register.html', form=form)
    user = User(request.form['username'], request.form['password'],
                request.form['email'])
    db.session.add(user)
    db.session.commit()
    flash('User successfully registered')
    return redirect(url_for('login'))
示例#7
0
def signup():
    """
    Goes to registration page and requests for email, username, and password. Stores members in database.
    :return: Sends user to login page after submitting a valid username, email, password.
    Else, it will not leave the page.
    """
    form = RegisterForm()

    if form.validate_on_submit():
        hashed_password = form.password.data
        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!')
        return redirect(url_for('login'))

    return render_template('signup.html', form=form)
示例#8
0
def register(request):
    if request.method == 'POST':
        form = RegisterForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect('myapp:login')

    form = RegisterForm()
    return render(request, 'myapp/register.html', {'form': form})
示例#9
0
def user_authn(request):
    userlist = User_info.objects.all()
    login_form = LoginForm()
    reg_form = RegisterForm()

    if request.method == 'POST':
        if 'signin' in request.POST:
            username = request.POST['username']
            password = request.POST['password']
            user = authenticate(username=username, password=password)
            if user:
                if user.is_active:
                    login(request, user)
                    user_ad = get_object_or_404(User_info, id=request.user.id)
                    return render(request, 'myapp/index.html/', {
                        'user': user,
                        'user_ad': user_ad
                    })
                else:
                    return HttpResponse('Your account is disabled.')
            else:
                return HttpResponse('Invalid login details!!')
        elif 'signup' in request.POST:
            if request.method == 'POST':
                form = RegisterForm(request.POST, request.FILES)
                if form.is_valid():
                    user = form.save(commit=False)
                    user.set_password(form.cleaned_data['password'])
                    user.save()
                    Relationship.objects.get_or_create(rel_from_user=user,
                                                       rel_to_user=user,
                                                       rel_status=3)
                    return HttpResponseRedirect('/myapp/')
                else:
                    return HttpResponse('Invalid details.')
    else:
        return render(request, "myapp/login.html", {
            'form': login_form,
            'form': reg_form,
            'userlist': userlist
        })
示例#10
0
def register_program(request, program_id):
    try:
        program = Program.objects.get(pk=program_id)
        if request.method == 'POST':
            form = RegisterForm(request.POST)
            if form.is_valid():
                customer = form.save()
                registration = Registration.objects.create(customer=customer,
                                                           program=program)
                #return HttpResponseRedirect('/player/%s', customer.id)
                body = '%s %s has been registered in %s' % (
                    customer.firstname, customer.lastname, program.title)
                to = customer.email
                send_mail('Confirmation for RT Hockey Registration',
                          body,
                          settings.EMAIL_HOST_USER, [to],
                          fail_silently=False)
                return render(request, 'myapp/player.html',
                              {'customer': customer})
        else:
            form = RegisterForm()
    except Program.DoesNotExist:
        raise Http404("Program does not exist")
    return render(request, 'myapp/register_program.html', {
        'program': program,
        'form': form
    })
示例#11
0
文件: views.py 项目: Priya5686/Intern
def register(request):
    if request.method == 'POST':
        form = RegisterForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect('/app')
    else:
        form = RegisterForm()

        args = {'form': form}
        return render(request, 'myapp/reg_form.html', args)
示例#12
0
文件: views.py 项目: thomashhs/myblog
def register(request):
    redirect_to = request.POST.get('next', request.GET.get('next', ''))

    if request.method == 'POST':
        form = RegisterForm(request.POST)
        if form.is_valid():
            form.save()
            if redirect_to:
                return redirect(redirect_to)
            else:
                return redirect('/')
    else:
        form = RegisterForm()
    return render(request, "register.html", {'form': form})
示例#13
0
def register(request):
    if request.user.is_authenticated:
        return redirect('myapp:logout')
    else:
        if request.method == 'POST':
            form = RegisterForm(request.POST)
            if form.is_valid():
                form.save()
                return redirect('myprofile:list')
        else:
            form = RegisterForm()

            args = {'form': form}
            return render(request, 'myapp/register.html', args)
示例#14
0
def register(request):
    studentlist = Student.objects.all()
    if request.method == 'POST':
        form = RegisterForm(request.POST, request.FILES)
        if form.is_valid():
            student = form.save(commit=False)
            student.save()
            return HttpResponseRedirect(reverse('myapp:index'))
    else:
        form = RegisterForm()
    return render(request, 'myapp/register.html', {
        'form': form,
        'studentlist': studentlist
    })
示例#15
0
def register(request):
    userlist = User_Auth.objects.all()
    if request.method == 'POST':
        form = RegisterForm(request.POST, request.FILES)
        if form.is_valid():
            student = form.save(commit=False)
            student.set_password(form.cleaned_data['password'])
            student.save()
            return HttpResponseRedirect('/myapp/')
    else:
        form = RegisterForm()
    return render(request, "myapp/register.html", {
        'form': form,
        'userlist': userlist
    })
示例#16
0
def register(request):
    if request.method == "POST":
        form = RegisterForm(request.POST)
        if form.is_valid():
            email = request.POST['email']
            username = request.POST['first_name'] + "@apssdc.in"
            pwd = random.randint(1000, 9999)
            form.save()
            data = Register.objects.get(email=request.POST['email'])
            data.password = pwd
            data.username = username
            data.save()
            send_mail(
                "Your Data Registered Succesfully",
                "Your Username: "******"Your Password is: " + str(pwd),
                settings.EMAIL_HOST_USER, [email])
            return HttpResponse("Check Your Mail")

        return HttpResponse("Already Registered")
    form = RegisterForm()
    return render(request, 'myapp/register.html', {'form': form})