예제 #1
0
파일: main.py 프로젝트: Ivanm2114/mars-http
def main():
    db_session.global_init("db/blogs.db")
    db_sess = db_session.create_session()

    user1 = User()
    user1.surname = 'Scott'
    user1.name = 'Ridley'
    user1.age = 21
    user1.position = 'captain'
    user1.speciality = 'research engeneer'
    user1.address = 'module 1'
    user1.email = "*****@*****.**"

    user2 = User()
    user2.surname = 'Elatskov'
    user2.name = 'Dimon'
    user2.age = 17
    user2.position = 'prgrammer'
    user2.speciality = 'engeneer'
    user2.address = 'module 69'
    user2.email = "*****@*****.**"

    user3 = User()
    user3.surname = 'Bon Jovi'
    user3.name = 'Jhon'
    user3.age = 77
    user3.position = 'musican'
    user3.speciality = 'entertainer'
    user3.address = 'module 4'
    user3.email = "*****@*****.**"

    db_sess.add(user1)
    db_sess.add(user2)
    db_sess.add(user3)
    db_sess.commit()
예제 #2
0
def main():
    db_session.global_init("db/blogs.db")
    user = User()
    user.surname = "Scott"
    user.name = "Ridley"
    user.age = 21
    user.position = "captain"
    user.speciality = "research engineer"
    user.address = "module_1"
    user.email = "*****@*****.**"
    db_sess = db_session.create_session()
    db_sess.add(user)
    db_sess.commit()
    user = User()
    user.surname = "Dead"
    user.name = "Line"
    user.age = 24
    user.position = "your dead"
    user.speciality = "your kill"
    user.address = "module_1"
    user.email = "*****@*****.**"
    db_sess = db_session.create_session()
    db_sess.add(user)
    db_sess.commit()
    user = User()
    user.surname = "Qwerty"
    user.name = "asd"
    user.age = 123
    user.position = "cap"
    user.speciality = "research engineer"
    user.address = "module_1"
    user.email = "*****@*****.**"
    db_sess = db_session.create_session()
    db_sess.add(user)
    db_sess.commit()
예제 #3
0
파일: main.py 프로젝트: pepilica/sqlalchemy
def main():
    session = db_session.create_session()
    user0 = User()
    user0.name = 'Ridley'
    user0.surname = 'Scott'
    user0.age = 21
    user0.position = 'captain'
    user0.speciality = 'research engineer'
    user0.address = 'module_1'
    user0.email = '*****@*****.**'
    session.add(user0)
    user1 = User()
    user1.name = 'Neal'
    user1.surname = 'Armstrong'
    user1.age = 82
    user1.position = 'senior engineer'
    user1.speciality = 'biologist'
    user1.address = 'module_1'
    user1.email = '*****@*****.**'
    session.add(user1)
    user2 = User()
    user2.name = 'Ivan'
    user2.surname = 'Sokolov'
    user2.position = 'Junior scientist'
    user2.speciality = 'programmer'
    user2.age = 24
    user2.address = 'module_2'
    user2.email = '*****@*****.**'
    session.add(user2)
    session.commit()
    app.run()
예제 #4
0
def new_users():
    db_session.global_init("db/blogs.db")
    db_sess = db_session.create_session()
    user = User()
    user.surname = 'Scott'
    user.name = 'Ridley'
    user.age = 21
    user.position = 'capitan'
    user.speciality = 'speciality research engineer'
    user.address = 'module_1'
    user.email = '*****@*****.**'
    db_sess.add(user)
    db_sess.commit()
    user = User()
    user.surname = 'Scott1'
    user.name = 'Ridley1'
    user.age = 21
    user.position = 'capitan'
    user.speciality = 'speciality research engineer'
    user.address = 'module_1'
    user.email = '*****@*****.**'
    db_sess.add(user)
    db_sess.commit()
    user = User()
    user.surname = 'Scott2'
    user.name = 'Ridley2'
    user.age = 21
    user.position = 'capitan'
    user.speciality = 'speciality research engineer'
    user.address = 'module_1'
    user.email = '*****@*****.**'
    db_sess.add(user)
    db_sess.commit()
