aboutsummaryrefslogtreecommitdiff
path: root/app/templates
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2018-06-11 22:49:25 +0100
committerrubenwardy <rw@rubenwardy.com>2018-06-11 22:52:37 +0100
commitb1c349cc3558b4642a700a489482ff95b038ce56 (patch)
tree1b8cda09e538d9c571050d26ecbb1d5455dea5c0 /app/templates
parent40aac38d43c2d7c2220b10a1bef34ac85f960359 (diff)
downloadcheatdb-b1c349cc3558b4642a700a489482ff95b038ce56.tar.xz
Add comment system
Diffstat (limited to 'app/templates')
-rw-r--r--app/templates/macros/threads.html27
-rw-r--r--app/templates/packages/view.html13
-rw-r--r--app/templates/threads/list.html12
-rw-r--r--app/templates/threads/new.html19
-rw-r--r--app/templates/threads/view.html25
5 files changed, 96 insertions, 0 deletions
diff --git a/app/templates/macros/threads.html b/app/templates/macros/threads.html
new file mode 100644
index 0000000..96e1107
--- /dev/null
+++ b/app/templates/macros/threads.html
@@ -0,0 +1,27 @@
+{% macro render_thread(thread, current_user) -%}
+ <ul>
+ {% for r in thread.replies %}
+ <li>
+ &lt;<a href="{{ url_for('user_profile_page', username=r.author.username) }}">{{ r.author.display_name }}</a>&gt;
+ {{ r.comment }}
+ </li>
+ {% endfor %}
+ </ul>
+
+ {% if current_user.is_authenticated %}
+ <form method="post" action="{{ url_for('thread_page', id=thread.id)}}">
+ <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
+ <textarea required maxlength=500 name="comment"></textarea><br />
+ <input type="submit" value="Comment" />
+ </form>
+ {% endif %}
+{% endmacro %}
+
+{% macro render_threadlist(threads) -%}
+ <ul>
+ {% for t in threads %}
+ <li><a href="{{ url_for('thread_page', id=t.id) }}">{{ t.title }}</a> by {{ t.author.display_name }}</li>
+ {% endfor %}
+ </ul>
+
+{% endmacro %}
diff --git a/app/templates/packages/view.html b/app/templates/packages/view.html
index 56cfd62..3a83995 100644
--- a/app/templates/packages/view.html
+++ b/app/templates/packages/view.html
@@ -43,6 +43,19 @@
{% endif %}
<div style="clear: both;"></div>
</div>
+
+ {% if package.author == current_user or package.checkPerm(current_user, "APPROVE_NEW") %}
+ {% if review_thread %}
+ {% from "macros/threads.html" import render_thread %}
+ {{ render_thread(review_thread, current_user) }}
+ {% else %}
+ <div class="box box_grey alert alert-info">
+ Privately ask a question or give feedback
+
+ <a class="alert_right button" href="{{ url_for('new_thread_page', pid=package.id, title='Package approval comments') }}">Open Thread</a>
+ </div>
+ {% endif %}
+ {% endif %}
{% endif %}
<h1>{{ package.title }} by {{ package.author.display_name }}</h1>
diff --git a/app/templates/threads/list.html b/app/templates/threads/list.html
new file mode 100644
index 0000000..7e27325
--- /dev/null
+++ b/app/templates/threads/list.html
@@ -0,0 +1,12 @@
+{% extends "base.html" %}
+
+{% block title %}
+Threads
+{% endblock %}
+
+{% block content %}
+ <h1>Threads</h1>
+
+ {% from "macros/threads.html" import render_threadlist %}
+ {{ render_threadlist(threads) }}
+{% endblock %}
diff --git a/app/templates/threads/new.html b/app/templates/threads/new.html
new file mode 100644
index 0000000..22f5b72
--- /dev/null
+++ b/app/templates/threads/new.html
@@ -0,0 +1,19 @@
+{% extends "base.html" %}
+
+{% block title %}
+ New Thread
+{% endblock %}
+
+{% block content %}
+ {% from "macros/forms.html" import render_field, render_submit_field %}
+ <form method="POST" action="" enctype="multipart/form-data">
+ {{ form.hidden_tag() }}
+
+ {{ render_field(form.title) }}
+ {{ render_field(form.comment) }}
+ {{ render_field(form.private) }}
+ {{ render_submit_field(form.submit) }}
+
+ <p>Only the you, the package author, and users of Editor rank and above can read private threads.</p>
+ </form>
+{% endblock %}
diff --git a/app/templates/threads/view.html b/app/templates/threads/view.html
new file mode 100644
index 0000000..397fba3
--- /dev/null
+++ b/app/templates/threads/view.html
@@ -0,0 +1,25 @@
+{% extends "base.html" %}
+
+{% block title %}
+Threads
+{% endblock %}
+
+{% block content %}
+ <h1>{% if thread.private %}&#x1f512; {% endif %}{{ thread.title }}</h1>
+
+ {% if thread.package %}
+ <p>
+ Package: <a href="{{ thread.package.getDetailsURL() }}">{{ thread.package.title }}</a>
+ </p>
+ {% endif %}
+
+ {% if thread.private %}
+ <i>
+ This thread is only visible to its creator, the package owner, and users of
+ Editor rank or above.
+ </i>
+ {% endif %}
+
+ {% from "macros/threads.html" import render_thread %}
+ {{ render_thread(thread, current_user) }}
+{% endblock %}