Compare commits

..

4 Commits

9 changed files with 83 additions and 42 deletions

View File

@ -123,19 +123,32 @@ def etudiant(etudid: int = None, nip: int = None, ine: int = None):
"prenom": "JACQUES"
}
"""
etu = []
# etu = []
if etudid is not None: # Si route etudid
# Récupération de l'étudiant
if etudid is None:
if nip is None: # si ine
etu = models.Identite.query.filter_by(code_ine=str(ine)).first()
else: # si nip
etu = models.Identite.query.filter_by(code_nip=str(nip)).first()
else: # si etudid
etu = models.Identite.query.filter_by(id=etudid).first()
if nip is not None: # Si route nip
# Récupération de l'étudiant
etu = models.Identite.query.filter_by(code_nip=nip).first()
if ine is not None: # Si route ine
# Récupération de l'étudiant
etu = models.Identite.query.filter_by(code_ine=ine).first()
# if etudid is not None: # Si route etudid
# # Récupération de l'étudiant
# etu = models.Identite.query.filter_by(id=etudid).first()
#
# if nip is not None: # Si route nip
# # Récupération de l'étudiant
# etu = models.Identite.query.filter_by(code_nip=str(nip)).first()
#
# breakpoint()
#
# if ine is not None: # Si route ine
# # Récupération de l'étudiant
# etu = models.Identite.query.filter_by(code_ine=str(ine)).first()
# Mise en forme des données
data = etu.to_dict_bul(include_urls=False)
@ -321,9 +334,10 @@ def etudiant_groups(formsemestre_id: int, etudid: int = None, nip: int = None, i
# Récupération du formsemestre
sem = models.FormSemestre.query.filter_by(id=formsemestre_id).first()
#breakpoint()
try:
# Utilisation de la fonction get_etud_groups
data = get_etud_groups(etudid, sem.to_dict())
data = get_etud_groups(etudid, sem.id)
except ValueError:
return error_response(409, message="La requête ne peut être traitée en létat actuel")

View File

@ -4,7 +4,6 @@ from flask import jsonify
from app import models
from app.api import bp
from app.api.errors import error_response
from app.decorators import permission_required
from app.api.auth import token_auth, token_permission_required
from app.scodoc.sco_bulletins import formsemestre_bulletinetud_dict
from app.scodoc.sco_permissions import Permission

View File

@ -102,9 +102,15 @@ class ScolarNews(db.Model):
}
@classmethod
def last_news(cls, n=1) -> list:
def last_news(cls, n=1, dept_id=None, filter_dept=True) -> list:
"The most recent n news. Returns list of ScolarNews instances."
return cls.query.order_by(cls.date.desc()).limit(n).all()
query = cls.query
if filter_dept:
if dept_id is None:
dept_id = g.scodoc_dept_id
query = query.filter_by(dept_id=dept_id)
return query.order_by(cls.date.desc()).limit(n).all()
@classmethod
def add(cls, typ, obj=None, text="", url=None, max_frequency=0):

View File

@ -222,7 +222,7 @@ def do_ue_delete(ue_id, delete_validations=False, force=False):
ScolarNews.add(
typ=ScolarNews.NEWS_FORM,
obj=ue.formation_id,
text="Modification de la formation %(acronyme)s" % F,
text=f"Modification de la formation {F['acronyme']}",
max_frequency=10 * 60,
)
#

View File

@ -1,7 +1,7 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
SCOVERSION = "9.2.1"
SCOVERSION = "9.2.2"
SCONAME = "ScoDoc"

View File

@ -75,9 +75,9 @@ def test_referenciel_competences():
# # semestre_index
def test_semestre_index(): #XXX TODO pour Seb
r = requests.get(
SCODOC_URL + "/ScoDoc/api/departements/TAPI/formsemestre/1/programme",
headers=HEADERS, verify=CHECK_CERTIFICATE
)
assert r.status_code == 200
# def test_semestre_index(): #XXX TODO pour Seb
# r = requests.get(
# SCODOC_URL + "/ScoDoc/api/departements/TAPI/formsemestre/1/programme",
# headers=HEADERS, verify=CHECK_CERTIFICATE
# )
# assert r.status_code == 200

View File

@ -22,6 +22,7 @@ import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
# etudiants
def test_etudiants():
r = requests.get(
@ -46,6 +47,20 @@ def test_etudiants():
"nom",
"prenom",
"nomprenom",
"lieu_naissance",
"dept_naissance",
"nationalite",
"boursier",
"id",
"domicile",
"villedomicile",
"telephone",
"fax",
"description",
"codepostaldomicile",
"paysdomicile",
"telephonemobile",
"typeadresse",
]
fields_OK = True
@ -59,40 +74,43 @@ def test_etudiants():
# etudiants_courant
def test_etudiants_courant(): #XXX TODO pour Seb
def test_etudiants_courant(): # XXX TODO pour Seb
r = requests.get(
SCODOC_URL + "/ScoDoc/api/etudiants/courant",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
assert len(r.json()) == 0
assert len(r.json()) == 16
# etudiant
def test_etudiant(): #XXX TODO pour Seb
def test_etudiant(): # XXX TODO pour Seb
r = requests.get(
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
assert len(r.json()) == 10
assert len(r.json()) == 24
# r = requests.get(
# SCODOC_URL + "/ScoDoc/api/etudiant/nip/<int:nip>",
# headers=HEADERS, verify=CHECK_CERTIFICATE
# )
# assert r.status_code == 200
# r = requests.get(
# SCODOC_URL + "/ScoDoc/api/etudiant/ine/<int:ine>",
# headers=HEADERS, verify=CHECK_CERTIFICATE
# )
# assert r.status_code == 200
r = requests.get(
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1",
headers=HEADERS, verify=CHECK_CERTIFICATE
)
assert r.status_code == 200
assert len(r.json()) == 24
r = requests.get(
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1",
headers=HEADERS, verify=CHECK_CERTIFICATE
)
assert r.status_code == 200
assert len(r.json()) == 24
# etudiant_formsemestres
def test_etudiant_formsemestres(): #XXX TODO pour Seb
def test_etudiant_formsemestres(): # XXX TODO pour Seb
r = requests.get(
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1/formsemestres",
headers=HEADERS,

View File

@ -24,7 +24,7 @@ from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
# formsemestre
def test_formsemestre():
r = requests.get(
SCODOC_URL + "/ScoDoc/api/formations/formsemestre/<int:formsemestre_id>",
SCODOC_URL + "/ScoDoc/api/formations/formsemestre/1",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
@ -35,7 +35,7 @@ def test_formsemestre():
def test_etudiant_bulletin(): #XXX TODO pour Seb
r = requests.get(
SCODOC_URL
+ "/ScoDoc/api/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/etudid/<int:etudid>/bulletin",
+ "/ScoDoc/api/formsemestre/1/departements/TAPI/etudiant/etudid/1/bulletin",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
@ -43,7 +43,7 @@ def test_etudiant_bulletin(): #XXX TODO pour Seb
r = requests.get(
SCODOC_URL
+ "/ScoDoc/api/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/nip/<int:nip>/bulletin",
+ "/ScoDoc/api/formsemestre/1/departements/TAPI/etudiant/nip/1/bulletin",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
@ -51,7 +51,7 @@ def test_etudiant_bulletin(): #XXX TODO pour Seb
r = requests.get(
SCODOC_URL
+ "/ScoDoc/api/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/ine/<int:ine>/bulletin",
+ "/ScoDoc/api/formsemestre/1/departements/TAPI/etudiant/ine/1/bulletin",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
@ -61,7 +61,7 @@ def test_etudiant_bulletin(): #XXX TODO pour Seb
# bulletins
def test_bulletins():
r = requests.get(
SCODOC_URL + "/ScoDoc/api/formsemestre/<int:formsemestre_id>/bulletins",
SCODOC_URL + "/ScoDoc/api/formsemestre/1/bulletins",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
@ -71,7 +71,7 @@ def test_bulletins():
# jury
def test_jury():
r = requests.get(
SCODOC_URL + "/ScoDoc/api/formsemestre/<int:formsemestre_id>/jury",
SCODOC_URL + "/ScoDoc/api/formsemestre/1/jury",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)

View File

@ -86,6 +86,10 @@ def create_fake_etud(dept):
etud = models.Identite(civilite=civilite, nom=nom, prenom=prenom, dept_id=dept.id)
db.session.add(etud)
db.session.commit()
etud.code_nip = etud.id
etud.code_ine = etud.id
db.session.add(etud)
db.session.commit()
adresse = models.Adresse(
etudid=etud.id, email=f"{etud.prenom}.{etud.nom}@example.com"
)