forked from ScoDoc/ScoDoc
wip
This commit is contained in:
parent
e56a97eaf6
commit
3f01048f59
@ -16,6 +16,16 @@
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro render_logo(logo, logo_field) %}
|
||||
<div class="configuration_logo">
|
||||
<h3>{{ logo.titre }}</h3>
|
||||
<p class="help">{{ logo.description }}</p>
|
||||
<div class="img-container"><img src="{{ logo.source }}"
|
||||
alt="pas de logo chargé" /></div>
|
||||
{{ render_field(logo_field) }}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% block app_content %}
|
||||
|
||||
{% if scodoc_dept %}
|
||||
@ -34,20 +44,23 @@
|
||||
{% endif %}
|
||||
|
||||
<div class="configuration_logo">
|
||||
<h3>Logo en-tête</h3>
|
||||
<p class="help">image placée en haut de certains documents documents PDF. Image actuelle:</p>
|
||||
<div class="img-container"><img src="{{ url_for('scodoc.logo_header', scodoc_dept=scodoc_dept) }}"
|
||||
alt="pas de logo chargé" /></div>
|
||||
{{ render_field(form.logo_header) }}
|
||||
<h3>Logo pied de page</h3>
|
||||
<p class="help">image placée en pied de page de certains documents documents PDF. Image actuelle:</p>
|
||||
<div class="img-container"><img src="{{ url_for('scodoc.logo_footer', scodoc_dept=g.scodoc_dept) }}"
|
||||
alt="pas de logo chargé" /></div>
|
||||
{{ render_field(form.logo_footer) }}
|
||||
{{ render_logo(logo, form.header) }}
|
||||
{{ render_logo(logo, form.footer) }}
|
||||
</div>
|
||||
|
||||
<div class="sco-submit">{{ form.submit() }}</div>
|
||||
{# <h3>Logo en-tête</h3>#}
|
||||
{# <p class="help">image placée en haut de certains documents documents PDF. Image actuelle:</p>#}
|
||||
{# <div class="img-container"><img src="{{ url_for('scodoc.logo_header', scodoc_dept=scodoc_dept) }}"#}
|
||||
{# alt="pas de logo chargé" /></div>#}
|
||||
{# {{ render_field(form.logo_header) }}#}
|
||||
{# <h3>Logo pied de page</h3>#}
|
||||
{# <p class="help">image placée en pied de page de certains documents documents PDF. Image actuelle:</p>#}
|
||||
{# <div class="img-container"><img src="{{ url_for('scodoc.logo_footer', scodoc_dept=g.scodoc_dept) }}"#}
|
||||
{# alt="pas de logo chargé" /></div>#}
|
||||
{# {{ render_field(form.logo_footer) }}#}
|
||||
<!-- <div class="sco_help">Les paramètres ci-dessous peuvent être changés dans chaque département
|
||||
(paramétrage).<br />On indique ici les valeurs initiales par défaut:
|
||||
</div> -->
|
||||
<div class="sco-submit">{{ form.submit() }}</div>
|
||||
</form>
|
||||
{% endblock %}
|
@ -176,6 +176,28 @@ def about(scodoc_dept=None):
|
||||
# ---- CONFIGURATION
|
||||
|
||||
|
||||
class Logo:
|
||||
def __init__(self, name, titre, description, source, form):
|
||||
self.titre = titre,
|
||||
self.description = description
|
||||
self.source = source
|
||||
unbound = FileField(
|
||||
name,
|
||||
label="Modifier l'image:",
|
||||
description=description,
|
||||
validators=[
|
||||
FileAllowed(
|
||||
scu.LOGOS_IMAGES_ALLOWED_TYPES,
|
||||
f"n'accepte que les fichiers image <tt>{','.join([e for e in scu.LOGOS_IMAGES_ALLOWED_TYPES])}</tt>",
|
||||
),
|
||||
],
|
||||
)
|
||||
self.field = form.Meta.bind_field(
|
||||
form=form,
|
||||
unbound_field=unbound,
|
||||
options={},
|
||||
)
|
||||
|
||||
class ScoDocConfigurationForm(FlaskForm):
|
||||
"Panneau de configuration général"
|
||||
|
||||
@ -187,30 +209,34 @@ class ScoDocConfigurationForm(FlaskForm):
|
||||
],
|
||||
)
|
||||
|
||||
logo_header = FileField(
|
||||
label="Modifier l'image:",
|
||||
description="logo placé en haut des documents PDF",
|
||||
validators=[
|
||||
FileAllowed(
|
||||
scu.LOGOS_IMAGES_ALLOWED_TYPES,
|
||||
f"n'accepte que les fichiers image <tt>{','.join([e for e in scu.LOGOS_IMAGES_ALLOWED_TYPES])}</tt>",
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
logo_footer = FileField(
|
||||
label="Modifier l'image:",
|
||||
description="logo placé en pied des documents PDF",
|
||||
validators=[
|
||||
FileAllowed(
|
||||
scu.LOGOS_IMAGES_ALLOWED_TYPES,
|
||||
f"n'accepte que les fichiers image <tt>{','.join([e for e in scu.LOGOS_IMAGES_ALLOWED_TYPES])}</tt>",
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
# logo_header = FileField(
|
||||
# label="Modifier l'image:",
|
||||
# description="logo placé en haut des documents PDF",
|
||||
# validators=[
|
||||
# FileAllowed(
|
||||
# scu.LOGOS_IMAGES_ALLOWED_TYPES,
|
||||
# f"n'accepte que les fichiers image <tt>{','.join([e for e in scu.LOGOS_IMAGES_ALLOWED_TYPES])}</tt>",
|
||||
# )
|
||||
# ],
|
||||
# )
|
||||
#
|
||||
# logo_footer = FileField(
|
||||
# label="Modifier l'image:",
|
||||
# description="logo placé en pied des documents PDF",
|
||||
# validators=[
|
||||
# FileAllowed(
|
||||
# scu.LOGOS_IMAGES_ALLOWED_TYPES,
|
||||
# f"n'accepte que les fichiers image <tt>{','.join([e for e in scu.LOGOS_IMAGES_ALLOWED_TYPES])}</tt>",
|
||||
# )
|
||||
# ],
|
||||
# )
|
||||
submit = SubmitField("Enregistrer")
|
||||
|
||||
def __init__(self, *args, scodoc_dept=None, **kwargs):
|
||||
breakpoint()
|
||||
super().__init__(*args, **kwargs)
|
||||
self.header = Logo(name='header', titre="Logo en-tête", description="logo placé en haut des documents PDF", source=url_for('scodoc.logo_header', scodoc_dept=None), form=self)
|
||||
self.footer = Logo(name='footer', titre="Logo en-tête", description="logo placé en pied des documents PDF", source=url_for('scodoc.logo_footer', scodoc_dept=None), form=self)
|
||||
|
||||
# Notes pour variables config: (valeurs par défaut des paramètres de département)
|
||||
# Chaines simples
|
||||
@ -239,13 +265,13 @@ def configuration():
|
||||
)
|
||||
if form.validate_on_submit():
|
||||
ScoDocSiteConfig.set_bonus_sport_func(form.bonus_sport_func_name.data)
|
||||
if form.logo_header.data:
|
||||
if form.header.field.data:
|
||||
sco_logos.store_image(
|
||||
form.logo_header.data, os.path.join(scu.SCODOC_LOGOS_DIR, "logo_header")
|
||||
form.header.field.data, os.path.join(scu.SCODOC_LOGOS_DIR, "logo_header")
|
||||
)
|
||||
if form.logo_footer.data:
|
||||
if form.footer.field.data:
|
||||
sco_logos.store_image(
|
||||
form.logo_footer.data, os.path.join(scu.SCODOC_LOGOS_DIR, "logo_footer")
|
||||
form.footer.field.data, os.path.join(scu.SCODOC_LOGOS_DIR, "logo_footer")
|
||||
)
|
||||
app.clear_scodoc_cache()
|
||||
flash(f"Configuration enregistrée")
|
||||
|
Loading…
x
Reference in New Issue
Block a user