diff --git a/app/auth/cas.py b/app/auth/cas.py index 2f231d2ad..01b6c10f9 100644 --- a/app/auth/cas.py +++ b/app/auth/cas.py @@ -85,6 +85,13 @@ def set_cas_configuration(app: flask.app.Flask = None): if ScoDocSiteConfig.is_cas_enabled(): current_app.logger.debug("CAS: set_cas_configuration") app.config["CAS_SERVER"] = ScoDocSiteConfig.get("cas_server") + app.config["CAS_LOGIN_ROUTE"] = ScoDocSiteConfig.get("cas_login_route", "/cas") + app.config["CAS_LOGOUT_ROUTE"] = ScoDocSiteConfig.get( + "cas_logout_route", "/cas/logout" + ) + app.config["CAS_VALIDATE_ROUTE"] = ScoDocSiteConfig.get( + "cas_validate_route", "/cas/serviceValidate" + ) app.config["CAS_AFTER_LOGIN"] = "auth.after_cas_login" app.config["CAS_AFTER_LOGOUT"] = "auth.after_cas_logout" app.config["CAS_ERROR_CALLBACK"] = cas_error_callback diff --git a/app/forms/main/config_cas.py b/app/forms/main/config_cas.py index 5b6020b84..0c6baac4a 100644 --- a/app/forms/main/config_cas.py +++ b/app/forms/main/config_cas.py @@ -45,6 +45,21 @@ class ConfigCASForm(FlaskForm): label="URL du serveur CAS", description="""url complète. Commence en général par https://.""", ) + cas_login_route = StringField( + label="Route du login CAS", + description="""ajouté à l'URL du serveur: exemple /cas (si commence par /, part de la racine)""", + default="/cas", + ) + cas_logout_route = StringField( + label="Route du logout CAS", + description="""ajouté à l'URL du serveur: exemple /cas/logout""", + default="/cas/logout", + ) + cas_validate_route = StringField( + label="Route de validation CAS", + description="""ajouté à l'URL du serveur: exemple /cas/serviceValidate""", + default="/cas/serviceValidate", + ) cas_attribute_id = StringField( label="Attribut CAS utilisé comme id (laissez vide pour prendre l'id par défaut)", diff --git a/app/models/config.py b/app/models/config.py index de46f95b7..09699cf74 100644 --- a/app/models/config.py +++ b/app/models/config.py @@ -90,6 +90,9 @@ class ScoDocSiteConfig(db.Model): # CAS "cas_enable": bool, "cas_server": str, + "cas_login_route": str, + "cas_logout_route": str, + "cas_valmidate_route": str, "cas_attribute_id": str, } @@ -237,10 +240,12 @@ class ScoDocSiteConfig(db.Model): return False @classmethod - def get(cls, name: str) -> str: - "Get configuration param; empty string if unset" + def get(cls, name: str, default: str = "") -> str: + "Get configuration param; empty string or specified default if unset" cfg = ScoDocSiteConfig.query.filter_by(name=name).first() - return (cfg.value or "") if cfg else "" + if cfg is None: + return default + return cfg.value or "" @classmethod def set(cls, name: str, value: str) -> bool: diff --git a/app/views/scodoc.py b/app/views/scodoc.py index f298026aa..915287f0e 100644 --- a/app/views/scodoc.py +++ b/app/views/scodoc.py @@ -150,6 +150,12 @@ def config_cas(): flash("CAS " + ("forcé" if form.data["cas_force"] else "non forcé")) if ScoDocSiteConfig.set("cas_server", form.data["cas_server"]): flash("Serveur CAS enregistré") + if ScoDocSiteConfig.set("cas_login_route", form.data["cas_login_route"]): + flash("Serveur CAS enregistré") + if ScoDocSiteConfig.set("cas_logout_route", form.data["cas_logout_route"]): + flash("Serveur CAS enregistré") + if ScoDocSiteConfig.set("cas_validate_route", form.data["cas_validate_route"]): + flash("Serveur CAS enregistré") if ScoDocSiteConfig.set("cas_attribute_id", form.data["cas_attribute_id"]): flash("Serveur CAS enregistré") if ScoDocSiteConfig.set("cas_ssl_verify", form.data["cas_ssl_verify"]): diff --git a/app/views/scolar.py b/app/views/scolar.py index 03e158c4c..620066169 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -928,6 +928,31 @@ def partition_editor(formsemestre_id: int): return "\n".join(H) +# Future page pour répartition parcours +@bp.route("/students_groups_auto_assignment", methods=["GET", "POST"]) +@scodoc +@permission_required(Permission.ScoView) +@scodoc7func +def students_groups_auto_assignment(formsemestre_id: int): + """En cours de dev.""" + formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id) + H = [ + html_sco_header.sco_header( + page_title=f"DEV", + ), + f"""