forked from ScoDoc/DocScoDoc
62 lines
1.5 KiB
Python
62 lines
1.5 KiB
Python
# -*- coding: UTF-8 -*
|
|
"""Module scodoc: un exemple de fonctions
|
|
"""
|
|
from flask import g
|
|
from flask import current_app
|
|
|
|
from app.decorators import (
|
|
scodoc7func,
|
|
ScoDoc7Context,
|
|
permission_required,
|
|
admin_required,
|
|
login_required,
|
|
)
|
|
from app.auth.models import Permission
|
|
|
|
from app.views import notes_bp as bp
|
|
|
|
# import sco_core deviendra:
|
|
from app.ScoDoc import sco_core
|
|
|
|
context = ScoDoc7Context(globals())
|
|
|
|
|
|
@bp.route("/<scodoc_dept>/Scolarite/sco_exemple")
|
|
@scodoc7func
|
|
def sco_exemple(etudid="NON"):
|
|
"""Un exemple de fonction ScoDoc 7"""
|
|
return """<html>
|
|
<body><h1>ScoDoc 7 rules !</h1>
|
|
<p>etudid=%(etudid)s</p>
|
|
<p>g.scodoc_dept=%(scodoc_dept)s</p>
|
|
</body>
|
|
</html>
|
|
""" % {
|
|
"etudid": etudid,
|
|
"scodoc_dept": g.scodoc_dept,
|
|
}
|
|
|
|
|
|
# En ScoDoc 7, on a souvent des vues qui en appellent d'autres
|
|
# avec context.sco_exemple( etudid="E12" )
|
|
@bp.route("/<scodoc_dept>/Scolarite/sco_exemple2")
|
|
@login_required
|
|
@scodoc7func
|
|
def sco_exemple2():
|
|
return "Exemple 2" + context.sco_exemple(etudid="deux")
|
|
|
|
|
|
# Test avec un seul argument REQUEST positionnel
|
|
@bp.route("/<scodoc_dept>/Scolarite/sco_get_version")
|
|
@scodoc7func
|
|
def sco_get_version(REQUEST):
|
|
return sco_core.sco_get_version(REQUEST)
|
|
|
|
|
|
# Fonction ressemblant à une méthode Zope protégée
|
|
@bp.route("/<scodoc_dept>/Scolarite/sco_test_view")
|
|
@scodoc7func
|
|
@permission_required(Permission.ScoView)
|
|
def sco_test_view(REQUEST=None):
|
|
return """Vous avez vu sco_test_view !"""
|