affichage nom complet du dept. sur la page accueil

This commit is contained in:
Emmanuel Viennet 2022-01-05 16:06:56 +01:00
parent ff948cb98d
commit 6157e54a5f
4 changed files with 13 additions and 4 deletions

View File

@ -54,6 +54,7 @@ class CreateDeptForm(FlaskForm):
validators.DataRequired("acronyme du département requis"), validators.DataRequired("acronyme du département requis"),
], ],
) )
# description = StringField(label="Description")
visible = BooleanField( visible = BooleanField(
"Visible sur page d'accueil", "Visible sur page d'accueil",
default=True, default=True,

View File

@ -12,8 +12,10 @@ class Departement(db.Model):
"""Un département ScoDoc""" """Un département ScoDoc"""
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
acronym = db.Column(db.String(SHORT_STR_LEN), nullable=False, index=True) acronym = db.Column(
description = db.Column(db.Text()) db.String(SHORT_STR_LEN), nullable=False, index=True
) # ne change jamais, voir la pref. DeptName
description = db.Column(db.Text()) # pas utilisé par ScoDoc : voir DeptFullName
date_creation = db.Column(db.DateTime(timezone=True), server_default=db.func.now()) date_creation = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
visible = db.Column( visible = db.Column(
db.Boolean(), nullable=False, default=True, server_default="true" db.Boolean(), nullable=False, default=True, server_default="true"

View File

@ -16,7 +16,9 @@
<li> <li>
<a class="stdlink {{'link_accessible' if current_user.has_permission(Permission.ScoView, dept=dept.acronym) else 'link_unauthorized'}}" <a class="stdlink {{'link_accessible' if current_user.has_permission(Permission.ScoView, dept=dept.acronym) else 'link_unauthorized'}}"
href="{{url_for('scolar.index_html', scodoc_dept=dept.acronym)}}">Département href="{{url_for('scolar.index_html', scodoc_dept=dept.acronym)}}">Département
{{dept.preferences.filter_by(name="DeptName").first().value}}</a> {{dept.preferences.filter_by(name="DeptName").first().value}}
{{ dept.preferences.filter_by( name="DeptFullName" ).first().value or "" }}
</a>
{% if current_user.is_administrator() %} {% if current_user.is_administrator() %}
<span class="dept_visibility"> <span class="dept_visibility">
{% if dept.visible %}visible{% else %}caché aux utilisateurs{% endif %} {% if dept.visible %}visible{% else %}caché aux utilisateurs{% endif %}

View File

@ -107,7 +107,11 @@ def create_dept():
if request.method == "POST" and form.cancel.data: # cancel button if request.method == "POST" and form.cancel.data: # cancel button
return redirect(url_for("scodoc.index")) return redirect(url_for("scodoc.index"))
if form.validate_on_submit(): if form.validate_on_submit():
departements.create_dept(form.acronym.data, visible=form.visible.data) departements.create_dept(
form.acronym.data,
visible=form.visible.data,
# description=form.description.data,
)
flash(f"Département {form.acronym.data} créé.") flash(f"Département {form.acronym.data} créé.")
return redirect(url_for("scodoc.index")) return redirect(url_for("scodoc.index"))
return render_template( return render_template(