From 718dbd88011071144da00d415f6966502569b43e Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sat, 12 Feb 2022 14:59:18 +0100 Subject: [PATCH] Feuille CSS pour couleurs UEs --- app/views/scodoc.py | 32 +++++++++++++++++++++++++++++++- app/views/scolar.py | 2 +- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/app/views/scodoc.py b/app/views/scodoc.py index 4867ecd6..b3ed1aa1 100644 --- a/app/views/scodoc.py +++ b/app/views/scodoc.py @@ -35,7 +35,15 @@ import io import re import flask -from flask import abort, flash, url_for, redirect, render_template, send_file +from flask import ( + abort, + flash, + make_response, + redirect, + render_template, + send_file, + url_for, +) from flask import request import flask_login from flask_login.utils import login_required, current_user @@ -54,6 +62,7 @@ from app.models import Departement, Identite from app.models import departements from app.models import FormSemestre, FormSemestreInscription from app.models import ScoDocSiteConfig +from app.models import UniteEns from app.scodoc import sco_codes_parcours, sco_logos from app.scodoc import sco_find_etud from app.scodoc import sco_utils as scu @@ -354,6 +363,27 @@ def get_logo(name: str, dept_id: int): ) +# --- +@bp.route("/ScoDoc/ue_colors_css//") +def ue_colors_css(formation_id: int, semestre_idx: int): + """Feuille de style pour les couleurs d'UE""" + ues = UniteEns.query.filter_by(formation_id=formation_id, semestre_idx=semestre_idx) + txt = ( + ":root{\n" + + "\n".join( + [ + f"--color-UE{semestre_idx}.{ue_idx+1}: {ue.color}" + for ue_idx, ue in enumerate(ues) + if ue.color + ] + ) + + "\n}\n" + ) + response = make_response(txt) + response.headers["Content-Type"] = "text/css" + return response + + # essais # @bp.route("/testlog") # def testlog(): diff --git a/app/views/scolar.py b/app/views/scolar.py index 7ec555d2..060fd4c3 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -35,7 +35,7 @@ import time import flask from flask import jsonify, url_for, flash, render_template, make_response -from flask import current_app, g, request +from flask import g, request from flask_login import current_user from flask_wtf import FlaskForm from flask_wtf.file import FileField, FileAllowed