Ejemplo n.º 1
0
def update_user_by_chat_id(chat_id, first_name, last_name, username):
    """
        Обновление информации о пользователе
    """
    try:
        us = User.objects.get(chat_id=chat_id)
    except DoesNotExist:
        us = User(chat_id=chat_id)
    us.first_name = first_name
    us.last_name = last_name
    us.username = username

    try:
        us.save()
    except Exception:
        pass
Ejemplo n.º 2
0
def build_sample_db():
    db.create_all()
    db.drop_all()
    db.create_all()
    user = User()
    user.first_name = 'admin'
    user.last_name = 'admin'
    user.login = '******'
    user.email = user.login + "@example.com"
    user.password = generate_password_hash('admin')
    db.session.add(user)
    db.session.add(RequestType(type='User'))
    db.session.add(RequestType(type='Bot'))
    db.session.add(Technique(name='chi_square'))
    db.session.add(Technique(name='Kolmogorov-Smirnov'))
    db.session.commit()