forked from ScoDoc/ScoDoc
API departement: noms fonctions pour doc
This commit is contained in:
parent
7620880b91
commit
8a59121b80
@ -16,15 +16,15 @@ from flask import request
|
|||||||
from flask_json import as_json
|
from flask_json import as_json
|
||||||
from flask_login import login_required
|
from flask_login import login_required
|
||||||
|
|
||||||
import app
|
|
||||||
from app import db
|
from app import db
|
||||||
from app.api import api_bp as bp, API_CLIENT_ERROR
|
from app.api import api_bp as bp, API_CLIENT_ERROR
|
||||||
from app.scodoc.sco_utils import json_error
|
from app.api import api_permission_required as permission_required
|
||||||
from app.decorators import scodoc, permission_required
|
from app.decorators import scodoc
|
||||||
from app.models import Departement, FormSemestre
|
from app.models import Departement, FormSemestre
|
||||||
from app.models import departements
|
from app.models import departements
|
||||||
from app.scodoc.sco_exceptions import ScoValueError
|
from app.scodoc.sco_exceptions import ScoValueError
|
||||||
from app.scodoc.sco_permissions import Permission
|
from app.scodoc.sco_permissions import Permission
|
||||||
|
from app.scodoc.sco_utils import json_error
|
||||||
|
|
||||||
|
|
||||||
def get_departement(dept_ident: str) -> Departement:
|
def get_departement(dept_ident: str) -> Departement:
|
||||||
@ -63,7 +63,7 @@ def departements_ids():
|
|||||||
@scodoc
|
@scodoc
|
||||||
@permission_required(Permission.ScoView)
|
@permission_required(Permission.ScoView)
|
||||||
@as_json
|
@as_json
|
||||||
def departement(acronym: str):
|
def departement_by_acronym(acronym: str):
|
||||||
"""
|
"""
|
||||||
Info sur un département. Accès par acronyme.
|
Info sur un département. Accès par acronyme.
|
||||||
|
|
||||||
@ -117,6 +117,9 @@ def departement_create():
|
|||||||
dept = departements.create_dept(acronym, visible=visible)
|
dept = departements.create_dept(acronym, visible=visible)
|
||||||
except ScoValueError as exc:
|
except ScoValueError as exc:
|
||||||
return json_error(500, exc.args[0] if exc.args else "")
|
return json_error(500, exc.args[0] if exc.args else "")
|
||||||
|
|
||||||
|
log(f"departement_create {dept.acronym}")
|
||||||
|
|
||||||
return dept.to_dict()
|
return dept.to_dict()
|
||||||
|
|
||||||
|
|
||||||
@ -142,6 +145,7 @@ def departement_edit(acronym):
|
|||||||
dept.visible = visible
|
dept.visible = visible
|
||||||
db.session.add(dept)
|
db.session.add(dept)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
log(f"departement_edit {dept.acronym}")
|
||||||
return dept.to_dict()
|
return dept.to_dict()
|
||||||
|
|
||||||
|
|
||||||
@ -154,8 +158,10 @@ def departement_delete(acronym):
|
|||||||
Suppression d'un département.
|
Suppression d'un département.
|
||||||
"""
|
"""
|
||||||
dept = Departement.query.filter_by(acronym=acronym).first_or_404()
|
dept = Departement.query.filter_by(acronym=acronym).first_or_404()
|
||||||
|
acronym = dept.acronym
|
||||||
db.session.delete(dept)
|
db.session.delete(dept)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
log(f"departement_delete {acronym}")
|
||||||
return {"OK": True}
|
return {"OK": True}
|
||||||
|
|
||||||
|
|
||||||
@ -164,7 +170,7 @@ def departement_delete(acronym):
|
|||||||
@scodoc
|
@scodoc
|
||||||
@permission_required(Permission.ScoView)
|
@permission_required(Permission.ScoView)
|
||||||
@as_json
|
@as_json
|
||||||
def dept_etudiants(acronym: str):
|
def departement_etudiants(acronym: str):
|
||||||
"""
|
"""
|
||||||
Retourne la liste des étudiants d'un département
|
Retourne la liste des étudiants d'un département
|
||||||
|
|
||||||
@ -195,7 +201,7 @@ def dept_etudiants(acronym: str):
|
|||||||
@scodoc
|
@scodoc
|
||||||
@permission_required(Permission.ScoView)
|
@permission_required(Permission.ScoView)
|
||||||
@as_json
|
@as_json
|
||||||
def dept_etudiants_by_id(dept_id: int):
|
def departement_etudiants_by_id(dept_id: int):
|
||||||
"""
|
"""
|
||||||
Retourne la liste des étudiants d'un département d'id donné.
|
Retourne la liste des étudiants d'un département d'id donné.
|
||||||
"""
|
"""
|
||||||
@ -231,7 +237,7 @@ def dept_formsemestres_ids_by_id(dept_id: int):
|
|||||||
@scodoc
|
@scodoc
|
||||||
@permission_required(Permission.ScoView)
|
@permission_required(Permission.ScoView)
|
||||||
@as_json
|
@as_json
|
||||||
def dept_formsemestres_courants(acronym: str = "", dept_id: int | None = None):
|
def departement_formsemestres_courants(acronym: str = "", dept_id: int | None = None):
|
||||||
"""
|
"""
|
||||||
Liste les semestres du département indiqué (par son acronyme ou son id)
|
Liste les semestres du département indiqué (par son acronyme ou son id)
|
||||||
contenant la date courante, ou à défaut celle indiquée en argument
|
contenant la date courante, ou à défaut celle indiquée en argument
|
||||||
|
Loading…
Reference in New Issue
Block a user