Modification de la liste des topics actifs du menu
+ Correction de bugs
This commit is contained in:
parent
1be5ec93da
commit
cf61b43e17
|
@ -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):
|
||||
"""
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -16,6 +16,7 @@ def login():
|
|||
|
||||
form = LoginForm()
|
||||
lateral = LoginForm(prefix="menu_")
|
||||
|
||||
if lateral.validate_on_submit():
|
||||
form = lateral
|
||||
if form.validate_on_submit():
|
||||
|
|
|
@ -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'])
|
||||
|
|
|
@ -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 %}
|
||||
|
|
Loading…
Reference in New Issue