forked from ScoDoc/DocScoDoc
API: ajout session_id au formsemestre. formsemestre/programme
This commit is contained in:
parent
443eb72687
commit
b740f40389
@ -4,14 +4,11 @@ from flask import jsonify
|
||||
import app
|
||||
from app import models
|
||||
from app.api import bp
|
||||
from app.api.errors import error_response
|
||||
from app.api.auth import token_auth, token_permission_required
|
||||
from app.api.tools import get_etu_from_etudid_or_nip_or_ine
|
||||
from app.models import FormSemestre, FormSemestreEtape
|
||||
from app.models import Departement, FormSemestre, FormSemestreEtape
|
||||
from app.scodoc.sco_bulletins import get_formsemestre_bulletin_etud_json
|
||||
from app.scodoc.sco_bulletins_json import make_json_formsemestre_bulletinetud
|
||||
from app.scodoc.sco_permissions import Permission
|
||||
from app.scodoc.sco_pvjury import formsemestre_pvjury
|
||||
from app.scodoc.sco_utils import ModuleType
|
||||
|
||||
|
||||
@bp.route("/formsemestre/<int:formsemestre_id>", methods=["GET"])
|
||||
@ -53,10 +50,15 @@ def formsemestre(formsemestre_id: int):
|
||||
}
|
||||
|
||||
"""
|
||||
formsemestre = models.FormSemestre.query.filter_by(
|
||||
formsemestre: FormSemestre = models.FormSemestre.query.filter_by(
|
||||
id=formsemestre_id
|
||||
).first_or_404()
|
||||
data = formsemestre.to_dict()
|
||||
# Pour le moment on a besoin de fixer le departement
|
||||
# pour accéder aux préferences
|
||||
dept = Departement.query.get(formsemestre.dept_id)
|
||||
app.set_sco_dept(dept.acronym)
|
||||
data["session_id"] = formsemestre.session_id()
|
||||
return jsonify(data)
|
||||
|
||||
|
||||
@ -71,32 +73,7 @@ def formsemestre_apo(etape_apo: str):
|
||||
|
||||
Exemple de résultat :
|
||||
[
|
||||
{
|
||||
"date_fin": "31/08/2022",
|
||||
"resp_can_edit": false,
|
||||
"dept_id": 1,
|
||||
"etat": true,
|
||||
"resp_can_change_ens": true,
|
||||
"id": 1,
|
||||
"modalite": "FI",
|
||||
"ens_can_edit_eval": false,
|
||||
"formation_id": 1,
|
||||
"gestion_compensation": false,
|
||||
"elt_sem_apo": null,
|
||||
"semestre_id": 1,
|
||||
"bul_hide_xml": false,
|
||||
"elt_annee_apo": null,
|
||||
"titre": "Semestre test",
|
||||
"block_moyennes": false,
|
||||
"scodoc7_id": null,
|
||||
"date_debut": "01/09/2021",
|
||||
"gestion_semestrielle": false,
|
||||
"bul_bgcolor": "white",
|
||||
"formsemestre_id": 1,
|
||||
"titre_num": "Semestre test semestre 1",
|
||||
"date_debut_iso": "2021-09-01",
|
||||
"date_fin_iso": "2022-08-31",
|
||||
"responsables": []
|
||||
{ ...formsemestre...
|
||||
}, ...
|
||||
]
|
||||
"""
|
||||
@ -341,114 +318,112 @@ def bulletins(formsemestre_id: int):
|
||||
# return jsonify(data)
|
||||
|
||||
|
||||
# XXX A spécifier et compléter TODO
|
||||
# @bp.route(
|
||||
# "/formsemestre/<int:formsemestre_id>/programme",
|
||||
# methods=["GET"],
|
||||
# )
|
||||
# @token_auth.login_required
|
||||
# @token_permission_required(Permission.APIView)
|
||||
# def semestre_index(formsemestre_id: int): # XXX nom bizarre ??
|
||||
# """
|
||||
# Retourne la liste des Ues, ressources et SAE d'un semestre
|
||||
@bp.route(
|
||||
"/formsemestre/<int:formsemestre_id>/programme",
|
||||
methods=["GET"],
|
||||
)
|
||||
@token_auth.login_required
|
||||
@token_permission_required(Permission.APIView)
|
||||
def formsemestre_programme(formsemestre_id: int): # XXX nom bizarre ??
|
||||
"""
|
||||
Retourne la liste des Ues, ressources et SAE d'un semestre
|
||||
|
||||
# formsemestre_id : l'id d'un formsemestre
|
||||
formsemestre_id : l'id d'un formsemestre
|
||||
|
||||
# Exemple de résultat :
|
||||
# {
|
||||
# "ues": [
|
||||
# {
|
||||
# "type": 0,
|
||||
# "formation_id": 1,
|
||||
# "ue_code": "UCOD11",
|
||||
# "id": 1,
|
||||
# "ects": 12.0,
|
||||
# "acronyme": "RT1.1",
|
||||
# "is_external": false,
|
||||
# "numero": 1,
|
||||
# "code_apogee": "",
|
||||
# "titre": "Administrer les r\u00e9seaux et l\u2019Internet",
|
||||
# "coefficient": 0.0,
|
||||
# "semestre_idx": 1,
|
||||
# "color": "#B80004",
|
||||
# "ue_id": 1
|
||||
# },
|
||||
# ...
|
||||
# ],
|
||||
# "ressources": [
|
||||
# {
|
||||
# "titre": "Fondamentaux de la programmation",
|
||||
# "coefficient": 1.0,
|
||||
# "module_type": 2,
|
||||
# "id": 17,
|
||||
# "ects": null,
|
||||
# "abbrev": null,
|
||||
# "ue_id": 3,
|
||||
# "code": "R107",
|
||||
# "formation_id": 1,
|
||||
# "heures_cours": 0.0,
|
||||
# "matiere_id": 3,
|
||||
# "heures_td": 0.0,
|
||||
# "semestre_id": 1,
|
||||
# "heures_tp": 0.0,
|
||||
# "numero": 70,
|
||||
# "code_apogee": "",
|
||||
# "module_id": 17
|
||||
# },
|
||||
# ...
|
||||
# ],
|
||||
# "saes": [
|
||||
# {
|
||||
# "titre": "Se pr\u00e9senter sur Internet",
|
||||
# "coefficient": 1.0,
|
||||
# "module_type": 3,
|
||||
# "id": 14,
|
||||
# "ects": null,
|
||||
# "abbrev": null,
|
||||
# "ue_id": 3,
|
||||
# "code": "SAE14",
|
||||
# "formation_id": 1,
|
||||
# "heures_cours": 0.0,
|
||||
# "matiere_id": 3,
|
||||
# "heures_td": 0.0,
|
||||
# "semestre_id": 1,
|
||||
# "heures_tp": 0.0,
|
||||
# "numero": 40,
|
||||
# "code_apogee": "",
|
||||
# "module_id": 14
|
||||
# },
|
||||
# ...
|
||||
# ]
|
||||
# }
|
||||
# """
|
||||
Exemple de résultat :
|
||||
{
|
||||
"ues": [
|
||||
{
|
||||
"type": 0,
|
||||
"formation_id": 1,
|
||||
"ue_code": "UCOD11",
|
||||
"id": 1,
|
||||
"ects": 12.0,
|
||||
"acronyme": "RT1.1",
|
||||
"is_external": false,
|
||||
"numero": 1,
|
||||
"code_apogee": "",
|
||||
"titre": "Administrer les r\u00e9seaux et l\u2019Internet",
|
||||
"coefficient": 0.0,
|
||||
"semestre_idx": 1,
|
||||
"color": "#B80004",
|
||||
"ue_id": 1
|
||||
},
|
||||
...
|
||||
],
|
||||
"ressources": [
|
||||
{
|
||||
"titre": "Fondamentaux de la programmation",
|
||||
"coefficient": 1.0,
|
||||
"module_type": 2,
|
||||
"id": 17,
|
||||
"ects": null,
|
||||
"abbrev": null,
|
||||
"ue_id": 3,
|
||||
"code": "R107",
|
||||
"formation_id": 1,
|
||||
"heures_cours": 0.0,
|
||||
"matiere_id": 3,
|
||||
"heures_td": 0.0,
|
||||
"semestre_id": 1,
|
||||
"heures_tp": 0.0,
|
||||
"numero": 70,
|
||||
"code_apogee": "",
|
||||
"module_id": 17
|
||||
},
|
||||
...
|
||||
],
|
||||
"saes": [
|
||||
{
|
||||
"titre": "Se pr\u00e9senter sur Internet",
|
||||
"coefficient": 1.0,
|
||||
"module_type": 3,
|
||||
"id": 14,
|
||||
"ects": null,
|
||||
"abbrev": null,
|
||||
"ue_id": 3,
|
||||
"code": "SAE14",
|
||||
"formation_id": 1,
|
||||
"heures_cours": 0.0,
|
||||
"matiere_id": 3,
|
||||
"heures_td": 0.0,
|
||||
"semestre_id": 1,
|
||||
"heures_tp": 0.0,
|
||||
"numero": 40,
|
||||
"code_apogee": "",
|
||||
"module_id": 14
|
||||
},
|
||||
...
|
||||
],
|
||||
"modules" : [ ... les modules qui ne sont niu des SAEs ni des ressources ... ]
|
||||
}
|
||||
"""
|
||||
formsemestre: FormSemestre = models.FormSemestre.query.filter_by(
|
||||
id=formsemestre_id
|
||||
).first_or_404()
|
||||
|
||||
# formsemestre: FormSemestre = models.FormSemestre.query.filter_by(
|
||||
# id=formsemestre_id
|
||||
# ).first_or_404()
|
||||
ues = formsemestre.query_ues()
|
||||
ressources = [
|
||||
modimpl.module
|
||||
for modimpl in formsemestre.modimpls_sorted
|
||||
if modimpl.module.module_type == ModuleType.RESSOURCE
|
||||
]
|
||||
saes = [
|
||||
modimpl.module
|
||||
for modimpl in formsemestre.modimpls_sorted
|
||||
if modimpl.module.module_type == ModuleType.SAE
|
||||
]
|
||||
modules = [
|
||||
modimpl.module
|
||||
for modimpl in formsemestre.modimpls_sorted
|
||||
if modimpl.module.module_type == ModuleType.STANDARD
|
||||
]
|
||||
|
||||
# ues = formsemestre.query_ues()
|
||||
data = {
|
||||
"ues": [ue.to_dict() for ue in ues],
|
||||
"ressources": [m.to_dict() for m in ressources],
|
||||
"saes": [m.to_dict() for m in saes],
|
||||
"modules": [m.to_dict() for m in modules],
|
||||
}
|
||||
|
||||
# ues_dict = []
|
||||
# ressources = []
|
||||
# saes = []
|
||||
|
||||
# for ue in ues:
|
||||
# ues_dict.append(ue.to_dict())
|
||||
# ressources = ue.get_ressources()
|
||||
# saes = ue.get_saes()
|
||||
|
||||
# data_ressources = []
|
||||
# for ressource in ressources:
|
||||
# data_ressources.append(ressource.to_dict())
|
||||
|
||||
# data_saes = []
|
||||
# for sae in saes:
|
||||
# data_saes.append(sae.to_dict())
|
||||
|
||||
# data = {
|
||||
# "ues": ues_dict,
|
||||
# "ressources": data_ressources,
|
||||
# "saes": data_saes,
|
||||
# }
|
||||
|
||||
# return data
|
||||
return jsonify(data)
|
||||
|
Loading…
Reference in New Issue
Block a user