Add delete button to comments
This commit is contained in:
@@ -1,13 +1,33 @@
|
||||
{% macro author(name, ctime, mtime, thread_id, parent_id) %}
|
||||
{% macro author(name, ctime, mtime) %}
|
||||
<i>{{ name }} - {{ format_since(ctime) }}{% if ctime != mtime %} (last modified {{ format_since(mtime) }}){% endif %}</i>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro comment_author(comment, thread_id) %}
|
||||
<p>
|
||||
<sub>
|
||||
<i>{{ name }} - {{ format_since(ctime) }}{% if ctime != mtime %} (last modified {{ format_since(mtime) }}){% endif %}</i>
|
||||
{% if thread_id is not none %}
|
||||
{{ author(comment.author, comment.create_time, comment.modify_time) }}
|
||||
{# Suffixing a # prevents unnecessary reloads #}
|
||||
<a href="{{ url_for('thread', thread_id = thread_id) }}#">thread</a>
|
||||
{% if comment.parent_id is not none %}
|
||||
<a href="{{ url_for('comment', comment_id = comment.parent_id) }}#">parent</a>
|
||||
{% endif %}
|
||||
{% if parent_id is not none %}
|
||||
<a href="{{ url_for('comment', comment_id = parent_id) }}#">parent</a>
|
||||
{% if comment.author_id == session.get('user_id') %}
|
||||
{% endif %}
|
||||
{% if comment.author_id == session.get('user_id') %}
|
||||
<a href="{{ url_for('confirm_delete_comment', comment_id = comment.id) }}">delete</a>
|
||||
{% endif %}
|
||||
</sub>
|
||||
</p>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro thread_author(author_id, name, ctime, mtime) %}
|
||||
<p>
|
||||
<sub>
|
||||
{{ author(name, ctime, mtime) }}
|
||||
{% if author_id == session.get('user_id') %}
|
||||
{% endif %}
|
||||
{% if author_id == session.get('user_id') %}
|
||||
<a href="{{ url_for('confirm_delete_thread', thread_id = thread_id) }}">delete</a>
|
||||
{% endif %}
|
||||
</sub>
|
||||
</p>
|
||||
@@ -15,7 +35,7 @@
|
||||
|
||||
{% macro render_comment_pre(comment, thread_id) %}
|
||||
<div class=comment>
|
||||
{{ author(comment.author, comment.create_time, comment.modify_time, thread_id, comment.parent_id) }}
|
||||
{{ comment_author(comment, thread_id) }}
|
||||
<p>{{ minimd(comment.text) | safe }}</p>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
{% from 'comment.html' import render_comment, render_comment_pre, render_comment_post, reply with context %}
|
||||
|
||||
{% block content %}
|
||||
<sup><a href="{{ url_for('thread', thread_id = thread_id) }}">thread</a></sup>
|
||||
{% if parent_id %}
|
||||
<sup><a href="../{{ parent_id }}">parent</a></sup>
|
||||
{% endif %}
|
||||
|
||||
{{ render_comment_pre(reply_comment, thread_id) }}
|
||||
|
||||
|
||||
14
templates/confirm_delete_comment.html
Normal file
14
templates/confirm_delete_comment.html
Normal file
@@ -0,0 +1,14 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<p>Are you sure you want to delete this comment on "{{ thread_title }}"?</p>
|
||||
<div class=comment>{{ minimd(text) | safe }}</div>
|
||||
<p>
|
||||
<form method="post" action="../delete" style=inline>
|
||||
<input type="submit" value="Yes">
|
||||
</form>
|
||||
<form method="get" action=".." style=inline>
|
||||
<input type="submit" value="No">
|
||||
</form>
|
||||
</p>
|
||||
{% endblock %}
|
||||
@@ -1,15 +1,8 @@
|
||||
{% extends 'base.html' %}
|
||||
{% from 'comment.html' import render_comment, reply, author as f_author with context %}
|
||||
{% from 'comment.html' import render_comment, reply, thread_author with context %}
|
||||
|
||||
{% block content %}
|
||||
{% if manage %}
|
||||
<div>
|
||||
<form method="get" action="confirm_delete/">
|
||||
<input type="submit" value="Delete">
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
<i>{{ f_author(author, create_time, modify_time, None, None) }}</i>
|
||||
<i>{{ thread_author(author_id, author, create_time, modify_time) }}</i>
|
||||
<p>{{ minimd(text) | safe }}</p>
|
||||
|
||||
{{ reply() }}
|
||||
|
||||
Reference in New Issue
Block a user