forked from ScoDoc/ScoDoc
API: Fix /api/group/edit
This commit is contained in:
parent
3a059c4f44
commit
26454de0c4
@ -62,6 +62,7 @@ def verify_token(token) -> User:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
user = User.check_token(token) if token else None
|
user = User.check_token(token) if token else None
|
||||||
|
if user is not None:
|
||||||
flask_login.login_user(user)
|
flask_login.login_user(user)
|
||||||
g.current_user = user
|
g.current_user = user
|
||||||
return user
|
return user
|
||||||
|
@ -71,7 +71,7 @@ def formsemestre_partitions(formsemestre_id: int):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||||
partitions = sorted(formsemestre.partitions, key=lambda p: p.numero)
|
partitions = sorted(formsemestre.partitions, key=lambda p: p.numero or 0)
|
||||||
return jsonify(
|
return jsonify(
|
||||||
{
|
{
|
||||||
partition.id: partition.to_dict(with_groups=True)
|
partition.id: partition.to_dict(with_groups=True)
|
||||||
|
@ -136,9 +136,7 @@ class GroupDescr(db.Model):
|
|||||||
"numero": self.numero,
|
"numero": self.numero,
|
||||||
}
|
}
|
||||||
if with_partition:
|
if with_partition:
|
||||||
d["partition"] = sorted(
|
d["partition"] = self.partition.to_dict(with_groups=False)
|
||||||
self.partition, key=lambda p: p.numero or 0
|
|
||||||
).to_dict(with_groups=False)
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -59,7 +59,7 @@ def GET(path: str, headers={}, errmsg=None):
|
|||||||
"""Get and returns as JSON"""
|
"""Get and returns as JSON"""
|
||||||
r = requests.get(API_URL + path, headers=headers or HEADERS, verify=CHK_CERT)
|
r = requests.get(API_URL + path, headers=headers or HEADERS, verify=CHK_CERT)
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
raise ScoError(errmsg or f"erreur status={r.status_code} !")
|
raise ScoError(errmsg or f"""erreur status={r.status_code} !\n{r.json()}""")
|
||||||
return r.json() # decode la reponse JSON
|
return r.json() # decode la reponse JSON
|
||||||
|
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ def POST(path: str, data: dict = {}, headers={}, errmsg=None):
|
|||||||
verify=CHK_CERT,
|
verify=CHK_CERT,
|
||||||
)
|
)
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
raise ScoError(errmsg or f"erreur status={r.status_code} !")
|
raise ScoError(errmsg or f"erreur status={r.status_code} !\n{r.json()}")
|
||||||
return r.json() # decode la reponse JSON
|
return r.json() # decode la reponse JSON
|
||||||
|
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ def POST_JSON(path: str, data: dict = {}, headers={}, errmsg=None):
|
|||||||
verify=CHK_CERT,
|
verify=CHK_CERT,
|
||||||
)
|
)
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
raise ScoError(errmsg or f"erreur status={r.status_code} !")
|
raise ScoError(errmsg or f"erreur status={r.status_code} !\n{r.json()}")
|
||||||
return r.json() # decode la reponse JSON
|
return r.json() # decode la reponse JSON
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user