diff --git a/app/api/absences.py b/app/api/absences.py index 35abe34ff..35056a05b 100644 --- a/app/api/absences.py +++ b/app/api/absences.py @@ -93,7 +93,7 @@ def absences_just(etudid: int = None, nip: int = None, ine: int = None): "jour": "Fri, 15 Apr 2022 00:00:00 GMT", "matin": false, "estabs": true, - "estjust": false, + "estjust": true, "description": "", "begin": "2022-04-15 12:00:00", "end": "2022-04-15 17:59:59" @@ -120,7 +120,11 @@ def absences_just(etudid: int = None, nip: int = None, ine: int = None): @bp.route( - "/absences/abs_group_etat/?group_id=&date_debut=date_debut&date_fin=date_fin", + "/absences/abs_group_etat/", + methods=["GET"], +) +@bp.route( + "/absences/abs_group_etat/group_id//date_debut//date_fin/", methods=["GET"], ) @token_permission_required(Permission.APIView) diff --git a/app/api/departements.py b/app/api/departements.py index 924d1e441..482bceca6 100644 --- a/app/api/departements.py +++ b/app/api/departements.py @@ -187,117 +187,3 @@ def referenciel_competences(dept: str, formation_id: int): ) else: return jsonify(ref_comp) - - -@bp.route( - "/departements//formsemestre//programme", - methods=["GET"], -) -@token_permission_required(Permission.APIView) -def semestre_index(dept: str, formsemestre_id: int): - """ - Retourne la liste des Ues, ressources et SAE d'un semestre - - dept : l'acronym d'un département - formsemestre_id : l'id d'un formesemestre - - 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 - }, - ... - ] - } - """ - - app.set_sco_dept(dept) - - formsemestre = models.FormSemestre.query.filter_by( - id=formsemestre_id - ).first_or_404() - - ues = formsemestre.query_ues() - - 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 diff --git a/app/api/etudiants.py b/app/api/etudiants.py index 964dcde98..c04495abe 100644 --- a/app/api/etudiants.py +++ b/app/api/etudiants.py @@ -12,41 +12,33 @@ from app.models import FormSemestreInscription, FormSemestre, Identite from app.scodoc import sco_bulletins from app.scodoc import sco_groups from app.scodoc.sco_permissions import Permission -from app.scodoc import notesdb as ndb -@bp.route("/etudiants/courant", methods=["GET"]) +@bp.route("/etudiants/courant", defaults={"long": False}) +@bp.route("/etudiants/courant/long", defaults={"long": True}) @token_permission_required(Permission.APIView) -def etudiants_courant(): +def etudiants_courant(long=False): """ Retourne la liste des étudiants courant Exemple de résultat : - { - { - "civilite": "X", - "code_ine": null, - "code_nip": null, - "date_naissance": null, - "email": null, - "emailperso": null, - "etudid": 18, + [ + { + "id": 1, + "nip": 1, "nom": "MOREL", - "prenom": "JACQUES" - }, - { + "prenom": "JACQUES", "civilite": "X", - "code_ine": null, - "code_nip": null, - "date_naissance": null, - "email": null, - "emailperso": null, - "etudid": 19, - "nom": "FOURNIER", - "prenom": "ANNE" - }, - ... - } + }, + { + "id": 2, + "nip": 2, + "nom": "GILLES", + "prenom": "MAXIME", + "civilite": "X", + }, + ... + ] """ # Récupération de tous les étudiants etuds = Identite.query.filter( @@ -55,9 +47,11 @@ def etudiants_courant(): FormSemestre.date_debut <= app.db.func.now(), FormSemestre.date_fin >= app.db.func.now(), ) - - data = [etu.to_dict_bul(include_urls=False) for etu in etuds] - + if long: + data = [etud.to_dict_bul(include_urls=False) for etud in etuds] + else: + data = [etud.to_dict_short() for etud in etuds] + print(jsonify(data)) return jsonify(data) @@ -74,17 +68,32 @@ def etudiant(etudid: int = None, nip: int = None, ine: int = None): ine : le code ine d'un étudiant Exemple de résultat : - { - "civilite": "X", - "code_ine": null, - "code_nip": null, - "date_naissance": null, - "email": null, - "emailperso": null, - "etudid": 18, - "nom": "MOREL", - "prenom": "JACQUES" - } + { + "civilite": "X", + "code_ine": "1", + "code_nip": "1", + "date_naissance": "", + "email": "SACHA.COSTA@example.com", + "emailperso": "", + "etudid": 1, + "nom": "COSTA", + "prenom": "SACHA", + "nomprenom": "Sacha COSTA", + "lieu_naissance": "", + "dept_naissance": "", + "nationalite": "", + "boursier": "", + "id": 1, + "codepostaldomicile": "", + "paysdomicile": "", + "telephonemobile": "", + "typeadresse": "domicile", + "domicile": "", + "villedomicile": "", + "telephone": "", + "fax": "", + "description": "" + } """ # Récupération de l'étudiant etud = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine) @@ -108,38 +117,36 @@ def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None) ine : le code ine d'un étudiant Exemple de résultat : - [ - { - "titre": "master machine info", - "gestion_semestrielle": false, - "date_debut": "01/09/2021", - "bul_bgcolor": null, - "date_fin": "15/12/2022", - "resp_can_edit": false, - "dept_id": 1, - "etat": true, - "resp_can_change_ens": false, - "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, - "block_moyennes": false, - "formsemestre_id": 1, - "titre_num": "master machine info semestre 1", - "date_debut_iso": "2021-09-01", - "date_fin_iso": "2022-12-15", - "responsables": [ - 3, - 2 - ] - }, - ... - ] + [ + { + "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": [] + }, + ... + ] """ # Récupération de l'étudiant etud = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine) diff --git a/app/api/evaluations.py b/app/api/evaluations.py index 2f6049d99..4cbfa9f33 100644 --- a/app/api/evaluations.py +++ b/app/api/evaluations.py @@ -62,27 +62,27 @@ def evaluation_notes(evaluation_id: int): evaluation_id : l'id d'une évaluation Exemple de résultat : - { - "1": { - "id": 1, - "etudid": 10, - "evaluation_id": 1, - "value": 15.0, - "comment": "", - "date": "Wed, 20 Apr 2022 06:49:05 GMT", - "uid": 2 - }, - "2": { - "id": 2, - "etudid": 1, - "evaluation_id": 1, - "value": 12.0, - "comment": "", - "date": "Wed, 20 Apr 2022 06:49:06 GMT", - "uid": 2 - }, - ... - } + { + "1": { + "id": 1, + "etudid": 10, + "evaluation_id": 1, + "value": 15.0, + "comment": "", + "date": "Wed, 20 Apr 2022 06:49:05 GMT", + "uid": 2 + }, + "2": { + "id": 2, + "etudid": 1, + "evaluation_id": 1, + "value": 12.0, + "comment": "", + "date": "Wed, 20 Apr 2022 06:49:06 GMT", + "uid": 2 + }, + ... + } """ # Fonction utilisée : app.scodoc.sco_evaluation_db.do_evaluation_get_all_notes() diff --git a/app/api/formations.py b/app/api/formations.py index f7d1a6424..920d9af4c 100644 --- a/app/api/formations.py +++ b/app/api/formations.py @@ -32,7 +32,6 @@ def formations(): }, ... ] - """ # Récupération de toutes les formations list_formations = models.Formation.query.all() @@ -171,13 +170,12 @@ def formation_export_by_formation_id(formation_id: int, export_ids=False): }, ] } - """ # Fonction utilité : app.scodoc.sco_formations.formation_export() try: # Utilisation de la fonction formation_export - data = formation_export(formation_id) + data = formation_export(formation_id, export_ids) except ValueError: return error_response( 409, @@ -190,17 +188,47 @@ def formation_export_by_formation_id(formation_id: int, export_ids=False): @bp.route("/formations/moduleimpl/", methods=["GET"]) @token_permission_required(Permission.APIView) -def moduleimpls(moduleimpl_id: int): +def moduleimpl(moduleimpl_id: int): """ - Retourne la liste des moduleimpl + Retourne un module moduleimpl en fonction de son id moduleimpl_id : l'id d'un moduleimpl + + Exemple de résultat : + { + "id": 1, + "formsemestre_id": 1, + "computation_expr": null, + "module_id": 1, + "responsable_id": 2, + "moduleimpl_id": 1, + "ens": [], + "module": { + "heures_tp": 0, + "code_apogee": "", + "titre": "Initiation aux réseaux informatiques", + "coefficient": 1, + "module_type": 2, + "id": 1, + "ects": null, + "abbrev": "Init aux réseaux informatiques", + "ue_id": 1, + "code": "R101", + "formation_id": 1, + "heures_cours": 0, + "matiere_id": 1, + "heures_td": 0, + "semestre_id": 1, + "numero": 10, + "module_id": 1 + } + } """ # Récupération des tous les moduleimpl - list_moduleimpls = models.ModuleImpl.query.filter_by(id=moduleimpl_id) + moduleimpl = models.ModuleImpl.query.filter_by(id=moduleimpl_id).first_or_404() # Mise en forme des données - data = [moduleimpl.to_dict() for moduleimpl in list_moduleimpls] + data = moduleimpl.to_dict() return jsonify(data) @@ -208,7 +236,7 @@ def moduleimpls(moduleimpl_id: int): @bp.route( "/formations/moduleimpl/formsemestre//liste", methods=["GET"], -) # XXX TODO penser à changer la route sur la doc +) @token_permission_required(Permission.APIView) def moduleimpls_sem(formsemestre_id: int): """ diff --git a/app/api/formsemestres.py b/app/api/formsemestres.py index 9704d753c..122abf148 100644 --- a/app/api/formsemestres.py +++ b/app/api/formsemestres.py @@ -68,6 +68,35 @@ def formsemestre_apo(etape_apo: str): Retourne les informations sur les formsemestres etape_apo : l'id d'une étape apogée + + 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": [] + } """ formsemestres = FormSemestre.query.filter( FormSemestreEtape.etape_apo == etape_apo, @@ -78,21 +107,20 @@ def formsemestre_apo(etape_apo: str): @bp.route( - "/formsemestre//departements//etudiant/etudid//bulletin", + "/formsemestre//etudiant/etudid//bulletin", methods=["GET"], ) @bp.route( - "/formsemestre//departements//etudiant/nip//bulletin", + "/formsemestre//etudiant/nip//bulletin", methods=["GET"], ) @bp.route( - "/formsemestre//departements//etudiant/ine//bulletin", + "/formsemestre//etudiant/ine//bulletin", methods=["GET"], ) @token_permission_required(Permission.APIView) def etudiant_bulletin( formsemestre_id, - dept, etudid: int = None, nip: int = None, ine: int = None, @@ -212,7 +240,15 @@ def etudiant_bulletin( # Fonction utilisée : app.scodoc.sco_bulletins_json.make_json_formsemestre_bulletinetud() try: - app.set_sco_dept(dept) + formsemestre = models.FormSemestre.query.filter_by( + id=formsemestre_id + ).first_or_404() + + dept = models.Departement.query.filter_by( + id=formsemestre.dept_id + ).first_or_404() + + app.set_sco_dept(dept.acronym) except: return error_response( 409, @@ -470,3 +506,115 @@ def jury(formsemestre_id: int): # ) return jsonify(data) + + +@bp.route( + "/formsemestre//programme", + methods=["GET"], +) +@token_permission_required(Permission.APIView) +def semestre_index(formsemestre_id: int): + """ + Retourne la liste des Ues, ressources et SAE d'un semestre + + dept : l'acronym d'un département + formsemestre_id : l'id d'un formesemestre + + 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 + }, + ... + ] + } + """ + + formsemestre = models.FormSemestre.query.filter_by( + id=formsemestre_id + ).first_or_404() + + ues = formsemestre.query_ues() + + 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 diff --git a/app/api/partitions.py b/app/api/partitions.py index 2af2f7cf7..d925d1749 100644 --- a/app/api/partitions.py +++ b/app/api/partitions.py @@ -121,13 +121,13 @@ def etud_in_group(group_id: int, etat=None): @bp.route( - "/partitions/set_groups?partition_id=&groups_lists=&" - "groups_to_create=&groups_to_delete=", + "/partitions/set_groups/partition//groups//delete/" + "/create/", methods=["POST"], ) @token_permission_required(Permission.APIEtudChangeGroups) def set_groups( - partition_id: int, groups_lists: int, groups_to_delete: int, groups_to_create: int + partition_id: int, groups_lists: str, groups_to_delete: str, groups_to_create: str ): """ Set les groups diff --git a/app/comp/bonus_spo.py b/app/comp/bonus_spo.py index da8cce5d7..86d444c31 100644 --- a/app/comp/bonus_spo.py +++ b/app/comp/bonus_spo.py @@ -946,7 +946,7 @@ class BonusStBrieuc(BonusSportAdditif): name = "bonus_iut_stbrieuc" displayed_name = "IUT de Saint-Brieuc" proportion_point = 1 / 20.0 - classic_use_bonus_ues = True + classic_use_bonus_ues = False def compute_bonus(self, sem_modimpl_moys_inscrits, modimpl_coefs_etuds_no_nan): """calcul du bonus""" diff --git a/app/models/etudiants.py b/app/models/etudiants.py index b1fec6092..917b01363 100644 --- a/app/models/etudiants.py +++ b/app/models/etudiants.py @@ -141,7 +141,18 @@ class Identite(db.Model): "Le mail associé à la première adrese de l'étudiant, ou None" return getattr(self.adresses[0], field) if self.adresses.count() > 0 else None - def to_dict_scodoc7(self): + def to_dict_short(self) -> dict: + """Les champs essentiels""" + return { + "id": self.id, + "nip": self.code_nip, + "nom": self.nom, + "nom_usuel": self.nom_usuel, + "prenom": self.prenom, + "civilite": self.civilite, + } + + def to_dict_scodoc7(self) -> dict: """Représentation dictionnaire, compatible ScoDoc7 mais sans infos admission """ diff --git a/app/scodoc/sco_moduleimpl_status.py b/app/scodoc/sco_moduleimpl_status.py index a82cc2b1e..d6def3697 100644 --- a/app/scodoc/sco_moduleimpl_status.py +++ b/app/scodoc/sco_moduleimpl_status.py @@ -210,10 +210,17 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None): ) # la plus RECENTE en tête # - caneditevals = sco_permissions_check.can_edit_notes( - current_user, moduleimpl_id, allow_ens=sem["ens_can_edit_eval"] + sem_locked = not sem["etat"] + can_edit_evals = ( + sco_permissions_check.can_edit_notes( + current_user, moduleimpl_id, allow_ens=sem["ens_can_edit_eval"] + ) + and not sem_locked + ) + can_edit_notes = ( + sco_permissions_check.can_edit_notes(current_user, moduleimpl_id) + and not sem_locked ) - caneditnotes = sco_permissions_check.can_edit_notes(current_user, moduleimpl_id) arrow_up, arrow_down, arrow_none = sco_groups.get_arrow_icons_tags() # module_resp = User.query.get(M["responsable_id"]) @@ -264,7 +271,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None): H.append("""Semestre: %s""" % sem["semestre_id"]) else: H.append("""""") - if not sem["etat"]: + if sem_locked: H.append(scu.icontag("lock32_img", title="verrouillé")) H.append("""""") if modimpl.module.is_apc(): @@ -385,13 +392,15 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None): # -------- Tableau des evaluations top_table_links = "" - if sem["etat"]: # non verrouillé - top_table_links = ( - """Créer nouvelle évaluation - Trier par date - """ - % M - ) + if can_edit_evals: + top_table_links = f"""Créer nouvelle évaluation + Trier par date + """ if mod_evals: H.append( '