1
0
forked from ScoDoc/ScoDoc

9.1.20 avec des cerises

This commit is contained in:
Emmanuel Viennet 2022-01-08 19:53:17 +01:00
parent fbae5d268f
commit 24bfb8a13d
6 changed files with 19 additions and 8 deletions

View File

@ -4,6 +4,7 @@
from app import db from app import db
from app.comp import df_cache from app.comp import df_cache
from app.models import SHORT_STR_LEN from app.models import SHORT_STR_LEN
from app.models.modules import Module
from app.scodoc import notesdb as ndb from app.scodoc import notesdb as ndb
from app.scodoc import sco_cache from app.scodoc import sco_cache
from app.scodoc import sco_codes_parcours from app.scodoc import sco_codes_parcours
@ -114,6 +115,7 @@ class Formation(db.Model):
return return
change = False change = False
for mod in self.modules: for mod in self.modules:
# --- Indices de semestres:
if ( if (
mod.ue.semestre_idx is not None mod.ue.semestre_idx is not None
and mod.ue.semestre_idx > 0 and mod.ue.semestre_idx > 0
@ -122,10 +124,15 @@ class Formation(db.Model):
mod.semestre_id = mod.ue.semestre_idx mod.semestre_id = mod.ue.semestre_idx
db.session.add(mod) db.session.add(mod)
change = True change = True
# --- Types de modules
if mod.module_type is None: if mod.module_type is None:
mod.module_type = scu.ModuleType.STANDARD mod.module_type = scu.ModuleType.STANDARD
db.session.add(mod) db.session.add(mod)
change = True change = True
# --- Numéros de modules
if Module.query.filter_by(formation_id=220, numero=None).count() > 0:
scu.objects_renumber(db, self.modules.all())
db.session.commit() db.session.commit()
if change: if change:
self.invalidate_module_coefs() self.invalidate_module_coefs()

View File

@ -306,7 +306,6 @@ def do_formation_edit(args):
sco_formations._formationEditor.edit(cnx, args) sco_formations._formationEditor.edit(cnx, args)
formation: Formation = Formation.query.get(args["formation_id"]) formation: Formation = Formation.query.get(args["formation_id"])
formation.invalidate_cached_sems() formation.invalidate_cached_sems()
formation.sanitize_old_formation()
def module_move(module_id, after=0, redirect=True): def module_move(module_id, after=0, redirect=True):

View File

@ -509,7 +509,6 @@ def ue_table(formation_id=None, semestre_idx=1, msg=""): # was ue_list
formation: Formation = Formation.query.get(formation_id) formation: Formation = Formation.query.get(formation_id)
if not formation: if not formation:
raise ScoValueError("invalid formation_id") raise ScoValueError("invalid formation_id")
formation.sanitize_old_formation()
parcours = formation.get_parcours() parcours = formation.get_parcours()
is_apc = parcours.APC_SAE is_apc = parcours.APC_SAE
locked = formation.has_locked_sems() locked = formation.has_locked_sems()
@ -1205,7 +1204,6 @@ def do_ue_edit(args, bypass_lock=False, dont_invalidate_cache=False):
if not dont_invalidate_cache: if not dont_invalidate_cache:
# Invalide les semestres utilisant cette formation: # Invalide les semestres utilisant cette formation:
formation.invalidate_cached_sems() formation.invalidate_cached_sems()
formation.sanitize_old_formation()
# essai edition en ligne: # essai edition en ligne:

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
SCOVERSION = "9.1.19" SCOVERSION = "9.1.20"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"

View File

@ -438,14 +438,21 @@ def photos_import_files(formsemestre_id: int, xlsfile: str, zipfile: str):
@app.cli.command() @app.cli.command()
@click.option("--sanitize/--no-sanitize", default=False)
@with_appcontext @with_appcontext
def clear_cache(): # clear-cache def clear_cache(sanitize): # clear-cache
"""Clear ScoDoc cache """Clear ScoDoc cache
This cache (currently Redis) is persistent between invocation This cache (currently Redis) is persistent between invocation
and it may be necessary to clear it during development or tests. and it may be necessary to clear it during upgrades,
development or tests.
""" """
click.echo("Flushing Redis cache...")
clear_scodoc_cache() clear_scodoc_cache()
click.echo("Redis caches flushed.") if sanitize:
# sanitizes all formations:
click.echo("Checking formations...")
for formation in Formation.query:
formation.sanitize_old_formation()
def recursive_help(cmd, parent=None): def recursive_help(cmd, parent=None):

View File

@ -107,7 +107,7 @@ then
# utilise les scripts dans migrations/version/ # utilise les scripts dans migrations/version/
# pour mettre à jour notre base (en tant qu'utilisateur scodoc) # pour mettre à jour notre base (en tant qu'utilisateur scodoc)
export FLASK_ENV="production" export FLASK_ENV="production"
su -c "(cd $SCODOC_DIR && source venv/bin/activate && flask db upgrade && flask clear-cache)" "$SCODOC_USER" su -c "(cd $SCODOC_DIR && source venv/bin/activate && flask db upgrade && flask clear-cache --sanitize)" "$SCODOC_USER"
fi fi
# ------------ LOGROTATE # ------------ LOGROTATE