예제 #5
0
파일: sqla.py 프로젝트: PolinaPar2003/files
def main():
    db_session.global_init("db/mars_explorer.db")
    user_kap = User()
    user_kap.surname = "Scott"
    user_kap.name = "Ridley"
    user_kap.age = 21
    user_kap.position = "captain"
    user_kap.speciality = "research engineer"
    user_kap.address = "module_1"
    user_kap.email = "*****@*****.**"
    db_sess = db_session.create_session()
    db_sess.add(user_kap)
    db_sess.commit()

    user_1 = User()
    user_1.surname = "Peter"
    user_1.name = "Polosh"
    user_1.age = 44
    user_1.position = "junior commander"
    user_1.speciality = "senior mechanic"
    user_1.address = "module_2"
    user_1.email = "*****@*****.**"
    db_sess = db_session.create_session()
    db_sess.add(user_1)
    db_sess.commit()

    user_2 = User()
    user_2.surname = "Harry"
    user_2.name = "Brown"
    user_2.age = 23
    user_2.position = "executor"
    user_2.speciality = "sailor"
    user_2.address = "module_4"
    user_2.email = "*****@*****.**"
    db_sess = db_session.create_session()
    db_sess.add(user_2)
    db_sess.commit()

    user_3 = User()
    user_3.surname = "Naill"
    user_3.name = "Horan"
    user_3.age = 32
    user_3.position = "assistant captain"
    user_3.speciality = "radio operator"
    user_3.address = "module_2"
    user_3.email = "*****@*****.**"
    db_sess = db_session.create_session()
    db_sess.add(user_3)
    db_sess.commit()

    job = Jobs(team_leader=1,
               job="deployment of residential modules 1 and 2",
               work_size=15,
               collaborators="2, 3",
               is_finished=False)
    db_sess.add(job)
    db_sess.commit()
    app.run()
예제 #6
0
파일: main_db.py 프로젝트: fairytallee/WEB
def append_users():
    db_sess = db_session.create_session()
    try:
        db_sess.query(User).delete()
        db_sess.commit()
        user = User()
        user.surname = "Scott"
        user.name = "Ridley"
        user.age = 21
        user.position = "captain"
        user.speciality = "research engineer"
        user.address = "module_1"
        user.email = "*****@*****.**"
        user.hashed_password = "******"
        db_sess.add(user)
        db_sess.commit()

        user = User()
        user.surname = "Steve"
        user.name = "Jobs"
        user.age = 34
        user.position = "director"
        user.speciality = "all what you want"
        user.address = "module_1"
        user.email = "*****@*****.**"
        user.hashed_password = "******"
        db_sess.add(user)
        db_sess.commit()

        user = User()
        user.surname = "Elon"
        user.name = "Hask"
        user.age = 51
        user.position = "president"
        user.speciality = "businessman"
        user.address = "module_2"
        user.email = "*****@*****.**"
        user.hashed_password = "******"
        db_sess.add(user)
        db_sess.commit()

        user = User()
        user.surname = "Vlad"
        user.name = "Shmelkov"
        user.age = 16
        user.position = "little gamer"
        user.speciality = "lol"
        user.address = "module_12"
        user.email = "*****@*****.**"
        user.hashed_password = "******"
        db_sess.add(user)
        db_sess.commit()

    except Exception as ex:
        print(f'Ошибка: {ex}')

    for user in db_sess.query(User).all():
        print(user)
