Beispiel #1
0
def get_data_from_db():
    data = db.select_users()
    global user_dict
    user_dict = {
        user[0]: {
            'first_name': user[1],
            'last_name': user[2],
            'current_group': user[3]
        }
        for user in data
    }
Beispiel #2
0
def distribute_all(**kwargs):
    if 'id' in kwargs and 'text' in kwargs:
        ids = db.select_users()
        #print('Рассылка всем пользователям')
        for user_id in ids:
            #print(user_id[0])
            bot.send_message(user_id[0], kwargs['text'])
        bot2.send_message(kwargs['id'], 'Сообщение разослано')
        global state
        state = 0
        menu(id=kwargs['id'])
Beispiel #3
0
def registration(id, nickname):
    c = db.connect()
    users = db.select_users(c)
    check = False
    for user in users:
        if user['id_user'] == id:
            check = True
    if check == False:
        db.add_user(c, id, nickname)
        bot.send_message(id,
                         'You register ' + nickname,
                         reply_markup=kb.main_menu())
    else:
        bot.send_message(id, 'Hello ' + nickname, reply_markup=kb.main_menu())
Beispiel #4
0
def adminUser():
    if request.method=='GET':
        data=db.select_users()
        return render_template('admin/users.html',data=data)

    if request.method=='POST':
        userType=request.form['type']
        fname=request.form['fname']
        print(str(fname))
        print(type(fname))
        lname=request.form['lname']
        print(str(lname))
        print(type(lname))
        email=request.form['email']
        print(str(email))
        print(type(email))
        dob=request.form['dob']
        print(str(dob))
        print(type(dob))
        address=request.form['address']
        print(str(address))
        print(type(address))
        phone=request.form['phone']
        print(str(phone))
        print(type(phone))
        nationality=request.form['nationality']
        print(str(nationality))
        print(type(fname))
        sex=request.form['sex']
        print(str(sex))
        print(type(sex))

        if userType=="student":
            major=request.form['major']
            gpa=request.form['gpa']
            print(str(gpa))
            print(type(gpa))
            advisor=request.form['advisor']
            db.insert_student(fname,lname,email,dob,address,phone,nationality,sex,major,gpa,advisor)

        if userType=="advisor":
            department=request.form['department']
            db.insert_advisor(fname,lname,email,dob,address,phone,nationality,sex,department)

        if userType=="admin":
            db.insert_admin(fname,lname,email,dob,address,phone,nationality,sex)

        return redirect('adminUsers')
Beispiel #5
0
def admin_userlist_message(message):
    if isAdmin(str(message.from_user.id)):
        users= select_users()
        for u in users:
            bot.send_message(message.chat.id, '{} {} {} {} {}'.format(u['id'],u['username'],u['fio'],u['role'],u['messanger']))