Merge branch 'dev' of gitea.planet-casio.com:devs/PCv5 into polls
This commit is contained in:
commit
cd8efcced8
|
@ -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,11 +15,11 @@ 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)
|
||||
|
||||
|
||||
|
||||
def __init__(self, author, text, thread):
|
||||
"""
|
||||
|
|
|
@ -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/<forum:f>/<topicpage:page>', 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(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)
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
{% for user in users %}
|
||||
<tr><td><a href="{{ url_for('user_by_id', user_id=user.id) }}" title="Page de profil publique de {{ user.name }}">{{ user.name }}</a></td>
|
||||
<td style="color: {{ 'red' if not user.email_confirmed else 'inherit' }};">{{ user.email }}</td>
|
||||
<td style="text-align: center">{{ user.register_date | date('%Y-%d-%d') }}</td>
|
||||
<td style="text-align: center">{{ user.register_date | date('%Y-%m-%d') }}</td>
|
||||
<td>{% for g in user.groups %}
|
||||
<span style="{{ g.css }}">{{ g.name }}</span>
|
||||
{{ ', ' if not loop.last }}
|
||||
|
|
|
@ -19,6 +19,13 @@
|
|||
|
||||
{{ widget_pagination.paginate(comments, 'forum_topic', t, {'f': t.forum}) }}
|
||||
|
||||
{% if last %}
|
||||
<div class="bg-warn">
|
||||
Ce topic est sans activité depuis plus de X jours, êtes-vous sûr de vouloir y poster ?
|
||||
{{ last }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if current_user.is_authenticated or V5Config.ENABLE_GUEST_POST %}
|
||||
<div class=form>
|
||||
<h3>Commenter le sujet</h3>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue