예제 #1
0
async def send_qr(request):
    req_data = await get_request(request)
    if req_data["string"] in QR:
        lector_id = LECTORS[0].get_id()
        pair_id = LECTORS[0].get_current_pair()
        student_ = NSTUAPI().get_student_info(
            req_data["token"],
        )[1]
        student = Postgres.select(table="student", where="student_info='{}'".format(student_['FIO']))[0]
        # group_ = Postgres.select(
        #     table="group_students",
        #     where="student_id='{}'".format(student['student_id']))[0]
        
        # group = Postgres.select(table="groups", where="group_id='{}'".format(group_["group_id"]))[0]
        # Postgres.insert(table="current_pars", [lector_id, pair_id, student["student_info"]])
        print(lector_id, pair_id, student["student_info"], student['student_id'])
        Postgres.insert(table="pairs", values=[lector_id, pair_id, student['student_id']])

        return get_response()
예제 #2
0
    def __init__(self, name, token):
        self.i_name = name

        if not Postgres.select(table="student",
                               where="student_info='{}'".format(self.i_name)):
            student_id = Postgres.select(table="student",
                                         columns="max(student_id)")[0]["max"]
            if student_id:
                student_id = int(student_id) + 1
            else:
                student_id = 1

            info = NSTUAPI().get_student_info(token)[1]
            Postgres.insert(table="student", values=[student_id, info["FIO"]])

            if not Postgres.select(table="groups",
                                   where="group_info='{}'".format(
                                       info["group"])):
                group_id = Postgres.select(table="groups",
                                           columns="max(group_id)")[0]["max"]
                if group_id:
                    group_id = int(group_id) + 1
                else:
                    group_id = 1

                Postgres.insert(table="groups",
                                values=[group_id, info["group"]])
                Postgres.insert(table="group_students",
                                values=[group_id, student_id])