forked from ScoDoc/ScoDoc
Merge branch 'master' of https://scodoc.org/git/viennet/ScoDoc into table
This commit is contained in:
commit
381aaf6a0a
@ -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"
|
||||
if formsemestre_id is None:
|
||||
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})
|
||||
if not sems:
|
||||
log(f"get_formsemestre: invalid formsemestre_id ({formsemestre_id})")
|
||||
if raise_soft_exc:
|
||||
raise ScoValueError(f"semestre {formsemestre_id} inconnu !")
|
||||
else:
|
||||
raise ValueError(f"semestre {formsemestre_id} inconnu !")
|
||||
|
||||
g.stored_get_formsemestre[formsemestre_id] = sems[0]
|
||||
return sems[0]
|
||||
|
||||
|
@ -300,9 +300,7 @@ def get_group_infos(group_id, etat=None): # was _getlisteetud
|
||||
|
||||
cnx = ndb.GetDBConnexion()
|
||||
group = get_group(group_id)
|
||||
sem = sco_formsemestre.get_formsemestre(
|
||||
group["formsemestre_id"], raise_soft_exc=True
|
||||
)
|
||||
sem = sco_formsemestre.get_formsemestre(group["formsemestre_id"])
|
||||
|
||||
members = get_group_members(group_id, etat=etat)
|
||||
# add human readable description of state:
|
||||
|
@ -7,7 +7,7 @@ from flask import g
|
||||
from flask_login import current_user
|
||||
|
||||
from app.auth.models import User
|
||||
|
||||
from app.models import FormSemestre
|
||||
import app.scodoc.notesdb as ndb
|
||||
from app.scodoc.sco_permissions import Permission
|
||||
from app.scodoc import html_sco_header
|
||||
@ -164,18 +164,14 @@ def check_access_diretud(formsemestre_id, required_permission=Permission.ScoImpl
|
||||
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"
|
||||
from app.scodoc import sco_formsemestre
|
||||
|
||||
sem = sco_formsemestre.get_formsemestre(formsemestre_id, raise_soft_exc=True)
|
||||
if not sem["etat"]:
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404()
|
||||
if not formsemestre.etat:
|
||||
return False # semestre verrouillé
|
||||
if current_user.has_permission(Permission.ScoEtudChangeGroups):
|
||||
return True # admin, chef dept
|
||||
if current_user.id in sem["responsables"]:
|
||||
return True
|
||||
return False
|
||||
return True # typiquement admin, chef dept
|
||||
return formsemestre.est_responsable(current_user)
|
||||
|
||||
|
||||
def can_handle_passwd(user: User, allow_admindepts=False) -> bool:
|
||||
|
Loading…
Reference in New Issue
Block a user