From c0ae3cc8ab74cc213b582ebd07a08beea4029181 Mon Sep 17 00:00:00 2001 From: Eragon Date: Tue, 12 Jan 2021 16:40:52 +0100 Subject: [PATCH 1/4] =?UTF-8?q?#84=20Confirmation=20anti-n=C3=A9cropost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/comment.py | 7 ++++--- app/routes/forum/topic.py | 22 ++++++++++++---------- app/templates/forum/topic.html | 6 ++++++ 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/models/comment.py b/app/models/comment.py index 8c7be13..8343e79 100644 --- a/app/models/comment.py +++ b/app/models/comment.py @@ -2,6 +2,7 @@ from app import db from app.models.post import Post from sqlalchemy.orm import backref + class Comment(Post): __tablename__ = 'comment' __mapper_args__ = {'polymorphic_identity': __tablename__} @@ -14,10 +15,10 @@ class Comment(Post): # Parent thread thread_id = db.Column(db.Integer, db.ForeignKey('thread.id'), - nullable=False) + nullable=False) thread = db.relationship('Thread', - backref=backref('comments', lazy='dynamic'), - foreign_keys=thread_id) + backref=backref('comments', lazy='dynamic'), + foreign_keys=thread_id) def __init__(self, author, text, thread): """ diff --git a/app/routes/forum/topic.py b/app/routes/forum/topic.py index 173e066..2af6b3b 100644 --- a/app/routes/forum/topic.py +++ b/app/routes/forum/topic.py @@ -1,17 +1,17 @@ from flask_login import current_user -from flask import request, redirect, url_for, flash, abort +from flask import redirect, url_for, flash, abort from app import app, db from config import V5Config from app.utils.render import render from app.forms.forum import CommentForm, AnonymousCommentForm -from app.models.forum import Forum -from app.models.topic import Topic from app.models.thread import Thread from app.models.comment import Comment from app.models.user import Guest from app.models.attachment import Attachment +import datetime + @app.route('/forum//', methods=['GET', 'POST']) def forum_topic(f, page): @@ -27,7 +27,7 @@ def forum_topic(f, page): form = AnonymousCommentForm() if form.validate_on_submit() and \ - (V5Config.ENABLE_GUEST_POST or current_user.is_authenticated): + (V5Config.ENABLE_GUEST_POST or current_user.is_authenticated): # Manage author if current_user.is_authenticated: author = current_user @@ -58,8 +58,8 @@ def forum_topic(f, page): flash('Message envoyé', 'ok') # Redirect to empty the form - return redirect(url_for('forum_topic', f=f, page=(t,"fin"), - _anchor=c.id)) + return redirect(url_for('forum_topic', f=f, page=(t, "fin"), + _anchor=c.id)) # Update views t.views += 1 @@ -67,10 +67,12 @@ def forum_topic(f, page): db.session.commit() if page == -1: - page = (t.thread.comments.count() - 1) \ - // Thread.COMMENTS_PER_PAGE + 1 + page = (t.thread.comments.count() - 1) // Thread.COMMENTS_PER_PAGE + 1 comments = t.thread.comments.paginate(page, - Thread.COMMENTS_PER_PAGE, True) + Thread.COMMENTS_PER_PAGE, True) - return render('/forum/topic.html', t=t, form=form, comments=comments) + now_minus = datetime.datetime.now() - datetime.timedelta(minutes=15) + last_edited_comment = t.thread.comments.filter(Comment.date_modified >= now_minus).first() + + return render('/forum/topic.html', t=t, form=form, comments=comments, last=last_edited_comment) diff --git a/app/templates/forum/topic.html b/app/templates/forum/topic.html index 3c48fda..99b454a 100644 --- a/app/templates/forum/topic.html +++ b/app/templates/forum/topic.html @@ -19,6 +19,12 @@ {{ widget_pagination.paginate(comments, 'forum_topic', t, {'f': t.forum}) }} + {% if not last %} +
+ Ce topic est sans activité depuis plus de X jours, êtes-vous sûr de vouloir y poster ? +
+ {% endif %} + {% if current_user.is_authenticated or V5Config.ENABLE_GUEST_POST %}

Commenter le sujet

