WIP: prepare migration (remove zope context)
This commit is contained in:
parent
5e8c837fb2
commit
77f68d1c4c
@ -25,6 +25,6 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
"""ScoDoc core
|
||||
"""ScoDoc core package
|
||||
"""
|
||||
from app.ScoDoc import sco_core
|
||||
# from app.scodoc import sco_core
|
||||
|
@ -1,15 +1,19 @@
|
||||
# -*- mode: python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""essai: ceci serait un module ScoDoc/sco_xxx.py
|
||||
"""essai: ceci serait un module scodoc/sco_xxx.py
|
||||
"""
|
||||
|
||||
import types
|
||||
|
||||
import sco_utils as scu
|
||||
|
||||
|
||||
def sco_get_version(context, REQUEST=None):
|
||||
"""Une fonction typique de ScoDoc7
|
||||
"""
|
||||
"""Une fonction typique de ScoDoc7"""
|
||||
return """<html><body><p>%s</p></body></html>""" % scu.SCOVERSION
|
||||
|
||||
|
||||
def test_refactor(context, x=1):
|
||||
x = context.toto()
|
||||
y = ("context=" + context.module_is_locked("alpha")) + "23"
|
||||
|
@ -20,7 +20,7 @@ from app.auth.models import Permission
|
||||
from app.views import notes_bp as bp
|
||||
|
||||
# import sco_core deviendra:
|
||||
from app.ScoDoc import sco_core
|
||||
from app.scodoc import sco_core
|
||||
|
||||
context = ScoDoc7Context(globals())
|
||||
|
||||
|
@ -30,6 +30,7 @@ Module notes: issu de ScoDoc7 / ZNotes.py
|
||||
|
||||
Emmanuel Viennet, 2021
|
||||
"""
|
||||
import sys
|
||||
import time
|
||||
import datetime
|
||||
import jaxml
|
||||
@ -53,81 +54,81 @@ from app.views import notes_bp as bp
|
||||
|
||||
# ---------------
|
||||
|
||||
from app.ScoDoc import sco_utils as scu
|
||||
from app.ScoDoc import notesdb as ndb
|
||||
from app.ScoDoc.notes_log import log, sendAlarm
|
||||
from app.scodoc import sco_utils as scu
|
||||
from app.scodoc import notesdb as ndb
|
||||
from app.scodoc.notes_log import log, sendAlarm
|
||||
|
||||
from app.ScoDoc import scolog
|
||||
from app.ScoDoc.scolog import logdb
|
||||
from app.scodoc import scolog
|
||||
from app.scodoc.scolog import logdb
|
||||
|
||||
from app.ScoDoc.sco_exceptions import (
|
||||
from app.scodoc.sco_exceptions import (
|
||||
ScoValueError,
|
||||
ScoLockedFormError,
|
||||
ScoGenError,
|
||||
AccessDenied,
|
||||
)
|
||||
from app.ScoDoc.sco_permissions import Permission, ScoImplement
|
||||
from app.ScoDoc.TrivialFormulator import TrivialFormulator
|
||||
import app.ScoDoc.htmlutils as htmlutils
|
||||
import app.ScoDoc.sco_excel as sco_excel
|
||||
from app.scodoc.sco_permissions import Permission, ScoImplement
|
||||
from app.scodoc.TrivialFormulator import TrivialFormulator
|
||||
import app.scodoc.htmlutils as htmlutils
|
||||
import app.scodoc.sco_excel as sco_excel
|
||||
|
||||
from app.ScoDoc.gen_tables import GenTable
|
||||
from app.ScoDoc import sco_cache as sco_cache
|
||||
from app.ScoDoc import scolars as scolars
|
||||
from app.ScoDoc import sco_news as sco_news
|
||||
from app.ScoDoc.sco_news import NEWS_INSCR, NEWS_NOTE, NEWS_FORM, NEWS_SEM, NEWS_MISC
|
||||
from app.scodoc.gen_tables import GenTable
|
||||
from app.scodoc import sco_cache as sco_cache
|
||||
from app.scodoc import scolars as scolars
|
||||
from app.scodoc import sco_news as sco_news
|
||||
from app.scodoc.sco_news import NEWS_INSCR, NEWS_NOTE, NEWS_FORM, NEWS_SEM, NEWS_MISC
|
||||
|
||||
from app.ScoDoc import sco_formsemestre as sco_formsemestre
|
||||
from app.ScoDoc import sco_formsemestre_edit as sco_formsemestre_edit
|
||||
from app.ScoDoc import sco_formsemestre_status as sco_formsemestre_status
|
||||
from app.ScoDoc import sco_formsemestre_inscriptions as sco_formsemestre_inscriptions
|
||||
from app.ScoDoc import sco_formsemestre_custommenu as sco_formsemestre_custommenu
|
||||
from app.ScoDoc import sco_moduleimpl as sco_moduleimpl
|
||||
from app.ScoDoc import sco_moduleimpl_status as sco_moduleimpl_status
|
||||
from app.ScoDoc import sco_moduleimpl_inscriptions as sco_moduleimpl_inscriptions
|
||||
from app.ScoDoc import sco_evaluations as sco_evaluations
|
||||
from app.ScoDoc import sco_groups as sco_groups
|
||||
from app.ScoDoc import sco_edit_ue as sco_edit_ue
|
||||
from app.ScoDoc import sco_edit_formation as sco_edit_formation
|
||||
from app.ScoDoc import sco_edit_matiere as sco_edit_matiere
|
||||
from app.ScoDoc import sco_edit_module as sco_edit_module
|
||||
from app.ScoDoc import sco_tag_module as sco_tag_module
|
||||
from app.ScoDoc import sco_bulletins as sco_bulletins
|
||||
from app.ScoDoc import sco_bulletins_pdf as sco_bulletins_pdf
|
||||
from app.ScoDoc import sco_compute_moy as sco_compute_moy
|
||||
from app.ScoDoc import sco_recapcomplet as sco_recapcomplet
|
||||
from app.ScoDoc import sco_liste_notes as sco_liste_notes
|
||||
from app.ScoDoc import sco_saisie_notes as sco_saisie_notes
|
||||
from app.ScoDoc import sco_placement as sco_placement
|
||||
from app.ScoDoc import sco_undo_notes as sco_undo_notes
|
||||
from app.ScoDoc import sco_formations as sco_formations
|
||||
from app.ScoDoc import sco_report as sco_report
|
||||
from app.ScoDoc import sco_lycee as sco_lycee
|
||||
from app.ScoDoc import sco_poursuite_dut as sco_poursuite_dut
|
||||
from app.ScoDoc import pe_view as pe_view
|
||||
from app.ScoDoc import sco_debouche as sco_debouche
|
||||
from app.ScoDoc import sco_ue_external as sco_ue_external
|
||||
from app.ScoDoc import sco_cost_formation as sco_cost_formation
|
||||
from app.ScoDoc import sco_formsemestre_validation as sco_formsemestre_validation
|
||||
from app.ScoDoc import sco_parcours_dut as sco_parcours_dut
|
||||
from app.ScoDoc import sco_codes_parcours as sco_codes_parcours
|
||||
from app.ScoDoc import sco_pvjury as sco_pvjury
|
||||
from app.ScoDoc import sco_pvpdf as sco_pvpdf
|
||||
from app.ScoDoc import sco_prepajury as sco_prepajury
|
||||
from app.ScoDoc import sco_inscr_passage as sco_inscr_passage
|
||||
from app.ScoDoc import sco_synchro_etuds as sco_synchro_etuds
|
||||
from app.ScoDoc import sco_archives as sco_archives
|
||||
from app.ScoDoc import sco_apogee_csv as sco_apogee_csv
|
||||
from app.ScoDoc import sco_etape_apogee_view as sco_etape_apogee_view
|
||||
from app.ScoDoc import sco_apogee_compare as sco_apogee_compare
|
||||
from app.ScoDoc import sco_semset as sco_semset
|
||||
from app.ScoDoc import sco_export_results as sco_export_results
|
||||
from app.ScoDoc import sco_formsemestre_exterieurs as sco_formsemestre_exterieurs
|
||||
from app.scodoc import sco_formsemestre as sco_formsemestre
|
||||
from app.scodoc import sco_formsemestre_edit as sco_formsemestre_edit
|
||||
from app.scodoc import sco_formsemestre_status as sco_formsemestre_status
|
||||
from app.scodoc import sco_formsemestre_inscriptions as sco_formsemestre_inscriptions
|
||||
from app.scodoc import sco_formsemestre_custommenu as sco_formsemestre_custommenu
|
||||
from app.scodoc import sco_moduleimpl as sco_moduleimpl
|
||||
from app.scodoc import sco_moduleimpl_status as sco_moduleimpl_status
|
||||
from app.scodoc import sco_moduleimpl_inscriptions as sco_moduleimpl_inscriptions
|
||||
from app.scodoc import sco_evaluations as sco_evaluations
|
||||
from app.scodoc import sco_groups as sco_groups
|
||||
from app.scodoc import sco_edit_ue as sco_edit_ue
|
||||
from app.scodoc import sco_edit_formation as sco_edit_formation
|
||||
from app.scodoc import sco_edit_matiere as sco_edit_matiere
|
||||
from app.scodoc import sco_edit_module as sco_edit_module
|
||||
from app.scodoc import sco_tag_module as sco_tag_module
|
||||
from app.scodoc import sco_bulletins as sco_bulletins
|
||||
from app.scodoc import sco_bulletins_pdf as sco_bulletins_pdf
|
||||
from app.scodoc import sco_compute_moy as sco_compute_moy
|
||||
from app.scodoc import sco_recapcomplet as sco_recapcomplet
|
||||
from app.scodoc import sco_liste_notes as sco_liste_notes
|
||||
from app.scodoc import sco_saisie_notes as sco_saisie_notes
|
||||
from app.scodoc import sco_placement as sco_placement
|
||||
from app.scodoc import sco_undo_notes as sco_undo_notes
|
||||
from app.scodoc import sco_formations as sco_formations
|
||||
from app.scodoc import sco_report as sco_report
|
||||
from app.scodoc import sco_lycee as sco_lycee
|
||||
from app.scodoc import sco_poursuite_dut as sco_poursuite_dut
|
||||
from app.scodoc import pe_view as pe_view
|
||||
from app.scodoc import sco_debouche as sco_debouche
|
||||
from app.scodoc import sco_ue_external as sco_ue_external
|
||||
from app.scodoc import sco_cost_formation as sco_cost_formation
|
||||
from app.scodoc import sco_formsemestre_validation as sco_formsemestre_validation
|
||||
from app.scodoc import sco_parcours_dut as sco_parcours_dut
|
||||
from app.scodoc import sco_codes_parcours as sco_codes_parcours
|
||||
from app.scodoc import sco_pvjury as sco_pvjury
|
||||
from app.scodoc import sco_pvpdf as sco_pvpdf
|
||||
from app.scodoc import sco_prepajury as sco_prepajury
|
||||
from app.scodoc import sco_inscr_passage as sco_inscr_passage
|
||||
from app.scodoc import sco_synchro_etuds as sco_synchro_etuds
|
||||
from app.scodoc import sco_archives as sco_archives
|
||||
from app.scodoc import sco_apogee_csv as sco_apogee_csv
|
||||
from app.scodoc import sco_etape_apogee_view as sco_etape_apogee_view
|
||||
from app.scodoc import sco_apogee_compare as sco_apogee_compare
|
||||
from app.scodoc import sco_semset as sco_semset
|
||||
from app.scodoc import sco_export_results as sco_export_results
|
||||
from app.scodoc import sco_formsemestre_exterieurs as sco_formsemestre_exterieurs
|
||||
|
||||
from app.ScoDoc.sco_pdf import PDFLOCK
|
||||
from app.ScoDoc import notes_table as notes_table
|
||||
from app.ScoDoc.notes_table import NOTES_CACHE_INST, CacheNotesTable
|
||||
import app.ScoDoc.VERSION as VERSION
|
||||
from app.scodoc.sco_pdf import PDFLOCK
|
||||
from app.scodoc import notes_table as notes_table
|
||||
from app.scodoc.notes_table import NOTES_CACHE_INST, CacheNotesTable
|
||||
import app.scodoc.VERSION as VERSION
|
||||
|
||||
context = ScoDoc7Context(globals())
|
||||
|
||||
@ -136,9 +137,9 @@ def sco_publish(route, function, permission):
|
||||
"""Declare a route for a python function,
|
||||
protected by permission and called following ScoDoc 7 Zope standards.
|
||||
"""
|
||||
return bp.route(route)(
|
||||
permission_required(permission)(scodoc7func(context)(function))
|
||||
)
|
||||
# f =
|
||||
bp.route(route)(permission_required(permission)(scodoc7func(context)(function)))
|
||||
# setattr(sys.modules[__name__], f.__name__, f)
|
||||
|
||||
|
||||
# --------------------- Quelques essais élémentaires:
|
||||
@ -203,8 +204,8 @@ def _inval_cache(
|
||||
|
||||
|
||||
@bp.route("/clearcache")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def clearcache(context, REQUEST=None):
|
||||
"Efface les caches de notes (utile pendant developpement slt)"
|
||||
log("*** clearcache request")
|
||||
@ -257,13 +258,13 @@ sco_publish(
|
||||
|
||||
# controle d'acces specifique pour dir. etud:
|
||||
sco_publish(
|
||||
"formsemestre_editwithmodules",
|
||||
"/formsemestre_editwithmodules",
|
||||
sco_formsemestre_edit.formsemestre_editwithmodules,
|
||||
Permission.ScoView,
|
||||
)
|
||||
|
||||
sco_publish(
|
||||
"formsemestre_clone",
|
||||
"/formsemestre_clone",
|
||||
sco_formsemestre_edit.formsemestre_clone,
|
||||
Permission.ScoImplement,
|
||||
)
|
||||
@ -401,8 +402,8 @@ sco_publish(
|
||||
#
|
||||
@bp.route("/")
|
||||
@bp.route("/index_html")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def index_html(context, REQUEST=None):
|
||||
"Page accueil formations"
|
||||
|
||||
@ -454,8 +455,8 @@ _formationEditor = ndb.EditableTable(
|
||||
|
||||
|
||||
@bp.route("/do_formation_create")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoChangeFormation)
|
||||
@scodoc7func(context)
|
||||
def do_formation_create(context, args, REQUEST):
|
||||
"create a formation"
|
||||
cnx = context.GetDBConnexion()
|
||||
@ -483,8 +484,8 @@ def do_formation_create(context, args, REQUEST):
|
||||
|
||||
|
||||
@bp.route("/do_formation_delete")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoChangeFormation)
|
||||
@scodoc7func(context)
|
||||
def do_formation_delete(context, oid, REQUEST):
|
||||
"""delete a formation (and all its UE, matieres, modules)
|
||||
XXX delete all ues, will break if there are validations ! USE WITH CARE !
|
||||
@ -511,8 +512,8 @@ def do_formation_delete(context, oid, REQUEST):
|
||||
|
||||
|
||||
@bp.route("/formation_list")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formation_list(context, format=None, REQUEST=None, formation_id=None, args={}):
|
||||
"""List formation(s) with given id, or matching args
|
||||
(when args is given, formation_id is ignored).
|
||||
@ -530,8 +531,8 @@ def formation_list(context, format=None, REQUEST=None, formation_id=None, args={
|
||||
|
||||
|
||||
@bp.route("/formation_export")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formation_export(
|
||||
context, formation_id, export_ids=False, format=None, REQUEST=None
|
||||
):
|
||||
@ -542,8 +543,8 @@ def formation_export(
|
||||
|
||||
|
||||
@bp.route("/formation_import_xml")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoChangeFormation)
|
||||
@scodoc7func(context)
|
||||
def formation_import_xml(context, file, REQUEST):
|
||||
"import d'une formation en XML"
|
||||
log("formation_import_xml")
|
||||
@ -552,8 +553,8 @@ def formation_import_xml(context, file, REQUEST):
|
||||
|
||||
|
||||
@bp.route("/formation_import_xml_form")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoChangeFormation)
|
||||
@scodoc7func(context)
|
||||
def formation_import_xml_form(context, REQUEST):
|
||||
"form import d'une formation en XML"
|
||||
H = [
|
||||
@ -588,8 +589,8 @@ def formation_import_xml_form(context, REQUEST):
|
||||
|
||||
|
||||
@bp.route("/formation_create_new_version")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoChangeFormation)
|
||||
@scodoc7func(context)
|
||||
def formation_create_new_version(context, formation_id, redirect=True, REQUEST=None):
|
||||
"duplicate formation, with new version number"
|
||||
xml = sco_formations.formation_export(
|
||||
@ -643,8 +644,8 @@ _ueEditor = ndb.EditableTable(
|
||||
|
||||
|
||||
@bp.route("/do_ue_create")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoChangeFormation)
|
||||
@scodoc7func(context)
|
||||
def do_ue_create(context, args, REQUEST):
|
||||
"create an ue"
|
||||
cnx = context.GetDBConnexion()
|
||||
@ -738,8 +739,8 @@ def _do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=
|
||||
|
||||
|
||||
@bp.route("/do_ue_list")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def do_ue_list(context, *args, **kw):
|
||||
"list UEs"
|
||||
cnx = context.GetDBConnexion()
|
||||
@ -757,8 +758,8 @@ _matiereEditor = ndb.EditableTable(
|
||||
|
||||
|
||||
@bp.route("/do_matiere_create")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoChangeFormation)
|
||||
@scodoc7func(context)
|
||||
def do_matiere_create(context, args, REQUEST):
|
||||
"create a matiere"
|
||||
cnx = context.GetDBConnexion()
|
||||
@ -780,8 +781,8 @@ def do_matiere_create(context, args, REQUEST):
|
||||
|
||||
|
||||
@bp.route("/do_matiere_delete")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoChangeFormation)
|
||||
@scodoc7func(context)
|
||||
def do_matiere_delete(context, oid, REQUEST):
|
||||
"delete matiere and attached modules"
|
||||
cnx = context.GetDBConnexion()
|
||||
@ -813,8 +814,8 @@ def do_matiere_delete(context, oid, REQUEST):
|
||||
|
||||
|
||||
@bp.route("/do_matiere_list")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def do_matiere_list(context, *args, **kw):
|
||||
"list matieres"
|
||||
cnx = context.GetDBConnexion()
|
||||
@ -822,8 +823,8 @@ def do_matiere_list(context, *args, **kw):
|
||||
|
||||
|
||||
@bp.route("/do_matiere_edit")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoChangeFormation)
|
||||
@scodoc7func(context)
|
||||
def do_matiere_edit(context, *args, **kw):
|
||||
"edit a matiere"
|
||||
cnx = context.GetDBConnexion()
|
||||
@ -837,8 +838,8 @@ def do_matiere_edit(context, *args, **kw):
|
||||
|
||||
|
||||
@bp.route("/do_matiere_formation_id")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def do_matiere_formation_id(context, matiere_id):
|
||||
"get formation_id from matiere"
|
||||
cnx = context.GetDBConnexion()
|
||||
@ -887,8 +888,8 @@ _moduleEditor = ndb.EditableTable(
|
||||
|
||||
|
||||
@bp.route("/do_module_create")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoChangeFormation)
|
||||
@scodoc7func(context)
|
||||
def do_module_create(context, args, REQUEST):
|
||||
"create a module"
|
||||
# create
|
||||
@ -908,8 +909,8 @@ def do_module_create(context, args, REQUEST):
|
||||
|
||||
|
||||
@bp.route("/do_module_delete")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoChangeFormation)
|
||||
@scodoc7func(context)
|
||||
def do_module_delete(context, oid, REQUEST):
|
||||
"delete module"
|
||||
mod = context.do_module_list({"module_id": oid})[0]
|
||||
@ -943,8 +944,8 @@ def do_module_delete(context, oid, REQUEST):
|
||||
|
||||
|
||||
@bp.route("/do_module_list")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def do_module_list(context, *args, **kw):
|
||||
"list modules"
|
||||
cnx = context.GetDBConnexion()
|
||||
@ -952,8 +953,8 @@ def do_module_list(context, *args, **kw):
|
||||
|
||||
|
||||
@bp.route("/do_module_edit")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoChangeFormation)
|
||||
@scodoc7func(context)
|
||||
def do_module_edit(context, val):
|
||||
"edit a module"
|
||||
# check
|
||||
@ -979,8 +980,8 @@ def do_module_edit(context, val):
|
||||
|
||||
#
|
||||
@bp.route("/formation_has_locked_sems")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formation_has_locked_sems(context, formation_id):
|
||||
"True if there is a locked formsemestre in this formation"
|
||||
sems = sco_formsemestre.do_formsemestre_list(
|
||||
@ -990,8 +991,8 @@ def formation_has_locked_sems(context, formation_id):
|
||||
|
||||
|
||||
@bp.route("/formation_count_sems")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formation_count_sems(context, formation_id):
|
||||
"Number of formsemestre in this formation (locked or not)"
|
||||
sems = sco_formsemestre.do_formsemestre_list(
|
||||
@ -1001,8 +1002,8 @@ def formation_count_sems(context, formation_id):
|
||||
|
||||
|
||||
@bp.route("/module_count_moduleimpls")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def module_count_moduleimpls(context, module_id):
|
||||
"Number of moduleimpls using this module"
|
||||
mods = sco_moduleimpl.do_moduleimpl_list(context, module_id=module_id)
|
||||
@ -1010,8 +1011,8 @@ def module_count_moduleimpls(context, module_id):
|
||||
|
||||
|
||||
@bp.route("/module_is_locked")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def module_is_locked(context, module_id):
|
||||
"""True if UE should not be modified
|
||||
(used in a locked formsemestre)
|
||||
@ -1028,8 +1029,8 @@ def module_is_locked(context, module_id):
|
||||
|
||||
|
||||
@bp.route("/matiere_is_locked")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def matiere_is_locked(context, matiere_id):
|
||||
"""True if matiere should not be modified
|
||||
(contains modules used in a locked formsemestre)
|
||||
@ -1046,8 +1047,8 @@ def matiere_is_locked(context, matiere_id):
|
||||
|
||||
|
||||
@bp.route("/ue_is_locked")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def ue_is_locked(context, ue_id):
|
||||
"""True if module should not be modified
|
||||
(contains modules used in a locked formsemestre)
|
||||
@ -1065,8 +1066,8 @@ def ue_is_locked(context, ue_id):
|
||||
|
||||
|
||||
@bp.route("/module_move")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoChangeFormation)
|
||||
@scodoc7func(context)
|
||||
def module_move(context, module_id, after=0, REQUEST=None, redirect=1):
|
||||
"""Move before/after previous one (decrement/increment numero)"""
|
||||
module = context.do_module_list({"module_id": module_id})[0]
|
||||
@ -1101,8 +1102,8 @@ def module_move(context, module_id, after=0, REQUEST=None, redirect=1):
|
||||
|
||||
|
||||
@bp.route("/ue_move")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoChangeFormation)
|
||||
@scodoc7func(context)
|
||||
def ue_move(context, ue_id, after=0, REQUEST=None, redirect=1):
|
||||
"""Move UE before/after previous one (decrement/increment numero)"""
|
||||
o = context.do_ue_list({"ue_id": ue_id})[0]
|
||||
@ -1138,8 +1139,8 @@ def ue_move(context, ue_id, after=0, REQUEST=None, redirect=1):
|
||||
|
||||
|
||||
@bp.route("/do_formsemestre_create")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoImplement)
|
||||
@scodoc7func(context)
|
||||
def do_formsemestre_create(context, args, REQUEST, silent=False):
|
||||
"create a formsemestre"
|
||||
cnx = context.GetDBConnexion()
|
||||
@ -1176,8 +1177,8 @@ def do_formsemestre_create(context, args, REQUEST, silent=False):
|
||||
|
||||
|
||||
@bp.route("/formsemestre_list")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formsemestre_list(
|
||||
context,
|
||||
format=None,
|
||||
@ -1202,8 +1203,8 @@ def formsemestre_list(
|
||||
|
||||
|
||||
@bp.route("/XMLgetFormsemestres")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def XMLgetFormsemestres(context, etape_apo=None, formsemestre_id=None, REQUEST=None):
|
||||
"""List all formsemestres matching etape, XML format
|
||||
DEPRECATED: use formsemestre_list()
|
||||
@ -1282,8 +1283,8 @@ def _check_access_diretud(
|
||||
|
||||
|
||||
@bp.route("/formsemestre_custommenu_edit")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formsemestre_custommenu_edit(context, REQUEST, formsemestre_id):
|
||||
"Dialogue modif menu"
|
||||
# accessible à tous !
|
||||
@ -1300,8 +1301,8 @@ sco_publish(
|
||||
|
||||
|
||||
@bp.route("/html_sem_header")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def html_sem_header(
|
||||
context,
|
||||
REQUEST,
|
||||
@ -1326,8 +1327,8 @@ def html_sem_header(
|
||||
|
||||
# --- dialogue modif enseignants/moduleimpl
|
||||
@bp.route("/edit_enseignants_form")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def edit_enseignants_form(context, REQUEST, moduleimpl_id):
|
||||
"modif liste enseignants/moduleimpl"
|
||||
M, sem = sco_moduleimpl.can_change_ens(context, REQUEST, moduleimpl_id)
|
||||
@ -1434,8 +1435,8 @@ def edit_enseignants_form(context, REQUEST, moduleimpl_id):
|
||||
|
||||
|
||||
@bp.route("/edit_moduleimpl_resp")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def edit_moduleimpl_resp(context, REQUEST, moduleimpl_id):
|
||||
"""Changement d'un enseignant responsable de module
|
||||
Accessible par Admin et dir des etud si flag resp_can_change_ens
|
||||
@ -1543,8 +1544,8 @@ _expr_help = """<p class="help">Expérimental: formule de calcul de la moyenne %
|
||||
|
||||
|
||||
@bp.route("/edit_moduleimpl_expr")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def edit_moduleimpl_expr(context, REQUEST, moduleimpl_id):
|
||||
"""Edition formule calcul moyenne module
|
||||
Accessible par Admin, dir des etud et responsable module
|
||||
@ -1612,8 +1613,8 @@ def edit_moduleimpl_expr(context, REQUEST, moduleimpl_id):
|
||||
|
||||
|
||||
@bp.route("/view_module_abs")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def view_module_abs(context, REQUEST, moduleimpl_id, format="html"):
|
||||
"""Visualisation des absences a un module"""
|
||||
M = sco_moduleimpl.do_moduleimpl_withmodule_list(
|
||||
@ -1686,8 +1687,8 @@ def view_module_abs(context, REQUEST, moduleimpl_id, format="html"):
|
||||
|
||||
|
||||
@bp.route("/edit_ue_expr")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def edit_ue_expr(context, REQUEST, formsemestre_id, ue_id):
|
||||
"""Edition formule calcul moyenne UE"""
|
||||
# Check access
|
||||
@ -1757,8 +1758,8 @@ def edit_ue_expr(context, REQUEST, formsemestre_id, ue_id):
|
||||
|
||||
|
||||
@bp.route("/formsemestre_enseignants_list")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formsemestre_enseignants_list(context, REQUEST, formsemestre_id, format="html"):
|
||||
"""Liste les enseignants intervenants dans le semestre (resp. modules et chargés de TD)
|
||||
et indique les absences saisies par chacun.
|
||||
@ -1841,8 +1842,8 @@ def formsemestre_enseignants_list(context, REQUEST, formsemestre_id, format="htm
|
||||
|
||||
|
||||
@bp.route("/edit_enseignants_form_delete")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def edit_enseignants_form_delete(context, REQUEST, moduleimpl_id, ens_id):
|
||||
"remove ens"
|
||||
M, _ = sco_moduleimpl.can_change_ens(context, REQUEST, moduleimpl_id)
|
||||
@ -1870,8 +1871,8 @@ _formsemestre_inscriptionEditor = ndb.EditableTable(
|
||||
|
||||
|
||||
@bp.route("/do_formsemestre_inscription_create")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoEtudInscrit)
|
||||
@scodoc7func(context)
|
||||
def do_formsemestre_inscription_create(context, args, REQUEST, method=None):
|
||||
"create a formsemestre_inscription (and sco event)"
|
||||
cnx = context.GetDBConnexion()
|
||||
@ -1914,8 +1915,8 @@ def do_formsemestre_inscription_create(context, args, REQUEST, method=None):
|
||||
|
||||
|
||||
@bp.route("/do_formsemestre_inscription_delete")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoImplement)
|
||||
@scodoc7func(context)
|
||||
def do_formsemestre_inscription_delete(context, oid, formsemestre_id=None):
|
||||
"delete formsemestre_inscription"
|
||||
cnx = context.GetDBConnexion()
|
||||
@ -1927,8 +1928,8 @@ def do_formsemestre_inscription_delete(context, oid, formsemestre_id=None):
|
||||
|
||||
|
||||
@bp.route("/do_formsemestre_inscription_list")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def do_formsemestre_inscription_list(context, *args, **kw):
|
||||
"list formsemestre_inscriptions"
|
||||
cnx = context.GetDBConnexion()
|
||||
@ -1936,8 +1937,8 @@ def do_formsemestre_inscription_list(context, *args, **kw):
|
||||
|
||||
|
||||
@bp.route("/do_formsemestre_inscription_listinscrits")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def do_formsemestre_inscription_listinscrits(
|
||||
context, formsemestre_id, format=None, REQUEST=None
|
||||
):
|
||||
@ -1954,8 +1955,8 @@ def do_formsemestre_inscription_listinscrits(
|
||||
|
||||
|
||||
@bp.route("/do_formsemestre_inscription_edit")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoImplement)
|
||||
@scodoc7func(context)
|
||||
def do_formsemestre_inscription_edit(context, args=None, formsemestre_id=None):
|
||||
"edit a formsemestre_inscription"
|
||||
cnx = context.GetDBConnexion()
|
||||
@ -1977,8 +1978,8 @@ def get_formsemestre_inscription_cache(context, format=None):
|
||||
|
||||
|
||||
@bp.route("/formsemestre_desinscription")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoImplement)
|
||||
@scodoc7func(context)
|
||||
def formsemestre_desinscription(
|
||||
context, etudid, formsemestre_id, REQUEST=None, dialog_confirmed=False
|
||||
):
|
||||
@ -2055,8 +2056,8 @@ def formsemestre_desinscription(
|
||||
|
||||
|
||||
@bp.route("/do_formsemestre_desinscription")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoImplement)
|
||||
@scodoc7func(context)
|
||||
def do_formsemestre_desinscription(context, etudid, formsemestre_id, REQUEST=None):
|
||||
"""Désinscription d'un étudiant.
|
||||
Si semestre extérieur et dernier inscrit, suppression de ce semestre.
|
||||
@ -2123,8 +2124,8 @@ def do_formsemestre_desinscription(context, etudid, formsemestre_id, REQUEST=Non
|
||||
|
||||
|
||||
@bp.route("/etud_desinscrit_ue")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoEtudInscrit)
|
||||
@scodoc7func(context)
|
||||
def etud_desinscrit_ue(context, etudid, formsemestre_id, ue_id, REQUEST=None):
|
||||
"""Desinscrit l'etudiant de tous les modules de cette UE dans ce semestre."""
|
||||
sco_moduleimpl_inscriptions.do_etud_desinscrit_ue(
|
||||
@ -2138,8 +2139,8 @@ def etud_desinscrit_ue(context, etudid, formsemestre_id, ue_id, REQUEST=None):
|
||||
|
||||
|
||||
@bp.route("/etud_inscrit_ue")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoEtudInscrit)
|
||||
@scodoc7func(context)
|
||||
def etud_inscrit_ue(context, etudid, formsemestre_id, ue_id, REQUEST=None):
|
||||
"""Inscrit l'etudiant de tous les modules de cette UE dans ce semestre."""
|
||||
sco_moduleimpl_inscriptions.do_etud_inscrit_ue(
|
||||
@ -2257,8 +2258,8 @@ def _evaluation_check_write_access(context, REQUEST, moduleimpl_id=None):
|
||||
|
||||
|
||||
@bp.route("/do_evaluation_create")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoEnsView)
|
||||
@scodoc7func(context)
|
||||
def do_evaluation_create(
|
||||
context,
|
||||
moduleimpl_id=None,
|
||||
@ -2394,8 +2395,8 @@ def _check_evaluation_args(context, args):
|
||||
|
||||
|
||||
@bp.route("/evaluation_delete")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoEnsView)
|
||||
@scodoc7func(context)
|
||||
def evaluation_delete(context, REQUEST, evaluation_id):
|
||||
"""Form delete evaluation"""
|
||||
El = context.do_evaluation_list(args={"evaluation_id": evaluation_id})
|
||||
@ -2470,8 +2471,8 @@ def evaluation_delete(context, REQUEST, evaluation_id):
|
||||
|
||||
|
||||
@bp.route("/do_evaluation_list")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def do_evaluation_list(context, args, sortkey=None):
|
||||
"""List evaluations, sorted by numero (or most recent date first).
|
||||
|
||||
@ -2521,8 +2522,8 @@ def do_evaluation_list(context, args, sortkey=None):
|
||||
|
||||
|
||||
@bp.route("/do_evaluation_list_in_formsemestre")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def do_evaluation_list_in_formsemestre(context, formsemestre_id):
|
||||
"list evaluations in this formsemestre"
|
||||
mods = sco_moduleimpl.do_moduleimpl_list(context, formsemestre_id=formsemestre_id)
|
||||
@ -2535,8 +2536,8 @@ def do_evaluation_list_in_formsemestre(context, formsemestre_id):
|
||||
|
||||
|
||||
@bp.route("/do_evaluation_edit")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoEnsView)
|
||||
@scodoc7func(context)
|
||||
def do_evaluation_edit(context, REQUEST, args):
|
||||
"edit a evaluation"
|
||||
evaluation_id = args["evaluation_id"]
|
||||
@ -2557,8 +2558,8 @@ def do_evaluation_edit(context, REQUEST, args):
|
||||
|
||||
|
||||
@bp.route("/evaluation_edit")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoEnsView)
|
||||
@scodoc7func(context)
|
||||
def evaluation_edit(context, evaluation_id, REQUEST):
|
||||
"form edit evaluation"
|
||||
return sco_evaluations.evaluation_create_form(
|
||||
@ -2567,8 +2568,8 @@ def evaluation_edit(context, evaluation_id, REQUEST):
|
||||
|
||||
|
||||
@bp.route("/evaluation_create")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoEnsView)
|
||||
@scodoc7func(context)
|
||||
def evaluation_create(context, moduleimpl_id, REQUEST):
|
||||
"form create evaluation"
|
||||
return sco_evaluations.evaluation_create_form(
|
||||
@ -2577,8 +2578,8 @@ def evaluation_create(context, moduleimpl_id, REQUEST):
|
||||
|
||||
|
||||
@bp.route("/evaluation_listenotes")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def evaluation_listenotes(context, REQUEST=None):
|
||||
"""Affichage des notes d'une évaluation"""
|
||||
if REQUEST.form.get("format", "html") == "html":
|
||||
@ -2701,8 +2702,8 @@ def _notes_getall(
|
||||
|
||||
# --- Bulletins
|
||||
@bp.route("/formsemestre_bulletins_pdf")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formsemestre_bulletins_pdf(
|
||||
context, formsemestre_id, REQUEST, version="selectedevals"
|
||||
):
|
||||
@ -2714,8 +2715,8 @@ def formsemestre_bulletins_pdf(
|
||||
|
||||
|
||||
@bp.route("/etud_bulletins_pdf")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def etud_bulletins_pdf(context, etudid, REQUEST, version="selectedevals"):
|
||||
"Publie tous les bulletins d'un etudiants dans un classeur PDF"
|
||||
pdfdoc, filename = sco_bulletins_pdf.get_etud_bulletins_pdf(
|
||||
@ -2737,8 +2738,8 @@ sco_publish(
|
||||
|
||||
|
||||
@bp.route("/formsemestre_bulletins_mailetuds")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formsemestre_bulletins_mailetuds(
|
||||
context,
|
||||
formsemestre_id,
|
||||
@ -2802,8 +2803,8 @@ sco_publish(
|
||||
|
||||
|
||||
@bp.route("/appreciation_add_form")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoEnsView)
|
||||
@scodoc7func(context)
|
||||
def appreciation_add_form(
|
||||
context,
|
||||
etudid=None,
|
||||
@ -2946,8 +2947,8 @@ def _is_chef_or_diretud(context, REQUEST, sem):
|
||||
|
||||
|
||||
@bp.route("/formsemestre_validation_etud_form")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formsemestre_validation_etud_form(
|
||||
context,
|
||||
formsemestre_id,
|
||||
@ -2974,8 +2975,8 @@ def formsemestre_validation_etud_form(
|
||||
|
||||
|
||||
@bp.route("/formsemestre_validation_etud")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formsemestre_validation_etud(
|
||||
context,
|
||||
formsemestre_id,
|
||||
@ -3006,8 +3007,8 @@ def formsemestre_validation_etud(
|
||||
|
||||
|
||||
@bp.route("/formsemestre_validation_etud_manu")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formsemestre_validation_etud_manu(
|
||||
context,
|
||||
formsemestre_id,
|
||||
@ -3044,8 +3045,8 @@ def formsemestre_validation_etud_manu(
|
||||
|
||||
|
||||
@bp.route("/formsemestre_validate_previous_ue")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formsemestre_validate_previous_ue(
|
||||
context, formsemestre_id, etudid=None, REQUEST=None
|
||||
):
|
||||
@ -3070,8 +3071,8 @@ sco_publish(
|
||||
|
||||
|
||||
@bp.route("/formsemestre_ext_edit_ue_validations")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formsemestre_ext_edit_ue_validations(
|
||||
context, formsemestre_id, etudid=None, REQUEST=None
|
||||
):
|
||||
@ -3096,8 +3097,8 @@ sco_publish(
|
||||
|
||||
|
||||
@bp.route("/etud_ue_suppress_validation")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def etud_ue_suppress_validation(context, etudid, formsemestre_id, ue_id, REQUEST=None):
|
||||
"""Suppress a validation (ue_id, etudid) and redirect to formsemestre"""
|
||||
if not context._can_validate_sem(REQUEST, formsemestre_id):
|
||||
@ -3113,8 +3114,8 @@ def etud_ue_suppress_validation(context, etudid, formsemestre_id, ue_id, REQUEST
|
||||
|
||||
|
||||
@bp.route("/formsemestre_validation_auto")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formsemestre_validation_auto(context, formsemestre_id, REQUEST):
|
||||
"Formulaire saisie automatisee des decisions d'un semestre"
|
||||
if not context._can_validate_sem(REQUEST, formsemestre_id):
|
||||
@ -3131,8 +3132,8 @@ def formsemestre_validation_auto(context, formsemestre_id, REQUEST):
|
||||
|
||||
|
||||
@bp.route("/do_formsemestre_validation_auto")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def do_formsemestre_validation_auto(context, formsemestre_id, REQUEST):
|
||||
"Formulaire saisie automatisee des decisions d'un semestre"
|
||||
if not context._can_validate_sem(REQUEST, formsemestre_id):
|
||||
@ -3149,8 +3150,8 @@ def do_formsemestre_validation_auto(context, formsemestre_id, REQUEST):
|
||||
|
||||
|
||||
@bp.route("/formsemestre_fix_validation_ues")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formsemestre_fix_validation_ues(context, formsemestre_id, REQUEST=None):
|
||||
"Verif/reparation codes UE"
|
||||
if not context._can_validate_sem(REQUEST, formsemestre_id):
|
||||
@ -3167,8 +3168,8 @@ def formsemestre_fix_validation_ues(context, formsemestre_id, REQUEST=None):
|
||||
|
||||
|
||||
@bp.route("/formsemestre_validation_suppress_etud")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formsemestre_validation_suppress_etud(
|
||||
context, formsemestre_id, etudid, REQUEST=None, dialog_confirmed=False
|
||||
):
|
||||
@ -3376,8 +3377,8 @@ sco_publish(
|
||||
|
||||
|
||||
@bp.route("/check_sem_integrity")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def check_sem_integrity(context, formsemestre_id, REQUEST):
|
||||
"""Debug.
|
||||
Check that ue and module formations are consistents
|
||||
@ -3412,8 +3413,8 @@ def check_sem_integrity(context, formsemestre_id, REQUEST):
|
||||
|
||||
|
||||
@bp.route("/check_form_integrity")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def check_form_integrity(context, formation_id, fix=False, REQUEST=None):
|
||||
"debug"
|
||||
log("check_form_integrity: formation_id=%s fix=%s" % (formation_id, fix))
|
||||
@ -3449,8 +3450,8 @@ def check_form_integrity(context, formation_id, fix=False, REQUEST=None):
|
||||
|
||||
|
||||
@bp.route("/check_formsemestre_integrity")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def check_formsemestre_integrity(context, formsemestre_id, REQUEST=None):
|
||||
"debug"
|
||||
log("check_formsemestre_integrity: formsemestre_id=%s" % (formsemestre_id))
|
||||
@ -3501,8 +3502,8 @@ def check_formsemestre_integrity(context, formsemestre_id, REQUEST=None):
|
||||
|
||||
|
||||
@bp.route("/check_integrity_all")
|
||||
@scodoc7func(context)
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def check_integrity_all(context, REQUEST=None):
|
||||
"debug: verifie tous les semestres et tt les formations"
|
||||
# formations
|
||||
|
107
refactor.py
Normal file
107
refactor.py
Normal file
@ -0,0 +1,107 @@
|
||||
# -*- coding: UTF-8 -*
|
||||
|
||||
|
||||
"""Outil pour migration ScoDoc 7 => ScoDoc 8
|
||||
|
||||
Pour chaque module dans views:
|
||||
- construire la liste des fonctions définies dans ce module:
|
||||
get_module_functions
|
||||
|
||||
Pour chaque module dans views et dans scodoc:
|
||||
- remplacer context.xxx par app.views.M.xxx
|
||||
où M est le module de views définissant xxx
|
||||
Si xxx n'est pas trouvé, erreur !
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
import re
|
||||
|
||||
from pprint import pprint as pp
|
||||
import sys
|
||||
import types
|
||||
|
||||
import click
|
||||
import flask
|
||||
|
||||
import app
|
||||
from app import create_app, cli, db
|
||||
from app.auth.models import User, Role, UserRole
|
||||
|
||||
from config import Config
|
||||
|
||||
from app.views import notes
|
||||
|
||||
TYPES_TO_SCAN = {
|
||||
types.FunctionType,
|
||||
# types.ClassType,
|
||||
# types.DictionaryType,
|
||||
# types.FloatType,
|
||||
# types.IntType,
|
||||
# types.ListType,
|
||||
# types.StringType,
|
||||
# types.TupleType,
|
||||
}
|
||||
|
||||
|
||||
def get_module_symbols(module):
|
||||
"""returns list of symbols (functions and constants) defined in the given module"""
|
||||
return [
|
||||
f.__name__
|
||||
for f in [getattr(module, name) for name in dir(module)]
|
||||
if (type(f) in TYPES_TO_SCAN)
|
||||
and ((type(f) != types.FunctionType) or (f.__module__ == module.__name__))
|
||||
]
|
||||
|
||||
|
||||
# print("\n".join(f.__name__ for f in get_module_functions(notes)))
|
||||
|
||||
|
||||
def scan_views_symbols():
|
||||
"""Scan modules in app.views and returns
|
||||
{ }
|
||||
"""
|
||||
views_modules = [
|
||||
getattr(app.views, mod_name)
|
||||
for mod_name in dir(app.views)
|
||||
if type(getattr(app.views, mod_name)) == types.ModuleType
|
||||
]
|
||||
sym2mod = {} # symbole_name : module
|
||||
for module in views_modules:
|
||||
start = "app.views."
|
||||
assert module.__name__.startswith(start)
|
||||
module_name = module.__name__[len(start) :]
|
||||
symbols = set(get_module_symbols(module))
|
||||
print("%d symbols defined in %s" % (len(symbols), module))
|
||||
dups = symbols.intersection(sym2mod)
|
||||
if len(dups):
|
||||
print("duplicated symbols !")
|
||||
for dup in dups:
|
||||
print("%s:\t%s\t%s" % (dup, sym2mod[dup], module_name))
|
||||
|
||||
sym2mod.update({s: module_name for s in symbols})
|
||||
return sym2mod
|
||||
|
||||
|
||||
def replace_context_calls(sourcefilename, sym2mod):
|
||||
undefined_list = [] # noms de fonctions non présents dans les modules "views"
|
||||
|
||||
def repl(m):
|
||||
funcname = m.group(1)
|
||||
module = sym2mod.get(funcname, False)
|
||||
if module:
|
||||
return module + "." + funcname
|
||||
else:
|
||||
undefined_list.append((sourcefilename, funcname))
|
||||
return m.group(0) # leave unchanged
|
||||
|
||||
print("reading %s" % sourcefilename)
|
||||
source = open(sourcefilename).read()
|
||||
exp = re.compile(r"context\.([a-zA-Z0-9_]+)")
|
||||
source2 = exp.sub(repl, source)
|
||||
return source2, undefined_list
|
||||
|
||||
|
||||
sym2mod = scan_views_symbols()
|
||||
|
||||
source2, undefined_list = replace_context_calls("app/scodoc/sco_core.py", sym2mod)
|
Loading…
Reference in New Issue
Block a user