forked from ScoDoc/ScoDoc
Améliore page erreur 403 (permission refusée)
This commit is contained in:
parent
d980c6794a
commit
fdd7af6a8a
@ -25,7 +25,12 @@ from flask_moment import Moment
|
||||
from flask_caching import Cache
|
||||
import sqlalchemy
|
||||
|
||||
from app.scodoc.sco_exceptions import ScoGenError, ScoValueError, APIInvalidParams
|
||||
from app.scodoc.sco_exceptions import (
|
||||
AccessDenied,
|
||||
ScoGenError,
|
||||
ScoValueError,
|
||||
APIInvalidParams,
|
||||
)
|
||||
from config import DevConfig
|
||||
import sco_version
|
||||
|
||||
@ -51,6 +56,10 @@ def handle_sco_value_error(exc):
|
||||
return render_template("sco_value_error.html", exc=exc), 404
|
||||
|
||||
|
||||
def handle_access_denied(exc):
|
||||
return render_template("error_access_denied.html", exc=exc), 403
|
||||
|
||||
|
||||
def internal_server_error(e):
|
||||
"""Bugs scodoc, erreurs 500"""
|
||||
# note that we set the 500 status explicitly
|
||||
@ -181,6 +190,7 @@ def create_app(config_class=DevConfig):
|
||||
|
||||
app.register_error_handler(ScoGenError, handle_sco_value_error)
|
||||
app.register_error_handler(ScoValueError, handle_sco_value_error)
|
||||
app.register_error_handler(AccessDenied, handle_access_denied)
|
||||
app.register_error_handler(500, internal_server_error)
|
||||
app.register_error_handler(503, postgresql_server_error)
|
||||
app.register_error_handler(APIInvalidParams, handle_invalid_usage)
|
||||
|
@ -45,10 +45,6 @@ class InvalidEtudId(NoteProcessError):
|
||||
pass
|
||||
|
||||
|
||||
class AccessDenied(ScoException):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidNoteValue(ScoException):
|
||||
pass
|
||||
|
||||
@ -92,6 +88,10 @@ class ScoGenError(ScoException):
|
||||
ScoException.__init__(self, msg)
|
||||
|
||||
|
||||
class AccessDenied(ScoGenError):
|
||||
pass
|
||||
|
||||
|
||||
class ScoInvalidDateError(ScoValueError):
|
||||
pass
|
||||
|
||||
|
@ -109,8 +109,11 @@ def import_excel_file(datafile):
|
||||
if not exceldata:
|
||||
raise ScoValueError("Ficher excel vide ou invalide")
|
||||
_, data = sco_excel.excel_bytes_to_list(exceldata)
|
||||
if not data: # probably a bug
|
||||
raise ScoException("import_excel_file: empty file !")
|
||||
if not data:
|
||||
raise ScoValueError(
|
||||
"""Le fichier xlsx attendu semble vide !
|
||||
"""
|
||||
)
|
||||
# 1- --- check title line
|
||||
fs = [scu.stripquotes(s).lower() for s in data[0]]
|
||||
log("excel: fs='%s'\ndata=%s" % (str(fs), str(data)))
|
||||
|
@ -61,6 +61,7 @@ from app.decorators import (
|
||||
scodoc,
|
||||
permission_required_compat_scodoc7,
|
||||
)
|
||||
from app.scodoc.sco_exceptions import AccessDenied
|
||||
from app.scodoc.sco_permissions import Permission
|
||||
from app.views import scodoc_bp as bp
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- mode: python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
SCOVERSION = "9.0.51"
|
||||
SCOVERSION = "9.0.52"
|
||||
|
||||
SCONAME = "ScoDoc"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user