forked from ScoDoc/ScoDoc
API: modifs qq noms fonctions pour doc
This commit is contained in:
parent
8a85aa5b16
commit
2b22115dd8
@ -119,7 +119,7 @@ def assiduite_justificatifs(assiduite_id: int = None, long: bool = False):
|
||||
@scodoc
|
||||
@as_json
|
||||
@permission_required(Permission.ScoView)
|
||||
def count_assiduites(
|
||||
def assiduites_count(
|
||||
etudid: int = None, nip: str = None, ine: str = None, with_query: bool = False
|
||||
):
|
||||
"""
|
||||
@ -561,7 +561,7 @@ def assiduites_formsemestre(formsemestre_id: int, with_query: bool = False):
|
||||
@scodoc
|
||||
@as_json
|
||||
@permission_required(Permission.ScoView)
|
||||
def count_assiduites_formsemestre(
|
||||
def assiduites_formsemestre_count(
|
||||
formsemestre_id: int = None, with_query: bool = False
|
||||
):
|
||||
"""Comptage des assiduités du formsemestre
|
||||
|
@ -187,7 +187,7 @@ def etudiant(etudid: int = None, nip: str = None, ine: str = None):
|
||||
@login_required
|
||||
@scodoc
|
||||
@permission_required(Permission.ScoView)
|
||||
def get_photo_image(etudid: int = None, nip: str = None, ine: str = None):
|
||||
def etudiant_get_photo_image(etudid: int = None, nip: str = None, ine: str = None):
|
||||
"""
|
||||
Retourne la photo de l'étudiant ou un placeholder si non existant.
|
||||
Le paramètre `size` peut prendre la valeur `small` (taille réduite, hauteur
|
||||
@ -226,7 +226,7 @@ def get_photo_image(etudid: int = None, nip: str = None, ine: str = None):
|
||||
@scodoc
|
||||
@permission_required(Permission.EtudChangeAdr)
|
||||
@as_json
|
||||
def set_photo_image(etudid: int = None):
|
||||
def etudiant_set_photo_image(etudid: int = None):
|
||||
"""Enregistre la photo de l'étudiant."""
|
||||
allowed_depts = current_user.get_depts_with_permission(Permission.EtudChangeAdr)
|
||||
query = Identite.query.filter_by(id=etudid)
|
||||
|
@ -257,7 +257,7 @@ def referentiel_competences(formation_id: int):
|
||||
@scodoc
|
||||
@permission_required(Permission.EditFormation)
|
||||
@as_json
|
||||
def set_ue_parcours(ue_id: int):
|
||||
def ue_set_parcours(ue_id: int):
|
||||
"""Associe UE et parcours BUT.
|
||||
La liste des ids de parcours est passée en argument JSON.
|
||||
JSON arg: [parcour_id1, parcour_id2, ...]
|
||||
@ -273,7 +273,7 @@ def set_ue_parcours(ue_id: int):
|
||||
parcours = [
|
||||
ApcParcours.query.get_or_404(int(parcour_id)) for parcour_id in parcours_ids
|
||||
]
|
||||
log(f"set_ue_parcours: ue_id={ue.id} parcours_ids={parcours_ids}")
|
||||
log(f"ue_set_parcours: ue_id={ue.id} parcours_ids={parcours_ids}")
|
||||
ok, error_message = ue.set_parcours(parcours)
|
||||
if not ok:
|
||||
return json_error(404, error_message)
|
||||
@ -292,7 +292,7 @@ def set_ue_parcours(ue_id: int):
|
||||
@scodoc
|
||||
@permission_required(Permission.EditFormation)
|
||||
@as_json
|
||||
def assoc_ue_niveau(ue_id: int, niveau_id: int):
|
||||
def ue_assoc_niveau(ue_id: int, niveau_id: int):
|
||||
"""Associe l'UE au niveau de compétence"""
|
||||
query = UniteEns.query.filter_by(id=ue_id)
|
||||
if g.scodoc_dept:
|
||||
@ -321,7 +321,7 @@ def assoc_ue_niveau(ue_id: int, niveau_id: int):
|
||||
@scodoc
|
||||
@permission_required(Permission.EditFormation)
|
||||
@as_json
|
||||
def desassoc_ue_niveau(ue_id: int):
|
||||
def ue_desassoc_niveau(ue_id: int):
|
||||
"""Désassocie cette UE de son niveau de compétence
|
||||
(si elle n'est pas associée, ne fait rien)
|
||||
"""
|
||||
@ -358,7 +358,7 @@ def get_ue(ue_id: int):
|
||||
@login_required
|
||||
@scodoc
|
||||
@permission_required(Permission.ScoView)
|
||||
def get_module(module_id: int):
|
||||
def formation_module_get(module_id: int):
|
||||
"""Renvoie le module"""
|
||||
query = Module.query.filter_by(id=module_id)
|
||||
if g.scodoc_dept:
|
||||
@ -368,7 +368,7 @@ def get_module(module_id: int):
|
||||
|
||||
|
||||
@bp.route("/formation/ue/set_code_apogee", methods=["POST"])
|
||||
@api_web_bp.route("/ue/set_code_apogee", methods=["POST"])
|
||||
@api_web_bp.route("/formation/ue/set_code_apogee", methods=["POST"])
|
||||
@bp.route(
|
||||
"/formation/ue/<int:ue_id>/set_code_apogee/<string:code_apogee>", methods=["POST"]
|
||||
)
|
||||
@ -493,7 +493,9 @@ def ue_set_code_apogee_rcue(ue_id: int, code_apogee: str = ""):
|
||||
@login_required
|
||||
@scodoc
|
||||
@permission_required(Permission.EditFormation)
|
||||
def module_set_code_apogee(module_id: int | None = None, code_apogee: str = ""):
|
||||
def formation_module_set_code_apogee(
|
||||
module_id: int | None = None, code_apogee: str = ""
|
||||
):
|
||||
"""Change le code Apogée du module.
|
||||
Le code est une chaîne, avec éventuellement plusieurs valeurs séparées
|
||||
par des virgules.
|
||||
@ -538,7 +540,7 @@ def module_set_code_apogee(module_id: int | None = None, code_apogee: str = ""):
|
||||
@scodoc
|
||||
@permission_required(Permission.EditFormation)
|
||||
@as_json
|
||||
def module_edit(module_id: int):
|
||||
def formation_module_edit(module_id: int):
|
||||
"""Édition d'un module. Renvoie le module en json."""
|
||||
query = Module.query.filter_by(id=module_id)
|
||||
if g.scodoc_dept:
|
||||
|
@ -561,7 +561,7 @@ def formsemestre_etudiants(
|
||||
@scodoc
|
||||
@permission_required(Permission.ScoView)
|
||||
@as_json
|
||||
def etat_evals(formsemestre_id: int):
|
||||
def formsemestre_etat_evaluations(formsemestre_id: int):
|
||||
"""
|
||||
Informations sur l'état des évaluations d'un formsemestre.
|
||||
|
||||
@ -596,10 +596,7 @@ def etat_evals(formsemestre_id: int):
|
||||
},
|
||||
]
|
||||
"""
|
||||
query = FormSemestre.query.filter_by(id=formsemestre_id)
|
||||
if g.scodoc_dept:
|
||||
query = query.filter_by(dept_id=g.scodoc_dept_id)
|
||||
formsemestre: FormSemestre = query.first_or_404(formsemestre_id)
|
||||
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||
app.set_sco_dept(formsemestre.departement.acronym)
|
||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||
|
||||
@ -720,14 +717,14 @@ def formsemestre_resultat(formsemestre_id: int):
|
||||
return rows
|
||||
|
||||
|
||||
@bp.route("/formsemestre/<int:formsemestre_id>/get_groups_auto_assignment")
|
||||
@api_web_bp.route("/formsemestre/<int:formsemestre_id>/get_groups_auto_assignment")
|
||||
@bp.route("/formsemestre/<int:formsemestre_id>/groups_get_auto_assignment")
|
||||
@api_web_bp.route("/formsemestre/<int:formsemestre_id>/groups_get_auto_assignment")
|
||||
@login_required
|
||||
@scodoc
|
||||
@permission_required(Permission.ScoView)
|
||||
@as_json
|
||||
def get_groups_auto_assignment(formsemestre_id: int):
|
||||
"""rend les données"""
|
||||
def groups_get_auto_assignment(formsemestre_id: int):
|
||||
"""rend les données stockées par"""
|
||||
query = FormSemestre.query.filter_by(id=formsemestre_id)
|
||||
if g.scodoc_dept:
|
||||
query = query.filter_by(dept_id=g.scodoc_dept_id)
|
||||
@ -738,16 +735,16 @@ def get_groups_auto_assignment(formsemestre_id: int):
|
||||
|
||||
|
||||
@bp.route(
|
||||
"/formsemestre/<int:formsemestre_id>/save_groups_auto_assignment", methods=["POST"]
|
||||
"/formsemestre/<int:formsemestre_id>/groups_save_auto_assignment", methods=["POST"]
|
||||
)
|
||||
@api_web_bp.route(
|
||||
"/formsemestre/<int:formsemestre_id>/save_groups_auto_assignment", methods=["POST"]
|
||||
"/formsemestre/<int:formsemestre_id>/groups_save_auto_assignment", methods=["POST"]
|
||||
)
|
||||
@login_required
|
||||
@scodoc
|
||||
@permission_required(Permission.ScoView)
|
||||
@as_json
|
||||
def save_groups_auto_assignment(formsemestre_id: int):
|
||||
def groups_save_auto_assignment(formsemestre_id: int):
|
||||
"""enregistre les données"""
|
||||
query = FormSemestre.query.filter_by(id=formsemestre_id)
|
||||
if g.scodoc_dept:
|
||||
|
@ -108,7 +108,7 @@ def formsemestre_partitions(formsemestre_id: int):
|
||||
@scodoc
|
||||
@permission_required(Permission.ScoView)
|
||||
@as_json
|
||||
def etud_in_group(group_id: int):
|
||||
def group_etudiants(group_id: int):
|
||||
"""
|
||||
Retourne la liste des étudiants dans un groupe
|
||||
(inscrits au groupe et inscrits au semestre).
|
||||
@ -151,7 +151,7 @@ def etud_in_group(group_id: int):
|
||||
@scodoc
|
||||
@permission_required(Permission.ScoView)
|
||||
@as_json
|
||||
def etud_in_group_query(group_id: int):
|
||||
def group_etudiants_query(group_id: int):
|
||||
"""Étudiants du groupe, filtrés par état (aucun, I, D, DEF)
|
||||
|
||||
QUERY
|
||||
@ -185,7 +185,7 @@ def etud_in_group_query(group_id: int):
|
||||
@scodoc
|
||||
@permission_required(Permission.ScoView)
|
||||
@as_json
|
||||
def set_etud_group(etudid: int, group_id: int):
|
||||
def group_set_etudiant(group_id: int, etudid: int):
|
||||
"""Affecte l'étudiant au groupe indiqué"""
|
||||
etud = Identite.query.get_or_404(etudid)
|
||||
query = GroupDescr.query.filter_by(id=group_id)
|
||||
@ -507,7 +507,7 @@ def partition_create(formsemestre_id: int):
|
||||
@scodoc
|
||||
@permission_required(Permission.ScoView)
|
||||
@as_json
|
||||
def formsemestre_order_partitions(formsemestre_id: int):
|
||||
def formsemestre_set_partitions_order(formsemestre_id: int):
|
||||
"""Modifie l'ordre des partitions du formsemestre
|
||||
JSON args: [partition_id1, partition_id2, ...]
|
||||
"""
|
||||
@ -534,7 +534,7 @@ def formsemestre_order_partitions(formsemestre_id: int):
|
||||
db.session.commit()
|
||||
app.set_sco_dept(formsemestre.departement.acronym)
|
||||
sco_cache.invalidate_formsemestre(formsemestre_id)
|
||||
log(f"formsemestre_order_partitions({partition_ids})")
|
||||
log(f"formsemestre_set_partitions_order({partition_ids})")
|
||||
return [
|
||||
partition.to_dict()
|
||||
for partition in formsemestre.partitions.order_by(Partition.numero)
|
||||
|
@ -7,7 +7,7 @@ from app.auth.logic import basic_auth, token_auth
|
||||
@bp.route("/tokens", methods=["POST"])
|
||||
@basic_auth.login_required
|
||||
@as_json
|
||||
def get_token():
|
||||
def token_get():
|
||||
"renvoie un jeton jwt pour l'utilisateur courant"
|
||||
token = basic_auth.current_user().get_token()
|
||||
log(f"API: giving token to {basic_auth.current_user()}")
|
||||
@ -17,7 +17,7 @@ def get_token():
|
||||
|
||||
@bp.route("/tokens", methods=["DELETE"])
|
||||
@token_auth.login_required
|
||||
def revoke_token():
|
||||
def token_revoke():
|
||||
"révoque le jeton de l'utilisateur courant"
|
||||
user = token_auth.current_user()
|
||||
user.revoke_token()
|
||||
|
@ -298,7 +298,7 @@ def user_role_remove(uid: int, role_name: str, dept: str = None):
|
||||
@scodoc
|
||||
@permission_required(Permission.UsersView)
|
||||
@as_json
|
||||
def list_permissions():
|
||||
def permissions_list():
|
||||
"""Liste des noms de permissions définies"""
|
||||
return list(Permission.permission_by_name.keys())
|
||||
|
||||
@ -309,7 +309,7 @@ def list_permissions():
|
||||
@scodoc
|
||||
@permission_required(Permission.UsersView)
|
||||
@as_json
|
||||
def list_role(role_name: str):
|
||||
def role_get(role_name: str):
|
||||
"""Un rôle"""
|
||||
return Role.query.filter_by(name=role_name).first_or_404().to_dict()
|
||||
|
||||
@ -320,7 +320,7 @@ def list_role(role_name: str):
|
||||
@scodoc
|
||||
@permission_required(Permission.UsersView)
|
||||
@as_json
|
||||
def list_roles():
|
||||
def roles_list():
|
||||
"""Tous les rôles définis"""
|
||||
return [role.to_dict() for role in Role.query]
|
||||
|
||||
|
@ -60,7 +60,7 @@ def form_ue_choix_parcours(ue: UniteEns) -> str:
|
||||
f"""<label><input type="checkbox" name="{parcour.id}" value="{parcour.id}"
|
||||
{'checked' if parcour.id in ue_pids else ""}
|
||||
onclick="set_ue_parcour(this);"
|
||||
data-setter="{url_for("apiweb.set_ue_parcours",
|
||||
data-setter="{url_for("apiweb.ue_set_parcours",
|
||||
scodoc_dept=g.scodoc_dept, ue_id=ue.id)}"
|
||||
>{parcour.code}{ects_parcour_txt}</label>"""
|
||||
)
|
||||
|
@ -10,7 +10,7 @@
|
||||
{% if niv['niveau'] %}
|
||||
{% if current_user.has_permission(sco.Permission.EditFormation) %}
|
||||
<select name="ue_niv_{{niv['niveau'].id}}" id="ue_niv_{{niv['niveau'].id}}"
|
||||
onchange="assoc_ue_niveau(event,
|
||||
onchange="ue_assoc_niveau(event,
|
||||
{{niv['niveau'].id}}, {{parcour.id}}
|
||||
);"
|
||||
{% if niv['ue_'+sem] %}
|
||||
@ -144,7 +144,7 @@ Choisissez un parcours...
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
function assoc_ue_niveau(event, niveau_id) {
|
||||
function ue_assoc_niveau(event, niveau_id) {
|
||||
let ue_id = event.target.value;
|
||||
let url = "";
|
||||
let must_reload = false;
|
||||
@ -153,7 +153,7 @@ function assoc_ue_niveau(event, niveau_id) {
|
||||
ue_id = event.target.dataset.ue_id;
|
||||
const desassoc_url = '{{
|
||||
url_for(
|
||||
"apiweb.desassoc_ue_niveau",
|
||||
"apiweb.ue_desassoc_niveau",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
ue_id=11111
|
||||
)
|
||||
@ -163,7 +163,7 @@ function assoc_ue_niveau(event, niveau_id) {
|
||||
} else {
|
||||
const assoc_url = '{{
|
||||
url_for(
|
||||
"apiweb.assoc_ue_niveau",
|
||||
"apiweb.ue_assoc_niveau",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
ue_id=11111, niveau_id=22222
|
||||
)
|
||||
|
@ -569,7 +569,7 @@
|
||||
etudiants: etudiants
|
||||
};
|
||||
fetch(
|
||||
"/ScoDoc/{{formsemestre.departement.acronym}}/api/formsemestre/" + formsemestre + "/save_groups_auto_assignment",
|
||||
"/ScoDoc/{{formsemestre.departement.acronym}}/api/formsemestre/" + formsemestre + "/groups_save_auto_assignment",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
@ -582,7 +582,7 @@
|
||||
}
|
||||
|
||||
async function getFromScodoc() {
|
||||
let dataRaw = await fetch("/ScoDoc/{{formsemestre.departement.acronym}}/api/formsemestre/" + formsemestre + "/get_groups_auto_assignment");
|
||||
let dataRaw = await fetch("/ScoDoc/{{formsemestre.departement.acronym}}/api/formsemestre/" + formsemestre + "/groups_get_auto_assignment");
|
||||
let data = await dataRaw.text();
|
||||
if (data == "") {
|
||||
return {};
|
||||
|
@ -967,21 +967,17 @@ def partition_editor(formsemestre_id: int, edit_partition=False):
|
||||
return "\n".join(H)
|
||||
|
||||
|
||||
# Future page pour répartition parcours
|
||||
@bp.route("/students_groups_auto_assignment", methods=["GET", "POST"])
|
||||
@scodoc
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func
|
||||
def students_groups_auto_assignment(formsemestre_id: int):
|
||||
"""En cours de dev."""
|
||||
"""Répartition auto des groupes"""
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
H = [
|
||||
html_sco_header.sco_header(
|
||||
page_title=f"DEV",
|
||||
page_title="Répartition des groupes",
|
||||
),
|
||||
f"""<h2>
|
||||
</h2>
|
||||
""",
|
||||
render_template(
|
||||
"scolar/students_groups_auto_assignment.j2",
|
||||
formsemestre=formsemestre,
|
||||
|
@ -95,7 +95,7 @@ def test_route_assiduite(api_headers):
|
||||
)
|
||||
|
||||
|
||||
def test_route_count_assiduites(api_headers):
|
||||
def test_route_assiduites_count(api_headers):
|
||||
"""test de la route /assiduites/<etudid:int>/count"""
|
||||
|
||||
# Bon fonctionnement
|
||||
|
@ -14,6 +14,7 @@ Utilisation :
|
||||
Lancer :
|
||||
pytest tests/api/test_api_formsemestre.py
|
||||
"""
|
||||
|
||||
import requests
|
||||
|
||||
from app.scodoc import sco_utils as scu
|
||||
@ -25,11 +26,11 @@ from tests.api.setup_test_api import (
|
||||
)
|
||||
|
||||
|
||||
def test_save_groups_auto_assignment(api_headers):
|
||||
def test_groups_save_auto_assignment(api_headers):
|
||||
"""
|
||||
Routes:
|
||||
/formsemestre/<id>/save_groups_auto_assignment
|
||||
/formsemestre/<id>/get_groups_auto_assignment
|
||||
/formsemestre/<id>/groups_save_auto_assignment
|
||||
/formsemestre/<id>/groups_get_auto_assignment
|
||||
"""
|
||||
formsemestre_id = 1
|
||||
r = requests.get(
|
||||
@ -44,7 +45,7 @@ def test_save_groups_auto_assignment(api_headers):
|
||||
"""{ "attribute" : "Un paquet de json", "valide": pas nécessairement +}--"""
|
||||
)
|
||||
r = requests.post(
|
||||
f"{API_URL}/formsemestre/{formsemestre_id}/save_groups_auto_assignment",
|
||||
f"{API_URL}/formsemestre/{formsemestre_id}/groups_save_auto_assignment",
|
||||
data=data_orig.encode("utf-8"),
|
||||
headers=api_headers,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
@ -53,7 +54,7 @@ def test_save_groups_auto_assignment(api_headers):
|
||||
assert r.status_code == 200
|
||||
# GET
|
||||
r = requests.get(
|
||||
f"{API_URL}/formsemestre/{formsemestre_id}/get_groups_auto_assignment",
|
||||
f"{API_URL}/formsemestre/{formsemestre_id}/groups_get_auto_assignment",
|
||||
headers=api_headers,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
timeout=scu.SCO_TEST_API_TIMEOUT,
|
||||
@ -62,7 +63,7 @@ def test_save_groups_auto_assignment(api_headers):
|
||||
assert r.text == data_orig
|
||||
# Tente d'envoyer trop de données
|
||||
r = requests.post(
|
||||
f"{API_URL}/formsemestre/{formsemestre_id}/save_groups_auto_assignment",
|
||||
f"{API_URL}/formsemestre/{formsemestre_id}/groups_save_auto_assignment",
|
||||
data="F*CK" * 1000000, # environ 4MB
|
||||
headers=api_headers,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
|
@ -157,7 +157,7 @@ def test_formsemestre_partition(api_headers):
|
||||
assert repl["OK"] is True
|
||||
|
||||
|
||||
def test_etud_in_group(api_headers):
|
||||
def test_group_etudiants(api_headers):
|
||||
"""
|
||||
Test '/group/<int:group_id>/etudiants'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user