示例#1
0
def reset_token(token):

    if current_user.is_authenticated:
        return redirect(url_for('admin'))

    user = User.varify_reset_token(token)

    if user is None:
        flash('that is invalid or expired token ', 'warning')
        return redirect(url_for('reset_request'))
    form = ResetPasswordForm()
    if form.validate_on_submit():
        register = Register(name=form.name.data,
                            username=form.username.data,
                            email=form.email.data,
                            password=form.password.data,
                            country=form.country.data,
                            city=form.city.data,
                            contact=form.contact.data,
                            address=form.address.data,
                            zipcode=form.zipcode.data)
        db.session.add(register)
        flash(f'Welcome {form.name.data} Thank you for registering', 'success')
        db.session.commit()
    return redirect(url_for('customerLogin'))
    return render_template('customer/reset_token.html',
                           title='Reset Password',
                           form=form)
示例#2
0
def workregister():
    if request.method == 'POST':
        print('start....', request.method)
        print('start1....', request.args)
        print('start....', request.form)
        weixin = request.form.get("weixin")
        phone = request.form.get('phone')
        taobao = request.form.get('taobao')
        location = request.form.get('location')

        print('search weixin...', weixin)
        print('search phone...', phone)
        print('search taobao...', taobao)
        print('search location...', location)

        from model import Register
        engine = create_engine(
            "mysql://root:@127.0.0.1:3306/family?charset=utf8")
        Session = sessionmaker(bind=engine)
        session = Session()

        register = Register(weixin=weixin,
                            phone=phone,
                            taobao=taobao,
                            localcation=location)
        session.add(register)
        session.commit()

    return 'start compute...'
示例#3
0
def register_user(register: Register):

    sql = '''INSERT INTO "user"
            (first_name, surname, email, password, location, family_id)
            VALUES (%(first_name)s, %(surname)s, %(email)s, %(password)s, %(location)s, %(family_id)s);'''
    with psycopg2.connect(current_app.config['db_URL']) as conn:
        cur = conn.cursor()
        cur.execute(sql, register._asdict())
示例#4
0
def join():
    """allows user to join or leave event """
    # getting event id from homepage
    event_id = request.args.get('eventId')
    user_id = session['user']
    register = Register(user_id = user_id, event_id = event_id)
    db.session.add(register)
    db.session.commit()

    return redirect('/')
示例#5
0
文件: app.py 项目: sullyj3/IT-project
def editsettings():

    if request.method == 'GET':
        return render_template('edit_account_settings.html')
    elif request.method == 'POST':

        changed_details = Register(first_name=request.form["first_name"],
                                   surname=request.form["surname"],
                                   location=request.form["location"],
                                   family_id=None,
                                   email=None,
                                   password=None)

        edit_user_details(current_user.id, changed_details)
        flash("Details changed")
        return redirect('/profile')
示例#6
0
def customer_register():
    form = CustomerRegisterForm()
    if form.validate_on_submit():
        register = Register(name=form.name.data,
                            username=form.username.data,
                            email=form.email.data,
                            password=form.password.data,
                            country=form.country.data,
                            city=form.city.data,
                            contact=form.contact.data,
                            address=form.address.data,
                            zipcode=form.zipcode.data)
        db.session.add(register)
        flash(f'Welcome {form.name.data} Thank you for registering', 'success')
        db.session.commit()
        return redirect(url_for('customerLogin'))
    return render_template('customer/register.html', form=form)
示例#7
0
文件: app.py 项目: sullyj3/IT-project
def register():
    if request.method == 'GET':

        if current_user.is_authenticated:
            flash("You are already registered")
            return redirect(url_for('/'))
        else:
            return render_template('register.html')

    elif request.method == 'POST':

        if request.form['pass'] == request.form['confirm_pass'] and len(
                request.form['pass']) > 0:

            new_user = Credentials(request.form['email'], request.form['pass'])
            user_details = email_taken(new_user)

            if not user_details:
                # Creates famly if no referral_code

                if "new_family" in request.form:
                    family_id = create_family(request.form['surname'])
                else:
                    family_id = get_family_id(request.form['referral_code'])

                # Creates new register with hashed password
                new_register = Register(
                    request.form['first_name'], request.form['surname'],
                    family_id, request.form['email'], request.form['location'],
                    generate_password_hash(request.form['pass']))

                register_user(new_register)

                # Logs in user after adding to database
                db_user = email_taken(new_user)
                login_user(User(db_user))

                flash('Successfully registered')
                return redirect('/')
            else:
                flash("User already exists")
        else:
            flash("Passwords are not the same, or you have missing fields")
        return redirect(url_for('register'))
示例#8
0
def register_menu():
    processes = int(input("Enter the number of processes: "))
    lot_number = processes / 4
    remaining = residue(processes, 4)
    total_lots = int(lot_number + remaining)
    completed_lots = 0
    completed_processes = 0
    remaining_processes = processes
    id = isIdValid(1)
    while completed_lots != total_lots and remaining_processes != 0:
        for i in range(0, processes):
            id = int(input("Enter the id: "))
            if isIdValid(id):
                name = input("Enter the name: ")
                operation = operations_menu()
                max_ex_time = int(input("Enter the maxmimum operation time: "))
                register = Register(id=id,
                                    name=name,
                                    operation=operation,
                                    max_ex_time=max_ex_time)
                registers.append(register)
        remaining_processes -= 1
        completed_processes += 1
    if completed_processes == 4:
        completed_lots += 1
        completed_processes = 0

        for x in registers:
            print(f'Id: {x.id}')
            print(f'Name: {x.name}')
            print(f'Operation: {x.operation}')
            print(f'TME: {x.max_ex_time}')
            print("*------*" * 5)
        print(f"Initial processes: {processes}")
        print(f'Remaining processes: {remaining_processes}')
        print(f'Total lots: {total_lots}')
        print(f'Completed lots: {completed_lots}')
        print(f'Completed processes: {completed_processes}')

    if completed_lots == total_lots:
        break