Compare commits
2 Commits
b0fd2a4f0c
...
cf2d605077
Author | SHA1 | Date | |
---|---|---|---|
cf2d605077
|
|||
c68ead85c0
|
@ -5,7 +5,7 @@ from .users import login_required, get_active_user
|
||||
from ..lib.babycode import babycode_to_html
|
||||
from ..constants import InfoboxKind
|
||||
from ..db import db
|
||||
from ..models import Posts, PostHistory, Threads
|
||||
from ..models import Posts, PostHistory, Threads, Topics
|
||||
|
||||
bp = Blueprint("posts", __name__, url_prefix = "/post")
|
||||
|
||||
@ -50,10 +50,25 @@ def delete(post_id):
|
||||
post = Posts.find({'id': post_id})
|
||||
thread = Threads.find({'id': post.thread_id})
|
||||
user = get_active_user()
|
||||
if not user:
|
||||
return redirect(url_for('threads.thread', slug=thread.slug))
|
||||
|
||||
if user.is_mod() or post.user_id == user.id:
|
||||
post.delete()
|
||||
flash("Post deleted.", InfoboxKind.INFO)
|
||||
|
||||
post_count = Posts.count({
|
||||
'thread_id': thread.id,
|
||||
})
|
||||
|
||||
if post_count == 0:
|
||||
topic = Topics.find({
|
||||
'id': thread.topic_id,
|
||||
})
|
||||
thread.delete()
|
||||
flash('Thread deleted.', InfoboxKind.INFO)
|
||||
return redirect(url_for('topics.topic', slug=topic.slug))
|
||||
|
||||
flash('Post deleted.', InfoboxKind.INFO)
|
||||
|
||||
return redirect(url_for('threads.thread', slug=thread.slug))
|
||||
|
||||
|
@ -143,7 +143,7 @@
|
||||
|
||||
{% if show_reply %}
|
||||
{% set qtext = "[url=%s]%s said:[/url]" | format(post_permalink, post['username']) %}
|
||||
{% set reply_text = "%s\n[quote]%s[/quote]\n" | format(qtext, post['original_markup']) %}
|
||||
{% set reply_text = "%s\n[quote]\n%s\n[/quote]\n" | format(qtext, post['original_markup']) %}
|
||||
<button value="{{ reply_text }}" class="reply-button">Quote</button>
|
||||
{% endif %}
|
||||
|
||||
|
Reference in New Issue
Block a user