From 4ddf60353c52dfd5633d137c100272ef941eac80 Mon Sep 17 00:00:00 2001 From: Eragon Date: Tue, 12 Jan 2021 17:30:54 +0100 Subject: [PATCH 2/4] =?UTF-8?q?#84=20Passage=20du=20dernier=20post=20en=20?= =?UTF-8?q?cas=20de=20n=C3=A9cropost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routes/forum/topic.py | 6 +++--- app/templates/forum/topic.html | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/routes/forum/topic.py b/app/routes/forum/topic.py index 2af6b3b..324015f 100644 --- a/app/routes/forum/topic.py +++ b/app/routes/forum/topic.py @@ -72,7 +72,7 @@ def forum_topic(f, page): comments = t.thread.comments.paginate(page, Thread.COMMENTS_PER_PAGE, True) - now_minus = datetime.datetime.now() - datetime.timedelta(minutes=15) - last_edited_comment = t.thread.comments.filter(Comment.date_modified >= now_minus).first() + now_minus = datetime.datetime.now() - datetime.timedelta(minutes=1) + last_updated_comment = t.thread.comments.filter(Comment.date_modified <= now_minus).first() - return render('/forum/topic.html', t=t, form=form, comments=comments, last=last_edited_comment) + return render('/forum/topic.html', t=t, form=form, comments=comments, last=last_updated_comment) diff --git a/app/templates/forum/topic.html b/app/templates/forum/topic.html index 99b454a..8353ae5 100644 --- a/app/templates/forum/topic.html +++ b/app/templates/forum/topic.html @@ -19,9 +19,10 @@ {{ widget_pagination.paginate(comments, 'forum_topic', t, {'f': t.forum}) }} - {% if not last %} + {% if last %}
Ce topic est sans activité depuis plus de X jours, êtes-vous sûr de vouloir y poster ? + {{ last }}
{% endif %} From 9273430f9a8d2ec974d67a189ae26ee0146901ee Mon Sep 17 00:00:00 2001 From: Eragon Date: Tue, 12 Jan 2021 17:34:50 +0100 Subject: [PATCH 3/4] =?UTF-8?q?#84=20Configuration=20de=20la=20dur=C3=A9e?= =?UTF-8?q?=20avant=20n=C3=A9cropost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routes/forum/topic.py | 2 +- config.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/routes/forum/topic.py b/app/routes/forum/topic.py index 324015f..6a3f2e3 100644 --- a/app/routes/forum/topic.py +++ b/app/routes/forum/topic.py @@ -72,7 +72,7 @@ def forum_topic(f, page): comments = t.thread.comments.paginate(page, Thread.COMMENTS_PER_PAGE, True) - now_minus = datetime.datetime.now() - datetime.timedelta(minutes=1) + now_minus = datetime.datetime.now() - datetime.timedelta(days=V5Config.NECROPOST_LIMIT) last_updated_comment = t.thread.comments.filter(Comment.date_modified <= now_minus).first() return render('/forum/topic.html', t=t, form=form, comments=comments, last=last_updated_comment) diff --git a/config.py b/config.py index 4248053..7110ba9 100644 --- a/config.py +++ b/config.py @@ -4,6 +4,7 @@ try: from local_config import LocalConfig except ImportError: print(" \033[92mWARNING: Local config not found\033[0m") + class LocalConfig(): pass @@ -25,6 +26,7 @@ class Config(object): # Do not attach cookies to cross-origin requests SESSION_COOKIE_SAMESITE = "Lax" + class DefaultConfig(object): """Every value here can be overrided in the local_config.py class""" # Domain @@ -50,6 +52,9 @@ class DefaultConfig(object): # GLaDOS configuration GLADOS_HOST = "127.0.0.1" GLADOS_PORT = 5555 + # Time in days before trigerring the nec + NECROPOST_LIMIT = 31 + class V5Config(LocalConfig, DefaultConfig): # Values put here cannot be overidden with local_config From 3b1aa2fc1d49fe655c2e7c6f207b6e922be6e11b Mon Sep 17 00:00:00 2001 From: Eldeberen Date: Fri, 19 Feb 2021 22:23:26 +0100 Subject: [PATCH 4/4] admin-panel: fix users registration date --- app/templates/admin/members.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/admin/members.html b/app/templates/admin/members.html index e8d008f..ae9941d 100644 --- a/app/templates/admin/members.html +++ b/app/templates/admin/members.html @@ -35,7 +35,7 @@ {% for user in users %} {{ user.name }} {{ user.email }} - {{ user.register_date | date('%Y-%d-%d') }} + {{ user.register_date | date('%Y-%m-%d') }} {% for g in user.groups %} {{ g.name }} {{ ', ' if not loop.last }}