Пример #1
0
def registration(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            model = Form()
            model.fullname = data['fullname']
            model.wcaid = data['wcaid']
            model.country = data['country']
            model.city = data['city']
            model.email = data['email']
            model.tshirt = data['tshirt']
            model.nick = data['nick']
            model.accomodation = data['accomodation']
            model.born = datetime.date(int(data['bornyear']), int(data['bornmonth']), int(data['bornday']))
            model.events = [str(ev) for ev in data if ev.startswith('ev_') and data[ev] == True]
            model.status = 1
            model.put()

            return HttpResponseRedirect('/thanks')
    else:
        form = RegistrationForm()

    return render_to_response('registration.html', {
        'form': form,
        'page': 'registration',
        'years': range(1900, 2009),
        'months': range(1, 13),
        'days': range(1, 32),
        })
Пример #2
0
def signup(request):
    rider = get_rider(request)
    
    if rider:
        return HttpResponseRedirect('/entourage/')
    
    if request.method == 'POST':
        form = RegistrationForm(request.POST, request.FILES)
        if form.is_valid():
            rider = form.save(commit=False)
            
            if not rider.avatar:
                fname = generate_filename(rider, 'default.jpg')
                rider.avatar = fname
                default = settings.MEDIA_ROOT + 'riders/default.jpg'
                with open(default) as default:
                    with open(fname, 'w') as f:
                        f.write(default.read())
            
            rider.save()
        else:
            return render(request, 'entourage/signup.html', {'form': form})
        return HttpResponseRedirect('/entourage/login')
    else:
        form = RegistrationForm()

    return render(request, 'entourage/signup.html', {'form': form})
Пример #3
0
def register():
    # FUNCTIONALITY OF USER REGISTER
    form = RegistrationForm(request.form)
    if form.validate_on_submit():

        user = mongo.db.users
        existing_user = user.find_one({'username': request.form['username']})

        if existing_user is None:
            # HASHED PW AND INSERT TO COLL
            hashed_pw = bcrypt.hashpw(request.form['password'].encode('utf-8'),
                                      bcrypt.gensalt())
            mongo.db.users.insertOne({
                'username': request.form['username'],
                'email': request.form['email'],
                'password': hashed_pw
            })
            session['username'] = request.form['username']
            # IF REGISTER IS SUCCESSFUL
            flash(
                f'Account created for {form.username.data}.. now just to login',
                'success')
            return redirect(url_for('login'))  #TODO CHANGE TO USER PROFILE

        else:
            flash(f'Registration Failed. Check yo\'self, please try again!',
                  'danger')
    return render_template('register.html', title='Register', form=form)
Пример #4
0
def register(request):
    template = 'register.html'

    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            delegate = Delegates(username=request.POST['username'],
                                 password=md5.md5(request.POST['password']).hexdigest(),
                                 fname=request.POST['fname'],
                                 sname=request.POST['sname'],
                                 dob=request.POST['dob'],
                                 email=request.POST['email'])
            delegate.save();
            user = User.objects.create_user(request.POST['username'],
                                            request.POST['email'],
                                            request.POST['password'])
            user.save();
            #send_mail("djahfaj","aouhfpoa","*****@*****.**",['*****@*****.**'],fail_silently=False)
            return HttpResponse("Logged In Sucessfully")
    else :
        form = RegistrationForm()
    data = {
        'form' : form
    }
    return render_to_response(template,data,context_instance = RequestContext(request))
Пример #5
0
def sign_up(slug):
    try:
        course = find_course(slug)
    except ValueError:
        return abort(404)
    form = RegistrationForm(
        course_slug=course.slug,
        first_name=request.form['first_name'],
        last_name=request.form['last_name'],
        email=request.form['email'],
        phone=request.form['phone'],
        payment_type=request.form.get('payment_type', ''),
        paypal_email=request.form.get('paypal_email', ''),
        attendance=request.form.get('attendance', ''),
        referrer_name=request.form.get('referrer_name', ''),
        assessments=request.form.get('assessments', ''),
        instance=course,
    )
    if form.valid():
        registration = form.build()
        db_session.add(registration)
        db_session.commit()
        session['registration_id'] = registration.id
        return redirect("/thank-you")
    else:
        form.active = True
        return render_group_fitness(course, form)
Пример #6
0
def register():
    form = RegistrationForm(request.form)
    if request.method == 'POST' and form.validate():
        user = User(form.username.data, form.email.data, form.password.data)
        print("i m here")
        db_session.add(user)
        db_session.commit()
        return redirect(url_for('index'))
    return render_template('register.html', form=form)  
Пример #7
0
def register(request):
    """
    User registration view.
    """
    if request.method == 'POST':
        form = RegistrationForm(data=request.POST)
        if form.is_valid():
            user = form.save()
            return redirect('/')
    else:
        form = RegistrationForm()
    return render_to_response('register.html', {
        'form': form,
    }, context_instance=RequestContext(request))
Пример #8
0
def register_new_user(request):
    if request.method == 'POST':
        #usernamE = request.POST.get('username', '')
        #password = request.POST.get('password', '')
        #emaiL = request.POST.get('email', '')
        #phonE = request.POST.get('phone_number', '')

        form = RegistrationForm(data = request.POST)
        if form.is_valid():
            user = form.save()
            return HttpResponseRedirect('/online_store/register_success')
        else:
            return HttpResponseRedirect('online_store/loggedin.html')

    else:
        form = RegistrationForm()

    args = {}
    args.update(csrf(request))

    args['form'] = form

    return render_to_response('invalid_login.html', args)
Пример #9
0
def hello_world():
    form = RegistrationForm(request.form)
    if request.form.get('signup'):
        form = RegistrationForm(request.form)
        if request.method == 'POST' and form.validate():
            userdet = {}
            for i in form:
                userdet[i.name] = i.data
            cur.execute(
                f"Select 1 from users where username = '******'username']}'"
            )
            if len(cur.fetchall()) > 0:
                flash('Username already taken! Choose another', 'danger')
                return render_template('login.html',
                                       pageType=str(request.url_rule),
                                       form=form)
            userdet['password'] = bcrypt.generate_password_hash(
                userdet['password']).decode('utf-8')
            cur.execute(
                f"insert into users(fname, lname, email_id, username, password, contact_no) values('{userdet['fname']}', '{userdet['lname']}', '{userdet['email']}', '{userdet['username']}', '{userdet['password']}', {userdet['phno']})"
            )
            conn.commit()
            session['user'] = userdet
            flash('Registered successfully!', 'success')
        elif not form.validate():
            print(":((((((((()))))))))")
            flash('Please enter details properly', 'danger')
            # return render_template('login.html', pageType = str(request.url_rule), form = form)
    else:
        form1 = LoginForm(request.form)
        if request.method == 'POST' and form1.validate():
            print('abcd')
            u = request.form.get('username')
            p = request.form.get('password')
            print(u, p)
            print(
                f"Select * from users where username='******' and password='******'utf-8')}'"
            )
            cur.execute(f"Select * from users where username='******'")
            ulist = cur.fetchall()
            # print(ulist)
            if len(ulist) > 0:
                if bcrypt.check_password_hash(ulist[0][5], p):
                    flash('Login successful!', 'success')
                    session['user'] = list(ulist[0])
                    for i in range(len(session['user'])):
                        session['user'][i] = str(session['user'][i])
                    session['user'] = dict(zip(user_col, session['user']))
                    return redirect(url_for('new_homepage'))
                else:
                    flash(
                        'Could not find matching username or password. Please check your login credentials.',
                        'danger')
            else:
                flash(
                    'Could not find matching username or password. Please check your login credentials.',
                    'danger')
        print('wxyz', request.url_rule, type(request.url_rule))
    return render_template('login.html',
                           pageType=str(request.args.get('type')),
                           form=form)