Modification de la liste des topics actifs du menu

+ Correction de bugs
This commit is contained in:
Darks 2019-12-04 13:58:48 +01:00
parent 1be5ec93da
commit cf61b43e17
Signed by untrusted user: Darks
GPG Key ID: F61F10FA138E797C
6 changed files with 15 additions and 18 deletions

View File

@ -203,7 +203,7 @@ class Member(User):
Reward xp to a member. If [amount] is negative, the xp total of the
member will decrease, down to zero.
"""
self.xp_points = min(max(self.xp_points + amount, 0), 1000000000)
self.xp = min(max(self.xp + amount, 0), 1000000000)
def set_password(self, password):
"""

View File

@ -15,15 +15,14 @@ def menu_processor():
search_form = SearchForm()
main_forum = Forum.query.filter_by(parent=None).first()
# Constructing last forum comments [(member, topic)]
raw = db.session.execute( """SELECT member.id, topic.id FROM comment
RIGHT JOIN post ON comment.id = post.id
INNER JOIN topic ON comment.thread_id = topic.thread_id
INNER JOIN member ON post.author_id = member.id
ORDER BY post.date_created DESC
LIMIT 10""")
last_forum_comments = [(Member.query.get(m), Topic.query.get(t))
for m, t in raw]
# Constructing last active topics
raw = db.session.execute( """SELECT topic.id FROM topic
INNER JOIN comment ON topic.thread_id = comment.thread_id
INNER JOIN post ON post.id = comment.id
GROUP BY topic.id
ORDER BY MAX(post.date_created) DESC
LIMIT 10;""")
last_active_topics = [Topic.query.get(id) for id in raw]
return dict(login_form=login_form, search_form=search_form,
main_forum=main_forum, last_forum_comments=last_forum_comments)
main_forum=main_forum, last_active_topics=last_active_topics)

View File

@ -16,6 +16,7 @@ def login():
form = LoginForm()
lateral = LoginForm(prefix="menu_")
if lateral.validate_on_submit():
form = lateral
if form.validate_on_submit():

View File

@ -1,13 +1,14 @@
from flask_login import current_user
from flask import request, 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
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 import app, db
@app.route('/forum/<forum:f>/<topicslug:t>', methods=['GET', 'POST'])

View File

@ -15,12 +15,10 @@
<hr>
<h3>Derniers commentaires</h3>
<h3>Derniers topics actifs</h3>
<ul>
{% for m, t in last_forum_comments %}
{% for t in last_active_topics %}
<li>
<a href="{{ url_for('user', username=m.name) }}">{{ m.name }}</a>
sur
<a href="{{ url_for('forum_topic', f=t.forum, t=t)}}">{{ t.title }}</a>
</li>
{% endfor %}

View File

@ -9,8 +9,6 @@ class Config(object):
'postgresql+psycopg2://' + os.environ.get('USER') + ':@/' + DB_NAME
SQLALCHEMY_TRACK_MODIFICATIONS = False
UPLOAD_FOLDER = './app/static/avatars'
SESSION_COOKIE_SECURE = True
REMEMBER_COOKIE_SECURE = True
class V5Config(object):