From 876cae2b6993370b5553e36310520d5112040a80 Mon Sep 17 00:00:00 2001 From: Darks Date: Sun, 11 Jun 2023 23:05:03 +0200 Subject: [PATCH 1/3] =?UTF-8?q?glados:=C2=A0add=20some=20'say'=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routes/account/account.py | 2 ++ app/routes/forum/index.py | 3 +++ app/routes/forum/topic.py | 4 ++++ app/routes/programs/program.py | 1 + app/routes/programs/submit.py | 2 ++ app/utils/glados.py | 2 +- 6 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/routes/account/account.py b/app/routes/account/account.py index 31720ef..7acce3a 100644 --- a/app/routes/account/account.py +++ b/app/routes/account/account.py @@ -8,6 +8,7 @@ from app.models.trophy import Title from app.utils.render import render from app.utils.send_mail import send_validation_mail, send_reset_password_mail from app.utils.priv_required import guest_only +from app.utils.glados import say, BOLD import app.utils.ldap as ldap import app.utils.validators as vd from itsdangerous import URLSafeTimedSerializer @@ -178,4 +179,5 @@ def activate_account(token): db.session.commit() flash("L'email a bien été confirmé", "ok") + say(f"Un nouveau membre s’est inscrit ! Il s’agit de {BOLD}{m.name}{BOLD}.") return redirect(url_for('login')) diff --git a/app/routes/forum/index.py b/app/routes/forum/index.py index d843872..a32b1f1 100644 --- a/app/routes/forum/index.py +++ b/app/routes/forum/index.py @@ -73,6 +73,9 @@ def forum_page(f, page=1): current_user.update_trophies('new-post') flash('Le sujet a bien été créé', 'ok') + if f.is_default_accessible(): + say(f"Nouveau topic de {author.name} : {BOLD}{t.title}{BOLD}") + return redirect(url_for('forum_topic', f=f, page=(t,1))) # Paginate topic pages diff --git a/app/routes/forum/topic.py b/app/routes/forum/topic.py index 10dab56..9490fbc 100644 --- a/app/routes/forum/topic.py +++ b/app/routes/forum/topic.py @@ -5,6 +5,7 @@ from sqlalchemy import desc from app import app, db from config import V5Config from app.utils.render import render +from app.utils.glados import say, BOLD from app.forms.forum import CommentForm, AnonymousCommentForm from app.models.thread import Thread from app.models.comment import Comment @@ -54,6 +55,9 @@ def forum_topic(f, page): current_user.update_trophies('new-post') flash('Message envoyé', 'ok') + if f.is_default_accessible(): + say(f"Nouveau commentaire de {author.name} sur un topic : {BOLD}{t.title}{BOLD}") + # Redirect to empty the form return redirect(url_for('forum_topic', f=f, page=(t, "fin"), _anchor=str(c.id))) diff --git a/app/routes/programs/program.py b/app/routes/programs/program.py index 30bde3d..5667916 100644 --- a/app/routes/programs/program.py +++ b/app/routes/programs/program.py @@ -41,6 +41,7 @@ def program_view(page): current_user.update_trophies('new-post') flash('Message envoyé', 'ok') + say(f"Nouveau commentaire de {author.name} sur un programme: {BOLD}{t.name}{BOLD}") # Redirect to empty the form return redirect(url_for('program_view', page=(p, "fin"), _anchor=str(c.id))) diff --git a/app/routes/programs/submit.py b/app/routes/programs/submit.py index a990ac1..a670bfd 100644 --- a/app/routes/programs/submit.py +++ b/app/routes/programs/submit.py @@ -5,6 +5,7 @@ from app.models.comment import Comment from app.models.tag import Tag from app.models.attachment import Attachment from app.utils.render import render +from app.utils.glados import say, BOLD from app.forms.programs import ProgramCreationForm from flask_login import login_required, current_user @@ -54,6 +55,7 @@ def program_submit(): current_user.update_trophies('new-program') flash('Le programme a bien été soumis', 'ok') + say(f"Nouveau programme de {current_user.name} : {BOLD}{p.name}{BOLD}") return redirect(url_for('program_index')) return render('/programs/submit.html', form=form) diff --git a/app/utils/glados.py b/app/utils/glados.py index 978fdf0..0bd1419 100644 --- a/app/utils/glados.py +++ b/app/utils/glados.py @@ -36,4 +36,4 @@ def say(msg, channels = ["#general"]): def new_topic(topic): """ Example wrapper for glados.say """ - say(f"Le topic {BOLD}{topic.title}{BOLD} a été créé") + say(f"Nouveau topic de {topic.author.name}: {BOLD}{topic.title}{BOLD}") From f06f14e81474ba328fcbce24ee9d3b8848c7701e Mon Sep 17 00:00:00 2001 From: Darks Date: Mon, 12 Jun 2023 19:21:26 +0200 Subject: [PATCH 2/3] templates: fix a template tabtitle --- app/templates/programs/submit.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/programs/submit.html b/app/templates/programs/submit.html index fb6aede..1c896fc 100644 --- a/app/templates/programs/submit.html +++ b/app/templates/programs/submit.html @@ -2,7 +2,7 @@ {% import "widgets/editor.html" as widget_editor %} {% import "widgets/tag_selector.html" as widget_tag_selector with context %} -{% set tabtitle = f"Programmes - Soumettre un programme" %} +{% set tabtitle = "Programmes - Soumettre un programme" %} {% block title %} Programmes »