예제 #7
0
파일: main.py 프로젝트: LorezV/sqlacheme
def main():
    db_session.global_init("db/blogs.db")
    session = db_session.create_session()

    user = User()
    user.surname = 'Scott'
    user.name = 'Ridley'
    user.age = '21'
    user.position = 'captain'
    user.speciality = 'research engineer'
    user.address = 'module_1'
    user.email = '*****@*****.**'

    col1 = User()
    col1.surname = 'Derkach'
    col1.name = 'Dima'
    col1.age = '23'
    col1.position = 'polomoishik'
    col1.speciality = 'research engineer'
    col1.address = 'module_1'
    col1.email = '*****@*****.**'

    col2 = User()
    col2.surname = 'Kaha'
    col2.name = 'Sergo'
    col2.age = '26'
    col2.position = 'polomoishik'
    col2.speciality = 'research engineer'
    col2.address = 'module_1'
    col2.email = '*****@*****.**'

    col3 = User()
    col3.surname = 'Alex'
    col3.name = 'Boiko'
    col3.age = '21'
    col3.position = 'pilot'
    col3.speciality = 'research engineer'
    col3.address = 'module_1'
    col3.email = '*****@*****.**'

    job1 = Jobs()
    job1.team_leader = 1
    job1.job = 'deployment of residential modules 1 and 2'
    job1.work_size = 15
    job1.collaborators = '2, 3'

    session.add(user)
    session.add(col1)
    session.add(col2)
    session.add(col3)
    session.add(job1)
    session.commit()

    app.run(port=8080, host='127.0.0.1')
예제 #8
0
def main():
    db_session.global_init("db/blogs.db")

    user = User()
    user.surname = "Scott"
    user.name = "Ridley"
    user.age = 21
    user.position = "captain"
    user.speciality = "research engineer"
    user.address = "module_1"
    user.email = "*****@*****.**"
    user.hashed_password = "******"
    db_sess = db_session.create_session()
    db_sess.add(user)
    db_sess.commit()

    user = User()
    user.surname = "Stepanova"
    user.name = "Darya"
    user.age = 16
    user.position = "the second captain"
    user.speciality = "main system programmer"
    user.address = "module_1"
    user.email = "*****@*****.**"
    user.hashed_password = "******"
    db_sess = db_session.create_session()
    db_sess.add(user)
    db_sess.commit()

    user = User()
    user.surname = "Ononas"
    user.name = "Ray"
    user.age = 19
    user.position = "captain"
    user.speciality = "gravity engineer"
    user.address = "module_4"
    user.email = "*****@*****.**"
    user.hashed_password = "******"
    db_sess = db_session.create_session()
    db_sess.add(user)
    db_sess.commit()

    user = User()
    user.surname = "Lightwood"
    user.name = "Jeffrey"
    user.age = 29
    user.position = "main soldier"
    user.speciality = "weapon checker"
    user.address = "module_5"
    user.email = "*****@*****.**"
    user.hashed_password = "******"
    db_sess = db_session.create_session()
    db_sess.add(user)
    db_sess.commit()
예제 #9
0
파일: main.py 프로젝트: Tehnorobot/sql1.1
def main():
    db_session.global_init("db/mars_explorer.db")
    user = User()
    user.surname = "Scott"
    user.name = "Ridley"
    user.age = 21
    user.position = "captain"
    user.speciality = "research engineer"
    user.address = "module_1"
    user.email = "*****@*****.**"
    user.hashed_password = "******"
    db_sess = db_session.create_session()
    db_sess.add(user)
    db_sess.commit()
    user2 = User()
    user2.surname = "John"
    user2.name = "Gastings"
    user2.age = 30
    user2.position = "coock"
    user2.speciality = "coocks food"
    user2.address = "module_2"
    user2.email = "*****@*****.**"
    user2.hashed_password = "******"
    db_sess = db_session.create_session()
    db_sess.add(user2)
    db_sess.commit()
    user3 = User()
    user3.surname = "Majer"
    user3.name = "Bambula"
    user3.age = 25
    user3.position = "security captain"
    user3.speciality = "security"
    user3.address = "module_3"
    user3.email = "*****@*****.**"
    user3.hashed_password = "******"
    db_sess = db_session.create_session()
    db_sess.add(user3)
    db_sess.commit()
    user4 = User()
    user4.surname = "Arthur"
    user4.name = "Reigan"
    user4.age = 54
    user4.position = "chemist"
    user4.speciality = "chemist"
    user4.address = "module_4"
    user4.email = "*****@*****.**"
    user4.hashed_password = "******"
    db_sess = db_session.create_session()
    db_sess.add(user4)
    db_sess.commit()
예제 #10
0
def main():
    db_session.global_init("db/blogs.sqlite")
    captain = User()
    captain.surname = 'Scott'
    captain.name = 'Ridley'
    captain.age = 21
    captain.position = 'captain'
    captain.speciality = 'research engineer'
    captain.address = 'module_1'
    captain.email = '*****@*****.**'
    user1 = User()
    user1.surname = 'Max'
    user1.name = 'Riddel'
    user1.age = 47
    user1.position = 'ex-captain'
    user1.speciality = 'physic engineer'
    user1.address = 'module_7'
    user1.email = '*****@*****.**'
    user2 = User()
    user2.surname = 'Scaut'
    user2.name = 'Cherly'
    user2.age = 31
    user2.position = 'high enginer'
    user2.speciality = 'theory engineer'
    user2.address = 'module_4'
    user2.email = '*****@*****.**'
    user3 = User()
    user3.surname = 'Presnyakov'
    user3.name = 'Nikita'
    user3.age = 28
    user3.position = 'mechanic'
    user3.speciality = 'mechanic'
    user3.address = 'module_2'
    user3.email = '*****@*****.**'
    job1 = Jobs()
    job1.team_leader = 1
    job1.job = 'deployment of residential modules 1 and 2'
    job1.work_size = 15
    job1.collaborators = '2, 3'
    job1.start_date = '(now)'
    job1.is_finished = False
    session = db_session.create_session()
    session.add(captain)
    session.add(user1)
    session.add(user2)
    session.add(user3)
    session.add(job1)
    session.commit()
    app.run()
예제 #11
0
def main():
    db_session.global_init("db/blogs.db")
    #app.run()
    user = User()
    user.surname = 'Scott'
    user.name = "Ridley"
    user.age = "21"
    user.position = 'captain'
    user.speciality = 'research engineer'
    user.address = 'module_1'
    user.email = "*****@*****.**"
    db_sess = db_session.create_session()
    db_sess.add(user)

    user2 = User()
    user2.surname = 'Nastya'
    user2.name = "Peace"
    user2.age = "13"
    user2.position = 'serjant'
    user2.speciality = 'research engineer'
    user2.address = 'module_2'
    user2.email = "*****@*****.**"
    db_sess = db_session.create_session()
    db_sess.add(user2)

    user3 = User()
    user3.surname = 'Ivan'
    user3.name = "Ivanov"
    user3.age = "19"
    user3.position = 'cap'
    user3.speciality = 'research engineer'
    user3.address = 'module_3'
    user3.email = "*****@*****.**"
    db_sess = db_session.create_session()
    db_sess.add(user3)

    user4 = User()
    user4.surname = 'Nyton'
    user4.name = "Zendea"
    user4.age = "24"
    user4.position = 'op op'
    user4.speciality = 'research engineer'
    user4.address = 'module_4'
    user4.email = "*****@*****.**"
    db_sess = db_session.create_session()
    db_sess.add(user4)

    db_sess.commit()
예제 #12
0
def get_users():
    session = db_session.create_session()
    if request.method == "GET":
        return jsonify([get_user(i).json for i in range(1, session.query(User).count() + 1)])
    elif request.method == "POST":
        if not request.json:
            return jsonify({'error': 'Empty request'})
        elif not all(key in (rj := request.json) for key in
                     {'address',
                      'position',
                      'speciality',
                      'surname',
                      'name',
                      'login',
                      'age',
                      'password',
                      'city_from'}):
            return jsonify({'error': 'Bad request'})
        elif session.query(Jobs).get(request.json['job_id']):
            return jsonify(error="Id already exists")
        user = User()
        user.address = request.json['address']
        user.position = request.json['position']
        user.speciality = request.json['speciality']
        user.surname = request.json['surname']
        user.name = request.json['name']
        user.email = request.json['login']
        user.city_from = request.json['city_from']
        user.age = int(request.json['age'])
        user.modified_date = datetime.datetime.now()
        user.set_password(request.json['password'])
        session.add(user)
        session.commit()
        return jsonify(success="OK")
예제 #13
0
def reqister():
    db_session.global_init("db/info.sqlite")
    form = RegisterForm()
    if request.method == 'POST' and form.validate_on_submit():
        if form.password.data != form.password_again.data:
            return render_template('register.html',
                                   title='Регистрация',
                                   form=form,
                                   message="Пароли не совпадают")
        session = db_session.create_session()
        if session.query(User).filter(User.email == form.email.data).first():
            return render_template('register.html',
                                   title='Регистрация',
                                   form=form,
                                   message="Такой пользователь уже есть")
        user = User()
        user.name = form.name.data
        user.surname = form.surname.data
        user.email = form.email.data
        user.address = form.address.data
        user.age = int(form.age.data)
        user.set_password(form.password.data)
        session.add(user)
        session.commit()
        return redirect('/login')
    return render_template('register.html', title='Регистрация', form=form)
예제 #14
0
def add_user():
    if not request.json:
        return jsonify({'error': 'Empty request'})
    elif not all(key in request.json for key in
                 ['id',
                  'surname',
                  'name',
                  'age',
                  'position',
                  'speciality',
                  'address',
                  'password',
                  'email',
                  'city_from']):
        return jsonify({'error': 'Bad request'})
    session = db_session.create_session()
    if session.query(User).filter(User.id == request.json['id']).first():
        return jsonify({'error': 'Id already exists'})
    user = User()
    user.id = request.json['id']
    user.surname = request.json['surname']
    user.name = request.json['name']
    user.age = request.json['age']
    user.position = request.json['position']
    user.speciality = request.json['speciality']
    user.address = request.json['address']
    user.email = request.json['email']
    user.city_from = request.json['city_from']
    user.set_password(request.json['password'])
    session.add(user)
    session.commit()
    return jsonify({'success': 'OK'})
예제 #15
0
def register():
    if request.method == "GET":
        form = RegisterForm()
        return render_template("register.html", form=form)
    else:
        email = request.form["email"]
        password = request.form["password"]
        repeat_password = request.form["repeat_password"]
        surname = request.form["surname"]
        name = request.form["name"]
        age = request.form["age"]
        position = request.form["position"]
        speciality = request.form["speciality"]
        address = request.form["address"]

        if password != repeat_password:
            return "You didn't enter the same password"

        db_session.global_init("db/blogs.sqlite")
        session = db_session.create_session()

        user = User()
        user.email = email
        user.hashed_password = sha1(password.encode()).hexdigest()
        user.surname = surname
        user.name = name
        user.age = age
        user.position = position
        user.speciality = speciality
        user.address = address

        session.add(user)
        session.commit()

        return redirect("/success")
예제 #16
0
def reqister():
    db_session.global_init("db/information.sqlite")
    form = RegisterForm()
    if form.validate_on_submit():
        if form.password.data != form.password_again.data:
            return render_template('register.html', title='Регистрация',
                                   form=form,
                                   message="Пароли не совпадают")
        session = db_session.create_session()
        if session.query(User).filter(User.email == form.email.data).first():
            return render_template('register.html', title='Регистрация',
                                   form=form,
                                   message="Такой пользователь уже есть")
        user = User()
        user.email = form.email.data
        user.set_password(form.password.data)
        user.surname = form.surname.data
        user.name = form.name.data
        user.age = form.age.data
        user.position = form.position.data
        user.speciality = form.speciality.data
        user.address = form.address.data
        user.modifed_date = datetime.datetime.now()
        session = db_session.create_session()
        session.add(user)
        session.commit()

        return '<h1>Данные сохранены!</h1>'
    return render_template('register.html', title='Регистрация', form=form)
예제 #17
0
def add_user():
    password = False
    email = False
    form = RegisterForm()
    if form.hashed_password.data != form.confirm_password.data:
        password = True
    db_sess = db_session.create_session()
    emails = []
    for user in db_sess.query(User).all():
        emails.append(user.email)
    if form.email.data in emails:
        email = True
    if form.validate_on_submit() and not password and not email:
        user = User()
        user.surname = form.surname.data
        user.name = form.name.data
        user.age = form.age.data
        user.position = form.position.data
        user.speciality = form.speciality.data
        user.address = form.address.data
        user.email = form.email.data
        user.set_password(form.hashed_password.data)
        db_sess.add(user)

        db_sess.commit()
        login_user(user)
        return redirect('/')
    return render_template('register.html',
                           title='Регистрация',
                           password=password,
                           email=email,
                           form=form)
예제 #18
0
def register():
    form = RegisterForm()

    if form.validate_on_submit():
        session = database_session.create_session()
        if session.query(User).filter(User.email == form.email.data).first():
            params = {
                "title": "Регистрация",
                "form": form,
                "message": "Такой пользователь уже есть"
            }
            return render_template('register.html', **params)

        user = User()
        user.surname = form['surname'].data
        user.name = form['name'].data
        user.age = form['age'].data
        user.position = form['position'].data
        user.speciality = form['speciality'].data
        user.address = form['address'].data
        user.email = form['email'].data
        user.set_password(form['password'].data)
        session.add(user)
        session.commit()
        return redirect('/login')

    params = {"title": "Регистрация", "form": form, "message": False}
    return render_template("register.html", **params)
예제 #19
0
파일: main.py 프로젝트: tamco61/xxzz-
def login():
    form = LoginForm()
    if request.method == 'GET':
        if form.validate_on_submit():
            return redirect('/success')
        return render_template('login.html', title='Авторизация', form=form)
    elif request.method == 'POST':
        db_session.global_init('db/mars_explorer.sqlite')
        session = db_session.create_session()
        data = [i.email for i in session.query(User).all()]
        if form.email.data in data:
            return 'Error email'
        if form.password_first.data != form.password_second.data:
            return 'Error password'
        user = User()
        user.email = form.email.data
        user.name = form.name.data
        user.surname = form.surname.data
        user.age = form.age.data
        user.position = form.position.data
        user.speciality = form.speciality.data
        user.address = form.address.data
        user.hashed_password = form.password_second.data
        session.add(user)
        session.commit()

        return 'OK'
예제 #20
0
def main():
    db_session.global_init("db/blogs.db")
    info = [[
        "Scott", "Ridley", 21, "captain", "research engineer", "module_1",
        "*****@*****.**"
    ],
            [
                "Jack", "PewDiePie", 35, "corporal", "programmer", "module_2",
                "*****@*****.**"
            ],
            [
                "Jack", "Levi", 34, "corporal", "strategist", "module_3",
                "*****@*****.**"
            ]]
    for surname, name, age, position, speciality, address, email in info:
        user = User()
        user.surname = surname
        user.name = name
        user.age = age
        user.position = position
        user.speciality = speciality
        user.address = address
        user.email = email
        db_sess = db_session.create_session()
        db_sess.add(user)
        db_sess.commit()
예제 #21
0
def register():
    if request.method == "POST":
        db_sess = db_session.create_session()
        req = request.form
        name = req.get("name")
        address = req.get("address")
        phone_number = req.get("phone_number")
        password = req.get("password")
        if name != "" and address != "" and phone_number != "" and password != "":
            if "".join(name.split()).isalpha() and phone_number.isdigit() \
                    and len(phone_number) == 11 and len(password) >= 8:
                if not db_sess.query(User).filter(
                        User.phone_number == phone_number).first():
                    user = User()
                    user.name = name
                    user.address = address
                    user.phone_number = phone_number
                    user.set_password(password=password)
                    db_sess.add(user)
                    db_sess.commit()
                    db_sess.close()
                else:
                    return render_template(
                        "reg.html",
                        error_text=
                        "Аккаунт с таким номером телефона уже существует!")
            else:
                return render_template("reg.html",
                                       error_text="Ошибка при вводе данных")
        else:
            return render_template("reg.html",
                                   error_text="Нужно заполнить все поля!")
        return redirect("/login")
    return render_template("reg.html")
예제 #22
0
파일: main.py 프로젝트: MrEmgin/MarsIT
def register():
    if request.method == 'GET':
        return render_template('register_form.html',
                               title='Register form',
                               warning='')
    elif request.method == 'POST':
        session = db_session.create_session()

        user = User()
        user.surname = request.form['surname']
        user.name = request.form['name']
        user.age = int(request.form['age'])
        user.position = request.form['position']
        user.speciality = request.form['speciality']
        user.address = request.form['address']
        user.email = request.form['email']
        user.set_password(request.form['password'])
        if request.form['password'] != request.form['repeat']:
            return render_template('register_form.html',
                                   title='Register form',
                                   warning='Passwords are different!')

        session.add(user)
        session.commit()
        return 'Sent<br>' + str(user)
