Feuille CSS pour couleurs UEs

This commit is contained in:
Emmanuel Viennet 2022-02-12 14:59:18 +01:00
parent 0383b82597
commit 718dbd8801
2 changed files with 32 additions and 2 deletions

View File

@ -35,7 +35,15 @@ import io
import re import re
import flask 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 from flask import request
import flask_login import flask_login
from flask_login.utils import login_required, current_user 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 departements
from app.models import FormSemestre, FormSemestreInscription from app.models import FormSemestre, FormSemestreInscription
from app.models import ScoDocSiteConfig from app.models import ScoDocSiteConfig
from app.models import UniteEns
from app.scodoc import sco_codes_parcours, sco_logos from app.scodoc import sco_codes_parcours, sco_logos
from app.scodoc import sco_find_etud from app.scodoc import sco_find_etud
from app.scodoc import sco_utils as scu 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/<int:formation_id>/<int:semestre_idx>")
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 # essais
# @bp.route("/testlog") # @bp.route("/testlog")
# def testlog(): # def testlog():

View File

@ -35,7 +35,7 @@ import time
import flask import flask
from flask import jsonify, url_for, flash, render_template, make_response 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_login import current_user
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileAllowed from flask_wtf.file import FileField, FileAllowed