Compare commits

...

2 Commits

2 changed files with 18 additions and 3 deletions

View File

@ -5,7 +5,7 @@ from .users import login_required, get_active_user
from ..lib.babycode import babycode_to_html from ..lib.babycode import babycode_to_html
from ..constants import InfoboxKind from ..constants import InfoboxKind
from ..db import db from ..db import db
from ..models import Posts, PostHistory, Threads from ..models import Posts, PostHistory, Threads, Topics
bp = Blueprint("posts", __name__, url_prefix = "/post") bp = Blueprint("posts", __name__, url_prefix = "/post")
@ -50,10 +50,25 @@ def delete(post_id):
post = Posts.find({'id': post_id}) post = Posts.find({'id': post_id})
thread = Threads.find({'id': post.thread_id}) thread = Threads.find({'id': post.thread_id})
user = get_active_user() 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: if user.is_mod() or post.user_id == user.id:
post.delete() 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)) return redirect(url_for('threads.thread', slug=thread.slug))

View File

@ -143,7 +143,7 @@
{% if show_reply %} {% if show_reply %}
{% set qtext = "[url=%s]%s said:[/url]" | format(post_permalink, post['username']) %} {% 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> <button value="{{ reply_text }}" class="reply-button">Quote</button>
{% endif %} {% endif %}