1
0
forked from ScoDoc/ScoDoc

Merge branch 'master' of https://scodoc.org/git/viennet/ScoDoc into table

This commit is contained in:
Emmanuel Viennet 2023-02-01 11:05:36 -03:00
commit 381aaf6a0a
3 changed files with 10 additions and 18 deletions

View File

@ -93,7 +93,7 @@ _formsemestreEditor = ndb.EditableTable(
) )
def get_formsemestre(formsemestre_id, raise_soft_exc=False): def get_formsemestre(formsemestre_id: int):
"list ONE formsemestre" "list ONE formsemestre"
if formsemestre_id is None: if formsemestre_id is None:
raise ValueError("get_formsemestre: id manquant") raise ValueError("get_formsemestre: id manquant")
@ -105,10 +105,8 @@ def get_formsemestre(formsemestre_id, raise_soft_exc=False):
sems = do_formsemestre_list(args={"formsemestre_id": formsemestre_id}) sems = do_formsemestre_list(args={"formsemestre_id": formsemestre_id})
if not sems: if not sems:
log(f"get_formsemestre: invalid formsemestre_id ({formsemestre_id})") log(f"get_formsemestre: invalid formsemestre_id ({formsemestre_id})")
if raise_soft_exc:
raise ScoValueError(f"semestre {formsemestre_id} inconnu !") raise ScoValueError(f"semestre {formsemestre_id} inconnu !")
else:
raise ValueError(f"semestre {formsemestre_id} inconnu !")
g.stored_get_formsemestre[formsemestre_id] = sems[0] g.stored_get_formsemestre[formsemestre_id] = sems[0]
return sems[0] return sems[0]

View File

@ -300,9 +300,7 @@ def get_group_infos(group_id, etat=None): # was _getlisteetud
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
group = get_group(group_id) group = get_group(group_id)
sem = sco_formsemestre.get_formsemestre( sem = sco_formsemestre.get_formsemestre(group["formsemestre_id"])
group["formsemestre_id"], raise_soft_exc=True
)
members = get_group_members(group_id, etat=etat) members = get_group_members(group_id, etat=etat)
# add human readable description of state: # add human readable description of state:

View File

@ -7,7 +7,7 @@ from flask import g
from flask_login import current_user from flask_login import current_user
from app.auth.models import User from app.auth.models import User
from app.models import FormSemestre
import app.scodoc.notesdb as ndb import app.scodoc.notesdb as ndb
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission
from app.scodoc import html_sco_header from app.scodoc import html_sco_header
@ -164,18 +164,14 @@ def check_access_diretud(formsemestre_id, required_permission=Permission.ScoImpl
return True, "" return True, ""
def can_change_groups(formsemestre_id): def can_change_groups(formsemestre_id: int) -> bool:
"Vrai si l'utilisateur peut changer les groupes dans ce semestre" "Vrai si l'utilisateur peut changer les groupes dans ce semestre"
from app.scodoc import sco_formsemestre formsemestre: FormSemestre = FormSemestre.query.get_or_404()
if not formsemestre.etat:
sem = sco_formsemestre.get_formsemestre(formsemestre_id, raise_soft_exc=True)
if not sem["etat"]:
return False # semestre verrouillé return False # semestre verrouillé
if current_user.has_permission(Permission.ScoEtudChangeGroups): if current_user.has_permission(Permission.ScoEtudChangeGroups):
return True # admin, chef dept return True # typiquement admin, chef dept
if current_user.id in sem["responsables"]: return formsemestre.est_responsable(current_user)
return True
return False
def can_handle_passwd(user: User, allow_admindepts=False) -> bool: def can_handle_passwd(user: User, allow_admindepts=False) -> bool: