forked from ScoDoc/ScoDoc
Compare commits
2 Commits
e74d075bda
...
b5e4017315
Author | SHA1 | Date | |
---|---|---|---|
|
b5e4017315 | ||
|
09ff7f5d5d |
@ -117,34 +117,32 @@ def liste_semestres_courant(dept: str):
|
|||||||
Exemple de résultat :
|
Exemple de résultat :
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"titre": "master machine info",
|
"date_fin": "31/08/2022",
|
||||||
"gestion_semestrielle": false,
|
"resp_can_edit": false,
|
||||||
"scodoc7_id": null,
|
"dept_id": 1,
|
||||||
"date_debut": "01/09/2021",
|
"etat": true,
|
||||||
"bul_bgcolor": null,
|
"resp_can_change_ens": true,
|
||||||
"date_fin": "15/12/2022",
|
"id": 1,
|
||||||
"resp_can_edit": false,
|
"modalite": "FI",
|
||||||
"dept_id": 1,
|
"ens_can_edit_eval": false,
|
||||||
"etat": true,
|
"formation_id": 1,
|
||||||
"resp_can_change_ens": false,
|
"gestion_compensation": false,
|
||||||
"id": 1,
|
"elt_sem_apo": null,
|
||||||
"modalite": "FI",
|
"semestre_id": 1,
|
||||||
"ens_can_edit_eval": false,
|
"bul_hide_xml": false,
|
||||||
"formation_id": 1,
|
"elt_annee_apo": null,
|
||||||
"gestion_compensation": false,
|
"titre": "Semestre test",
|
||||||
"elt_sem_apo": null,
|
"block_moyennes": false,
|
||||||
"semestre_id": 1,
|
"scodoc7_id": null,
|
||||||
"bul_hide_xml": false,
|
"date_debut": "01/09/2021",
|
||||||
"elt_annee_apo": null,
|
"gestion_semestrielle": false,
|
||||||
"block_moyennes": false,
|
"bul_bgcolor": "white",
|
||||||
"formsemestre_id": 1,
|
"formsemestre_id": 1,
|
||||||
"titre_num": "master machine info semestre 1",
|
"titre_num": "Semestre test semestre 1",
|
||||||
"date_debut_iso": "2021-09-01",
|
"date_debut_iso": "2021-09-01",
|
||||||
"date_fin_iso": "2022-12-15",
|
"date_fin_iso": "2022-08-31",
|
||||||
"responsables": [
|
"responsables": []
|
||||||
3,
|
"titre_court": BUT MMI
|
||||||
2
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
@ -156,7 +154,7 @@ def liste_semestres_courant(dept: str):
|
|||||||
semestres = models.FormSemestre.query.filter_by(dept_id=dept.id, etat=True)
|
semestres = models.FormSemestre.query.filter_by(dept_id=dept.id, etat=True)
|
||||||
|
|
||||||
# Mise en forme des données
|
# Mise en forme des données
|
||||||
data = [d.to_dict() for d in semestres]
|
data = [d.to_dict_api() for d in semestres]
|
||||||
|
|
||||||
return jsonify(data)
|
return jsonify(data)
|
||||||
|
|
||||||
|
@ -144,6 +144,7 @@ def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None)
|
|||||||
"date_debut_iso": "2021-09-01",
|
"date_debut_iso": "2021-09-01",
|
||||||
"date_fin_iso": "2022-08-31",
|
"date_fin_iso": "2022-08-31",
|
||||||
"responsables": []
|
"responsables": []
|
||||||
|
"titre_court": BUT MMI
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
@ -156,7 +157,7 @@ def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None)
|
|||||||
models.FormSemestreInscription.formsemestre_id == models.FormSemestre.id,
|
models.FormSemestreInscription.formsemestre_id == models.FormSemestre.id,
|
||||||
).order_by(models.FormSemestre.date_debut)
|
).order_by(models.FormSemestre.date_debut)
|
||||||
|
|
||||||
return jsonify([formsemestre.to_dict() for formsemestre in formsemestres])
|
return jsonify([formsemestre.to_dict_api() for formsemestre in formsemestres])
|
||||||
|
|
||||||
|
|
||||||
@bp.route(
|
@bp.route(
|
||||||
|
@ -56,7 +56,7 @@ def formsemestre(formsemestre_id: int):
|
|||||||
formsemetre = models.FormSemestre.query.filter_by(id=formsemestre_id).first_or_404()
|
formsemetre = models.FormSemestre.query.filter_by(id=formsemestre_id).first_or_404()
|
||||||
|
|
||||||
# Mise en forme des données
|
# Mise en forme des données
|
||||||
data = formsemetre.to_dict()
|
data = formsemetre.to_dict_api()
|
||||||
|
|
||||||
return jsonify(data)
|
return jsonify(data)
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ def formsemestre_apo(etape_apo: str):
|
|||||||
FormSemestreEtape.formsemestre_id == FormSemestre.id,
|
FormSemestreEtape.formsemestre_id == FormSemestre.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
return jsonify([formsemestre.to_dict() for formsemestre in formsemestres])
|
return jsonify([formsemestre.to_dict_api() for formsemestre in formsemestres])
|
||||||
|
|
||||||
|
|
||||||
@bp.route(
|
@bp.route(
|
||||||
|
@ -141,6 +141,28 @@ class FormSemestre(db.Model):
|
|||||||
d["responsables"] = [u.id for u in self.responsables]
|
d["responsables"] = [u.id for u in self.responsables]
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def to_dict_api(self):
|
||||||
|
"""
|
||||||
|
Un dict avec les informations sur le semestre destiné à l'api
|
||||||
|
"""
|
||||||
|
d = dict(self.__dict__)
|
||||||
|
d.pop("_sa_instance_state", None)
|
||||||
|
d["formsemestre_id"] = self.id
|
||||||
|
d["titre_num"] = self.titre_num()
|
||||||
|
if self.date_debut:
|
||||||
|
d["date_debut"] = self.date_debut.strftime("%d/%m/%Y")
|
||||||
|
d["date_debut_iso"] = self.date_debut.isoformat()
|
||||||
|
else:
|
||||||
|
d["date_debut"] = d["date_debut_iso"] = ""
|
||||||
|
if self.date_fin:
|
||||||
|
d["date_fin"] = self.date_fin.strftime("%d/%m/%Y")
|
||||||
|
d["date_fin_iso"] = self.date_fin.isoformat()
|
||||||
|
else:
|
||||||
|
d["date_fin"] = d["date_fin_iso"] = ""
|
||||||
|
d["responsables"] = [u.id for u in self.responsables]
|
||||||
|
d["titre_court"] = self.formation.acronyme
|
||||||
|
return d
|
||||||
|
|
||||||
def get_infos_dict(self) -> dict:
|
def get_infos_dict(self) -> dict:
|
||||||
"""Un dict avec des informations sur le semestre
|
"""Un dict avec des informations sur le semestre
|
||||||
pour les bulletins et autres templates
|
pour les bulletins et autres templates
|
||||||
@ -373,6 +395,7 @@ class FormSemestre(db.Model):
|
|||||||
if self.semestre_id == sco_codes_parcours.NO_SEMESTRE_ID:
|
if self.semestre_id == sco_codes_parcours.NO_SEMESTRE_ID:
|
||||||
return self.titre
|
return self.titre
|
||||||
return f"{self.titre} {self.formation.get_parcours().SESSION_NAME} {self.semestre_id}"
|
return f"{self.titre} {self.formation.get_parcours().SESSION_NAME} {self.semestre_id}"
|
||||||
|
# return f"{self.formation.acronyme} S{self.semestre_id}"
|
||||||
|
|
||||||
def sem_modalite(self) -> str:
|
def sem_modalite(self) -> str:
|
||||||
"""Le semestre et la modalité, ex "S2 FI" ou "S3 APP" """
|
"""Le semestre et la modalité, ex "S2 FI" ou "S3 APP" """
|
||||||
|
@ -19,62 +19,98 @@ Utilisation :
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
|
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
|
||||||
|
from tests.api.tools_test_api import verify_fields
|
||||||
|
|
||||||
|
|
||||||
# absences
|
# absences
|
||||||
def test_absences():
|
def test_absences():
|
||||||
r = requests.get(
|
|
||||||
SCODOC_URL + "/ScoDoc/api/absences/etudid/<int:etudid>",
|
fields = ["jour", "matin", "estabs", "estjust", "description", "begin", "end"]
|
||||||
headers=HEADERS,
|
|
||||||
verify=CHECK_CERTIFICATE,
|
|
||||||
)
|
|
||||||
assert r.status_code == 200
|
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/absences/nip/<int:nip>",
|
SCODOC_URL + "/ScoDoc/api/absences/etudid/1",
|
||||||
headers=HEADERS,
|
headers=HEADERS,
|
||||||
verify=CHECK_CERTIFICATE,
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
abs = r.json()[0]
|
||||||
|
|
||||||
|
fields_OK = verify_fields(abs, fields)
|
||||||
|
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
|
assert fields_OK is True
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/absences/ine/<int:ine>",
|
SCODOC_URL + "/ScoDoc/api/absences/nip/1",
|
||||||
headers=HEADERS,
|
headers=HEADERS,
|
||||||
verify=CHECK_CERTIFICATE,
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
abs = r.json()[0]
|
||||||
|
|
||||||
|
fields_OK = verify_fields(abs, fields)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
|
assert fields_OK is True
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/ine/1",
|
||||||
|
headers=HEADERS,
|
||||||
|
verify=CHECK_CERTIFICATE,
|
||||||
|
)
|
||||||
|
|
||||||
|
abs = r.json()[0]
|
||||||
|
|
||||||
|
fields_OK = verify_fields(abs, fields)
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert fields_OK is True
|
||||||
|
|
||||||
|
|
||||||
# absences_justify
|
# absences_justify
|
||||||
def test_absences_justify():
|
def test_absences_justify():
|
||||||
|
fields = ["jour", "matin", "estabs", "estjust", "description", "begin", "end"]
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/absences/etudid/1/just",
|
SCODOC_URL + "/ScoDoc/api/absences/etudid/1/just",
|
||||||
headers=HEADERS,
|
headers=HEADERS,
|
||||||
verify=CHECK_CERTIFICATE,
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
abs = r.json()[0]
|
||||||
|
|
||||||
|
fields_OK = verify_fields(abs, fields)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
|
assert fields_OK is True
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/absences/nip/1/just",
|
SCODOC_URL + "/ScoDoc/api/absences/nip/1/just",
|
||||||
headers=HEADERS,
|
headers=HEADERS,
|
||||||
verify=CHECK_CERTIFICATE,
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
abs = r.json()[0]
|
||||||
|
|
||||||
|
fields_OK = verify_fields(abs, fields)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
|
assert fields_OK is True
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/absences/ine/1/just",
|
SCODOC_URL + "/ScoDoc/api/absences/ine/1/just",
|
||||||
headers=HEADERS,
|
headers=HEADERS,
|
||||||
verify=CHECK_CERTIFICATE,
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
abs = r.json()[0]
|
||||||
|
|
||||||
|
fields_OK = verify_fields(abs, fields)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
|
assert fields_OK is True
|
||||||
|
|
||||||
|
|
||||||
# abs_groupe_etat
|
# abs_groupe_etat
|
||||||
def test_abs_groupe_etat():
|
# def test_abs_groupe_etat():
|
||||||
r = requests.get(
|
# r = requests.get(
|
||||||
SCODOC_URL
|
# SCODOC_URL
|
||||||
+ "/ScoDoc/api/absences/abs_group_etat/?group_id=<int:group_id>&date_debut=date_debut&date_fin=date_fin",
|
# + "/ScoDoc/api/absences/abs_group_etat/?group_id=<int:group_id>&date_debut=date_debut&date_fin=date_fin",
|
||||||
headers=HEADERS,
|
# headers=HEADERS,
|
||||||
verify=CHECK_CERTIFICATE,
|
# verify=CHECK_CERTIFICATE,
|
||||||
)
|
# )
|
||||||
assert r.status_code == 200
|
# assert r.status_code == 200
|
||||||
|
@ -20,15 +20,45 @@ Utilisation :
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
|
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
|
||||||
|
from tests.api.tools_test_api import verify_fields
|
||||||
|
|
||||||
|
|
||||||
# evaluations
|
# evaluations
|
||||||
def test_evaluations():
|
def test_evaluations():
|
||||||
|
fields = [
|
||||||
|
"moduleimpl_id",
|
||||||
|
"jour",
|
||||||
|
"heure_debut",
|
||||||
|
"description",
|
||||||
|
"coefficient",
|
||||||
|
"publish_incomplete",
|
||||||
|
"numero",
|
||||||
|
"id",
|
||||||
|
"heure_fin",
|
||||||
|
"note_max",
|
||||||
|
"visibulletin",
|
||||||
|
"evaluation_type",
|
||||||
|
"evaluation_id",
|
||||||
|
"jouriso",
|
||||||
|
"duree",
|
||||||
|
"descrheure",
|
||||||
|
"matin",
|
||||||
|
"apresmidi",
|
||||||
|
]
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/evaluations/1",
|
SCODOC_URL + "/ScoDoc/api/evaluations/1",
|
||||||
headers=HEADERS,
|
headers=HEADERS,
|
||||||
verify=CHECK_CERTIFICATE,
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
eval = r.json()[0]
|
||||||
|
|
||||||
|
fields_OK = verify_fields(eval, fields)
|
||||||
|
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
|
# assert len(r.json()) == 1
|
||||||
|
assert fields_OK is True
|
||||||
|
|
||||||
|
|
||||||
# evaluation_notes
|
# evaluation_notes
|
||||||
|
Loading…
Reference in New Issue
Block a user