forked from ScoDoc/ScoDoc
API: Modification structure partitions/groupes
This commit is contained in:
parent
c3952c1118
commit
149522bcd3
@ -24,7 +24,8 @@ from app.scodoc import sco_utils as scu
|
||||
@bp.route("/partition/<int:partition_id>", methods=["GET"])
|
||||
@permission_required_api(Permission.ScoView, Permission.APIView)
|
||||
def partition_info(partition_id: int):
|
||||
"""
|
||||
"""Info sur une partition.
|
||||
|
||||
Exemple de résultat :
|
||||
```
|
||||
{
|
||||
@ -49,15 +50,33 @@ def partition_info(partition_id: int):
|
||||
@bp.route("/formsemestre/<int:formsemestre_id>/partitions", methods=["GET"])
|
||||
@permission_required_api(Permission.ScoView, Permission.APIView)
|
||||
def formsemestre_partitions(formsemestre_id: int):
|
||||
"""
|
||||
Retourne la liste de toutes les partitions d'un formsemestre
|
||||
"""Liste de toutes les partitions d'un formsemestre
|
||||
|
||||
formsemestre_id : l'id d'un formsemestre
|
||||
|
||||
{
|
||||
partition_id : {
|
||||
"bul_show_rank": False,
|
||||
"formsemestre_id": 1063,
|
||||
"groups" :
|
||||
group_id : {
|
||||
"id" : 12,
|
||||
"name" : "A",
|
||||
"partition_id" : partition_id,
|
||||
}
|
||||
},
|
||||
...
|
||||
}
|
||||
|
||||
"""
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
partitions = sorted(formsemestre.partitions, key=lambda p: p.numero)
|
||||
return jsonify(
|
||||
[partition.to_dict(with_groups=True) for partition in formsemestre.partitions]
|
||||
{
|
||||
partition.id: partition.to_dict(with_groups=True)
|
||||
for partition in partitions
|
||||
if partition.partition_name is not None
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
@ -90,7 +90,11 @@ class Partition(db.Model):
|
||||
d.pop("formsemestre", None)
|
||||
|
||||
if with_groups:
|
||||
d["groups"] = [group.to_dict(with_partition=False) for group in self.groups]
|
||||
groups = sorted(self.groups, key=lambda g: g.group_name)
|
||||
# un dict et non plus une liste, pour JSON
|
||||
d["groups"] = {
|
||||
group.id: group.to_dict(with_partition=False) for group in groups
|
||||
}
|
||||
return d
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user