Exemplo n.º 1
0
def return_one_day_by_week(week, day_of_week, group):
    try:
        cursor = connect_to_sqlite()
        if (week % 2):
            current_week = 1
        else:
            current_week = 2
        sqlite_select_Query = "SELECT schedule_calls.call_id, lessons.call_time, discipline_name, lesson_types.lesson_type_name, room_num, teacher_name  \
                            FROM lessons\
                            Join disciplines ON discipline_id = discipline\
                            Join schedule_calls ON call_id = call_num\
                            Join rooms On room_id = room\
                            JOIN teachers On teacher = teacher_id\
                            JOIN groups on group_id = group_num\
                            JOIN lesson_types on lesson_type_id = lesson_type\
                            WHERE groups.group_name = :group AND day = :day AND week = :week \
                            order by schedule_calls.call_id"

        cursor.execute(sqlite_select_Query, {
            'group': group,
            'day': day_of_week,
            'week': current_week
        })
        record = cursor.fetchall()
        cursor.close()
        return format_lesson(record, day_of_week, week)
    except:
        print("No database")
        return None
Exemplo n.º 2
0
def return_one_day(today, group):
    week = cur_week(today)
    cursor = connect_to_sqlite()
    day_of_week = today.isocalendar()[2]
    if(day_of_week==7):
        return ""
    if (week%2):
        current_week = 1
    else:
        current_week = 2
    sqlite_select_Query = "SELECT schedule_calls.call_id, lessons.call_time, discipline_name, room_num, teacher_name  \
                        FROM lessons\
                        Join disciplines ON discipline_id = discipline\
                        Join schedule_calls ON call_id = call_num\
                        Join rooms On room_id = room\
                        JOIN teachers On teacher = teacher_id\
                        JOIN groups on group_id = group_num\
                        WHERE groups.group_name = :group AND day = :day AND week = :week \
                        order by schedule_calls.call_id"
    cursor.execute(sqlite_select_Query, {'group':group, 'day':day_of_week, 'week':current_week})
    record = cursor.fetchall()
    cursor.close()
    if len(record):
        return format_lesson(record, day_of_week, week, today)
    return '\n' + days_of_week[day_of_week] + " " + str(today.day) + "." + str(today.month) + "\nНет пар\n" + "="*30
Exemplo n.º 3
0
def for_cache():
    try:
        cursor = connect_to_sqlite()
        sqlite_select_Query = "SELECT group_name FROM groups where group_name like 'И%';"
        cursor.execute(sqlite_select_Query)
        record = cursor.fetchall()
        cursor.close()
        res = {}

        for group in record:
            group = group[0]
            print(group)
            res[group] = full_sched(group)

        return res
    except:
        print("No database")
        return None
Exemplo n.º 4
0
def get_groups():
    courses = {1: "first", 2: "second", 3: "third", 4: "fourth"}
    try:
        res = {
            "bachelor": {
                "first": [],
                "second": [],
                "third": [],
                "fourth": []
            },
            "master": {
                "first": [],
                "second": []
            }
        }
        cursor = connect_to_sqlite()
        sqlite_select_Query = "SELECT group_name FROM groups where group_name like 'И%';"
        cursor.execute(sqlite_select_Query)
        record = cursor.fetchall()
        cursor.close()
        m = []
        b = []
        a = []
        m_courses = {}
        b_courses = {}
        max_year = 0
        for group in record:
            group = group[0]
            max_year = max(max_year, int(group[-2] + group[-1]))

        for group in record:
            group = group[0]

            if group[2] == "М":
                course = max_year - int(group[-2] + group[-1]) + 1
                ind = -1
                for i in range(len(res["master"][courses[course]])):
                    if res["master"][courses[course]][i]["name"] == group[:4]:
                        ind = i
                if ind != -1:
                    #res["master"][courses[course]][i]["numbers"].append({"number" : int(group[5:7]), "group": group})
                    res["master"][courses[course]][i]["numbers"].append(group)
                else:
                    #res["master"][courses[course]].append({"name": group[:4], "numbers":[{"number" : int(group[5:7]), "group": group}]})
                    res["master"][courses[course]].append({
                        "name": group[:4],
                        "numbers": [group]
                    })

            elif group[2] == "Б":
                course = max_year - int(group[-2] + group[-1]) + 1
                ind = -1
                for i in range(len(res["bachelor"][courses[course]])):
                    if res["bachelor"][
                            courses[course]][i]["name"] == group[:4]:
                        ind = i
                if ind != -1:
                    res["bachelor"][courses[course]][i]["numbers"].append(
                        group)
                    #res["bachelor"][courses[course]][i]["numbers"].append({"number" : int(group[5:7]), "group": group})
                else:
                    res["bachelor"][courses[course]].append({
                        "name": group[:4],
                        "numbers": [group]
                    })
                    #res["bachelor"][courses[course]].append({"name": group[:4], "numbers":[{"number" : int(group[5:7]), "group": group}]})

            else:
                a.append(group)
        return res
    except:
        print("No database")
        return None