-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubunitys.py
29 lines (22 loc) · 963 Bytes
/
subunitys.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from ufma_scrapper import subunidade as subunity
from models import Subunidade, Docente
def saveSubunitysAndTeachers():
subunidades = subunity.get_subunidades()
for subunidade in subunidades:
subunidade = Subunidade(codigo=subunidade["codigo"],
nome=subunidade["nome"]
)
try:
subunidade.save()
except Exception as error:
print("Erro ao persistir os dados de subunidade: ", error)
docentes = subunity.get_docentes(subunidade.id)
for docente in docentes:
docente = Docente(siape=docente["siape"],
nome=docente["nome"],
subunidade=docente["codigo_subunidade"]
)
try:
docente.save()
except Exception as error:
print("Erro ao persistir os dados de docente: ", error)