1
0
forked from ScoDoc/ScoDoc

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

This commit is contained in:
Emmanuel Viennet 2022-01-25 13:28:21 +01:00
commit 2c549b3d2d
5 changed files with 19 additions and 8 deletions

View File

@ -112,6 +112,7 @@ class User(UserMixin, db.Model):
self.password_hash = generate_password_hash(password) self.password_hash = generate_password_hash(password)
else: else:
self.password_hash = None self.password_hash = None
self.passwd_temp = False
def check_password(self, password): def check_password(self, password):
"""Check given password vs current one. """Check given password vs current one.

View File

@ -152,14 +152,19 @@ class BulletinBUT(ResultatsSemestreBUT):
} }
return d return d
def bulletin_etud(self, etud, formsemestre) -> dict: def bulletin_etud(self, etud, formsemestre, force_publishing=False) -> dict:
"""Le bulletin de l'étudiant dans ce semestre""" """Le bulletin de l'étudiant dans ce semestre.
Si force_publishing, rempli le bulletin même si bul_hide_xml est vrai
(bulletins non publiés).
"""
etat_inscription = etud.etat_inscription(formsemestre.id) etat_inscription = etud.etat_inscription(formsemestre.id)
nb_inscrits = self.get_inscriptions_counts()[scu.INSCRIT] nb_inscrits = self.get_inscriptions_counts()[scu.INSCRIT]
published = (not formsemestre.bul_hide_xml) or force_publishing
d = { d = {
"version": "0", "version": "0",
"type": "BUT", "type": "BUT",
"date": datetime.datetime.utcnow().isoformat() + "Z", "date": datetime.datetime.utcnow().isoformat() + "Z",
"publie": not formsemestre.bul_hide_xml,
"etudiant": etud.to_dict_bul(), "etudiant": etud.to_dict_bul(),
"formation": { "formation": {
"id": formsemestre.formation.id, "id": formsemestre.formation.id,
@ -171,6 +176,8 @@ class BulletinBUT(ResultatsSemestreBUT):
"etat_inscription": etat_inscription, "etat_inscription": etat_inscription,
"options": sco_preferences.bulletin_option_affichage(formsemestre.id), "options": sco_preferences.bulletin_option_affichage(formsemestre.id),
} }
if not published:
return d
semestre_infos = { semestre_infos = {
"etapes": [str(x.etape_apo) for x in formsemestre.etapes if x.etape_apo], "etapes": [str(x.etape_apo) for x in formsemestre.etapes if x.etape_apo],
"date_debut": formsemestre.date_debut.isoformat(), "date_debut": formsemestre.date_debut.isoformat(),

View File

@ -98,9 +98,9 @@ def formsemestre_bulletinetud_published_dict(
d = {} d = {}
if (not sem["bul_hide_xml"]) or force_publishing: if (not sem["bul_hide_xml"]) or force_publishing:
published = 1 published = True
else: else:
published = 0 published = False
if xml_nodate: if xml_nodate:
docdate = "" docdate = ""
else: else:

View File

@ -307,7 +307,9 @@ def formsemestre_bulletinetud(
) )
if format == "json": if format == "json":
r = bulletin_but.BulletinBUT(formsemestre) r = bulletin_but.BulletinBUT(formsemestre)
return jsonify(r.bulletin_etud(etud, formsemestre)) return jsonify(
r.bulletin_etud(etud, formsemestre, force_publishing=force_publishing)
)
elif format == "html": elif format == "html":
return render_template( return render_template(
"but/bulletin.html", "but/bulletin.html",
@ -318,6 +320,7 @@ def formsemestre_bulletinetud(
formsemestre_id=formsemestre_id, formsemestre_id=formsemestre_id,
etudid=etudid, etudid=etudid,
format="json", format="json",
force_publishing=1, # pour ScoDoc lui même
), ),
sco=ScoData(), sco=ScoData(),
) )

View File

@ -154,7 +154,7 @@ def create_user_form(user_name=None, edit=0, all_roles=1):
if user_name is not None: # scodoc7func converti en int ! if user_name is not None: # scodoc7func converti en int !
user_name = str(user_name) user_name = str(user_name)
auth_dept = current_user.dept auth_dept = current_user.dept
from_mail = current_user.email from_mail = current_app.config["SCODOC_MAIL_FROM"] # current_user.email
initvalues = {} initvalues = {}
edit = int(edit) edit = int(edit)
all_roles = int(all_roles) all_roles = int(all_roles)
@ -577,8 +577,8 @@ def create_user_form(user_name=None, edit=0, all_roles=1):
# A: envoi de welcome + procedure de reset # A: envoi de welcome + procedure de reset
# B: envoi de welcome seulement (mot de passe saisie dans le formulaire) # B: envoi de welcome seulement (mot de passe saisie dans le formulaire)
# C: Aucun envoi (mot de passe saisi dans le formulaire) # C: Aucun envoi (mot de passe saisi dans le formulaire)
if vals["welcome"] == "1": if vals["welcome"] != "1":
if vals["reset_password:list"] == "1": if vals["reset_password"] != "1":
mode = Mode.WELCOME_AND_CHANGE_PASSWORD mode = Mode.WELCOME_AND_CHANGE_PASSWORD
else: else:
mode = Mode.WELCOME_ONLY mode = Mode.WELCOME_ONLY