예제 #23
0
def register():
    session = db_session.create_session()
    form = RegisterForm(request.form)
    if request.method == "POST" and form.validate_on_submit():
        if session.query(User).filter(User.email == form.login.data).first():
            flash("Error with input Login: Invalid login")
        else:
            user = User()
            user.address = form.address.data
            user.position = form.position.data
            user.speciality = form.speciality.data
            user.surname = form.surname.data
            user.name = form.name.data
            user.email = form.login.data
            user.age = int(form.age.data)
            user.modified_date = datetime.datetime.now()
            user.set_password(form.password.data)
            session.add(user)
            session.commit()
            return redirect("/login")
    if form.errors:
        for k, v in form.errors.items():
            flash(f"Error with input {k}: {v[0]}")
    return render_template("standart.html",
                           base_title="Регистрация",
                           st_title="Register",
                           form=form,
                           current_user=current_user,
                           stpath=onepath)
예제 #24
0
def create_user():
    session = db_session.create_session()
    if not request.json:
        return jsonify({'error': 'Empty request'})
    elif not all(key in request.json for key in
                 ['id', 'surname', 'name', 'age', 'position', 'speciality', 'address', 'email',
                  'city_from', 'password']):
        return jsonify({'error': 'Missing some keys to create, you need keys to create:'
                                 'id, surname, name, age, position, speciality, address, email, city_from, password'})
    if session.query(User).get(request.json.get('id')):
        print('Id already exists')
    session = db_session.create_session()
    user = User()
    user.id = request.json.get('id')
    user.surname = request.json.get('surname')
    user.name = request.json.get('name')
    user.age = request.json.get('age')
    user.position = request.json.get('position')
    user.speciality = request.json.get('speciality')
    user.address = request.json.get('address')
    user.email = request.json.get('email')
    user.city_from = request.json.get('city_from')
    user.set_passwor(request.json.get('password'))
    session.add(user)
    session.commit()
    return jsonify({'success': 'OK'})
예제 #25
0
def register():
    form = RegisterForm()
    if form.validate_on_submit():
        session = db_session.create_session()
        user = session.query(User).filter(
            User.email == form.email.data).first()
        if not user and form.password and form.password_repeat.data == form.password.data:
            user = User()
            user.name = form.name.data
            user.email = form.email.data
            user.hashed_password = form.password.data
            user.surname = form.surname.data
            user.position = form.position.data
            user.speciality = form.speciality.data
            user.age = form.age.data
            user.address = form.address.data
            user.city_form = form.city.data
            user.modified_date = datetime.datetime.now()
            session.add(user)
            session.commit()
            return redirect("/")
        return render_template(
            'register.html',
            message="несовпадение паролей или пользователь уже зарегистрирован",
            form=form)
    return render_template('register.html',
                           title='Регистрация',
                           form=form,
                           text='Наше приложение')
예제 #26
0
def register():
    form = RegisterForm()
    if form.validate_on_submit():
        if form.password.data != form.password_again.data:
            return render_template('users/register.html',
                                   title='Registration',
                                   form=form,
                                   message="Passwords don't match")
        db_sess = db_session.create_session()
        if db_sess.query(User).filter(User.email == form.email.data).first():
            return render_template('users/register.html',
                                   title='Registration',
                                   form=form,
                                   message="This user already exists")
        user = User()
        user.name = form.name.data
        user.email = form.email.data
        user.address = form.address.data
        user.phone_number = form.phone_number.data
        user.set_password(form.password.data)
        db_sess.add(user)
        db_sess.commit()
        return redirect('/login')
    return render_template('users/register.html',
                           title='Registration',
                           form=form)
예제 #27
0
def register():
    form = RegisterForm()
    if form.validate_on_submit():
        if form.password.data != form.password_again.data:
            return render_template('register.html', title='Регистрация',
                                   form=form,
                                   message="Пароли не совпадают")
        db_sess = db_session.create_session()
        if db_sess.query(User).filter(User.email == form.email.data).first():
            return render_template('register.html', title='Регистрация',
                                   form=form,
                                   message="Такой пользователь уже есть")
        user = User()
        user.surname = form.surname.data
        user.name = form.name.data
        user.age = form.age.data
        user.position = form.position.data
        user.speciality = form.speciality.data
        user.address = form.address.data
        user.email = form.email.data
        user.set_password(form.password.data)
        db_sess.add(user)
        db_sess.commit()
        return redirect('/')
    return render_template('register.html', title='Регистрация', form=form)
예제 #28
0
def register():
    form = RegisterForm()
    if form.validate_on_submit():
        db_session.global_init("db/mars.db")
        db_sess = db_session.create_session()
        user = db_sess.query(User).filter(
            User.email == form.login_or_mail.data).first()
        if user:
            return render_template('register_form.html',
                                   form=form,
                                   message='Колонист с такой почтой уже есть!')
        if form.repeat_password.data != form.password.data:
            return render_template('register_form.html',
                                   form=form,
                                   message='Введенные пароли не совпадают!')
        user = User()
        user.surname = form.surname.data
        user.name = form.name.data
        user.age = form.age.data
        user.position = form.position.data
        user.speciality = form.speciality.data
        user.address = form.address.data
        user.email = form.login_or_mail.data
        user.set_password(form.password.data)
        db_sess.add(user)
        db_sess.commit()
        return redirect('/register')
    return render_template('register_form.html', form=form)
예제 #29
0
파일: main.py 프로젝트: Anna17-popova/base
def main():
    db_session.global_init("db/mars_explorer.db")
    #app.run()
    user = User()
    user.surname = 'Scott'
    user.name = 'Ridley'
    user.age = 21
    user.position = 'captain'
    user.speciality = 'research engineer'
    user.address = 'module_1'
    user.email = '*****@*****.**'
    db_sess = db_session.create_session()
    db_sess.add(user)
    db_sess.commit()
    user1 = User()
    user1.surname = 'Scott'
    user1.name = 'Mark'
    user1.age = 18
    user1.position = 'navigator'
    user1.speciality = 'engineer'
    user1.address = 'module_2'
    user1.email = '*****@*****.**'
    db_sess = db_session.create_session()
    db_sess.add(user1)
    db_sess.commit()
    user2 = User()
    user2.surname = 'Smith'
    user2.name = 'Ellis'
    user2.age = 18
    user2.position = 'doctor'
    user2.speciality = 'doctor'
    user2.address = 'module_3'
    user2.email = '*****@*****.**'
    db_sess = db_session.create_session()
    db_sess.add(user2)
    db_sess.commit()
    user3 = User()
    user3.surname = 'Smith'
    user3.name = 'Jane'
    user3.age = 20
    user3.position = 'scientist'
    user3.speciality = 'scientist'
    user3.address = 'module_4'
    user3.email = '*****@*****.**'
    db_sess = db_session.create_session()
    db_sess.add(user3)
    db_sess.commit()
예제 #30
0
def main():
    db_session.global_init("db/mars_explorer.db")

    captain = User()
    captain.surname = "Scott"
    captain.name = "Ridley"
    captain.age = 21
    captain.position = "captain"
    captain.speciality = "research engineer"
    captain.address = "module_1"
    captain.email = "*****@*****.**"

    nurse = User()
    nurse.surname = "Ilusa"
    nurse.name = "Mary"
    nurse.age = 24
    nurse.position = "colonist"
    nurse.speciality = "nurse"
    nurse.address = "module_4"
    nurse.email = "*****@*****.**"

    engineer = User()
    engineer.surname = "Shelly"
    engineer.name = "Smith"
    engineer.age = 36
    engineer.position = "colonist"
    engineer.speciality = "engineer"
    engineer.address = "module_2"
    engineer.email = "*****@*****.**"

    cooker = User()
    cooker.surname = "Hanks"
    cooker.name = "Tom"
    cooker.age = 30
    cooker.position = "colonist"
    cooker.speciality = "cooker"
    cooker.address = "module_8"
    cooker.email = "*****@*****.**"

    db_sess = db_session.create_session()
    db_sess.add(captain)
    db_sess.add(nurse)
    db_sess.add(engineer)
    db_sess.add(cooker)
    db_sess.commit()