From 6157e54a5f1817e96a82051fbd71ec8e13d1bf90 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 5 Jan 2022 16:06:56 +0100 Subject: [PATCH] affichage nom complet du dept. sur la page accueil --- app/forms/main/create_dept.py | 1 + app/models/departements.py | 6 ++++-- app/templates/scodoc.html | 4 +++- app/views/scodoc.py | 6 +++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/forms/main/create_dept.py b/app/forms/main/create_dept.py index d1e143bed..cd0534057 100644 --- a/app/forms/main/create_dept.py +++ b/app/forms/main/create_dept.py @@ -54,6 +54,7 @@ class CreateDeptForm(FlaskForm): validators.DataRequired("acronyme du département requis"), ], ) + # description = StringField(label="Description") visible = BooleanField( "Visible sur page d'accueil", default=True, diff --git a/app/models/departements.py b/app/models/departements.py index d83ccfc2d..1e6b5a1f1 100644 --- a/app/models/departements.py +++ b/app/models/departements.py @@ -12,8 +12,10 @@ class Departement(db.Model): """Un département ScoDoc""" id = db.Column(db.Integer, primary_key=True) - acronym = db.Column(db.String(SHORT_STR_LEN), nullable=False, index=True) - description = db.Column(db.Text()) + acronym = db.Column( + 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()) visible = db.Column( db.Boolean(), nullable=False, default=True, server_default="true" diff --git a/app/templates/scodoc.html b/app/templates/scodoc.html index 23667c24f..d5e453009 100644 --- a/app/templates/scodoc.html +++ b/app/templates/scodoc.html @@ -16,7 +16,9 @@
  • Département - {{dept.preferences.filter_by(name="DeptName").first().value}} + {{dept.preferences.filter_by(name="DeptName").first().value}} + {{ dept.preferences.filter_by( name="DeptFullName" ).first().value or "" }} + {% if current_user.is_administrator() %} {% if dept.visible %}visible{% else %}caché aux utilisateurs{% endif %} diff --git a/app/views/scodoc.py b/app/views/scodoc.py index 3e2fdbdc7..a7aedaa88 100644 --- a/app/views/scodoc.py +++ b/app/views/scodoc.py @@ -107,7 +107,11 @@ def create_dept(): if request.method == "POST" and form.cancel.data: # cancel button return redirect(url_for("scodoc.index")) 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éé.") return redirect(url_for("scodoc.index")) return render_template(