Soumettre un programme

From 2530581095003aad04bdbf270eb0a28e9ccac25f Mon Sep 17 00:00:00 2001 From: Darks Date: Mon, 12 Jun 2023 20:04:20 +0200 Subject: [PATCH 3/3] glados: updated announces --- app/routes/account/account.py | 2 ++ app/routes/forum/index.py | 2 ++ app/routes/forum/topic.py | 5 +++-- app/routes/programs/program.py | 5 ++++- app/routes/programs/submit.py | 4 +++- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/routes/account/account.py b/app/routes/account/account.py index 7acce3a..625efd0 100644 --- a/app/routes/account/account.py +++ b/app/routes/account/account.py @@ -180,4 +180,6 @@ def activate_account(token): flash("L'email a bien été confirmé", "ok") say(f"Un nouveau membre s’est inscrit ! Il s’agit de {BOLD}{m.name}{BOLD}.") + say(url_for('user', username=m.name, _external=True)) + return redirect(url_for('login')) diff --git a/app/routes/forum/index.py b/app/routes/forum/index.py index a32b1f1..1297c8d 100644 --- a/app/routes/forum/index.py +++ b/app/routes/forum/index.py @@ -4,6 +4,7 @@ from flask import request, redirect, url_for, abort, flash from app import app, db from config import V5Config from app.utils.render import render +from app.utils.glados import say, BOLD from app.forms.forum import TopicCreationForm, AnonymousTopicCreationForm from app.models.forum import Forum from app.models.topic import Topic @@ -75,6 +76,7 @@ def forum_page(f, page=1): flash('Le sujet a bien été créé', 'ok') if f.is_default_accessible(): say(f"Nouveau topic de {author.name} : {BOLD}{t.title}{BOLD}") + say(url_for('forum_topic', f=f, page=(t, 1), _external=True)) return redirect(url_for('forum_topic', f=f, page=(t,1))) diff --git a/app/routes/forum/topic.py b/app/routes/forum/topic.py index 9490fbc..828bab0 100644 --- a/app/routes/forum/topic.py +++ b/app/routes/forum/topic.py @@ -56,8 +56,9 @@ def forum_topic(f, page): flash('Message envoyé', 'ok') if f.is_default_accessible(): - say(f"Nouveau commentaire de {author.name} sur un topic : {BOLD}{t.title}{BOLD}") - + say(f"Nouveau commentaire de {author.name} sur le topic : {BOLD}{t.title}{BOLD}") + say(url_for('forum_topic', f=f, page=(t, "fin"), _anchor=str(c.id), _external=True)) + # Redirect to empty the form return redirect(url_for('forum_topic', f=f, page=(t, "fin"), _anchor=str(c.id))) diff --git a/app/routes/programs/program.py b/app/routes/programs/program.py index 5667916..e851eba 100644 --- a/app/routes/programs/program.py +++ b/app/routes/programs/program.py @@ -4,6 +4,7 @@ from app.models.program import Program from app.models.comment import Comment from app.models.thread import Thread from app.utils.render import render +from app.utils.glados import say, BOLD from app.forms.forum import CommentForm, AnonymousCommentForm from config import V5Config @@ -41,7 +42,9 @@ def program_view(page): current_user.update_trophies('new-post') flash('Message envoyé', 'ok') - say(f"Nouveau commentaire de {author.name} sur un programme: {BOLD}{t.name}{BOLD}") + say(f"Nouveau commentaire de {author.name} sur le programme : {BOLD}{p.name}{BOLD}") + say(url_for('program_view', page=(p, "fin"), _anchor=str(c.id), _external=True)) + # Redirect to empty the form return redirect(url_for('program_view', page=(p, "fin"), _anchor=str(c.id))) diff --git a/app/routes/programs/submit.py b/app/routes/programs/submit.py index a670bfd..9bb7c57 100644 --- a/app/routes/programs/submit.py +++ b/app/routes/programs/submit.py @@ -56,6 +56,8 @@ def program_submit(): flash('Le programme a bien été soumis', 'ok') say(f"Nouveau programme de {current_user.name} : {BOLD}{p.name}{BOLD}") - return redirect(url_for('program_index')) + say(url_for('program_view', page=(p, 1), _external=True)) + + return redirect(url_for('program_view', page=(p, 1))) return render('/programs/submit.html', form=form)