diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index 989c7bd5cf..0244520479 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -148,12 +148,15 @@ def formsemestre_bulletinetud_dict(formsemestre_id, etudid, version="long"): I["server_name"] = request.url_root # Formation et parcours + formation_dict = None if I["sem"]["formation_id"]: - I["formation"] = sco_formations.formation_list( + formation_dicts = sco_formations.formation_list( args={"formation_id": I["sem"]["formation_id"]} - )[0] - else: # what's the fuck ? - I["formation"] = { + ) + if formation_dicts: + formation_dict = formation_dicts[0] + if formation_dict is None: # what's the fuck ? + formation_dict = { "acronyme": "?", "code_specialite": "", "dept_id": 1, @@ -166,6 +169,7 @@ def formsemestre_bulletinetud_dict(formsemestre_id, etudid, version="long"): "type_parcours": 0, "version": 0, } + I["formation"] = formation_dict I["parcours"] = sco_codes_parcours.get_parcours_from_code( I["formation"]["type_parcours"] ) diff --git a/app/views/notes.py b/app/views/notes.py index fe1774a735..111019d829 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -299,21 +299,21 @@ def formsemestre_bulletinetud( raise ScoInvalidIdType( "formsemestre_bulletinetud: formsemestre_id must be an integer !" ) - formsemestre = FormSemestre.query.get_or_404(formsemestre_id) + formsemestre = FormSemestre.query.filter_by( + formsemestre_id=formsemestre_id, dept_id=g.scodoc_dept_id + ).first_or_404() if etudid: - etud = models.Identite.query.get_or_404(etudid) + etud = models.Identite.query.filter_by( + etudid=etudid, dept_id=formsemestre.dept_id + ).first_or_404() elif code_nip: - etud = ( - models.Identite.query.filter_by(code_nip=str(code_nip)) - .filter_by(dept_id=formsemestre.dept_id) - .first_or_404() - ) + etud = models.Identite.query.filter_by( + code_nip=str(code_nip), dept_id=formsemestre.dept_id + ).first_or_404() elif code_ine: - etud = ( - models.Identite.query.filter_by(code_ine=str(code_ine)) - .filter_by(dept_id=formsemestre.dept_id) - .first_or_404() - ) + etud = models.Identite.query.filter_by( + code_ine=str(code_ine), dept_id=formsemestre.dept_id + ).first_or_404() else: raise ScoValueError( "Paramètre manquant: spécifier etudid, code_nip ou code_ine"