|
4 | 4 | from pprint import pprint |
5 | 5 |
|
6 | 6 | from fet_api_to_gcal import db |
7 | | -from fet_api_to_gcal.common.utils import getDate, perror, psuccess |
| 7 | +from fet_api_to_gcal.common.utils import getDate, perror, psuccess, path_leaf |
8 | 8 | from fet_api_to_gcal.models import Calendar, Resource, Std_mail, Teacher |
9 | 9 |
|
10 | 10 |
|
|
22 | 22 | } |
23 | 23 |
|
24 | 24 |
|
25 | | -def check_teachers(teacher_file): |
26 | | - """Checks that all teachers from the FET timetable are present in the database |
27 | | - |
28 | | - Args: |
29 | | - teacher_file (str, required): path to a FET generated csv file for teachers. |
30 | | - |
31 | | - Returns: |
32 | | - dict: a dictionary with two keys, one for the operation status |
33 | | - and one for missing teachers when status is False else returns None |
34 | | - """ |
35 | | - not_found = [] |
36 | | - |
37 | | - with open(teacher_file, "r") as teachers_f: |
38 | | - teachers = teachers_f.readlines() |
39 | | - total_teachers, i = len(teachers[1:]), 0 |
40 | | - for teacher_name in teachers[1:]: |
41 | | - teacher_name = teacher_name.replace('"', '').strip() |
42 | | - teacher_obj = Teacher.query.filter_by( |
43 | | - fet_name=teacher_name).first() |
44 | | - if teacher_obj is None: |
45 | | - not_found.append(teacher_name) |
46 | | - |
47 | | - if len(not_found) != 0: |
48 | | - return {"status": False, "missing_teachers": not_found} |
49 | | - else: |
50 | | - return {"status": True, "missing_teachers": None} |
51 | | - |
52 | | - |
53 | 25 | def check_timetable_validity(timetable_path, |
54 | 26 | dates, |
55 | 27 | events_freq=1, |
|
0 commit comments