aboutsummaryrefslogtreecommitdiff
path: root/app/templates
diff options
context:
space:
mode:
Diffstat (limited to 'app/templates')
-rw-r--r--app/templates/macros/topics.html4
-rw-r--r--app/templates/todo/topics.html34
-rw-r--r--app/templates/users/user_profile_page.html11
3 files changed, 14 insertions, 35 deletions
diff --git a/app/templates/macros/topics.html b/app/templates/macros/topics.html
index 8316a70..432867d 100644
--- a/app/templates/macros/topics.html
+++ b/app/templates/macros/topics.html
@@ -1,4 +1,4 @@
-{% macro render_topics_table(topics, show_author=True, show_discard=False) -%}
+{% macro render_topics_table(topics, show_author=True, show_discard=False, current_user=current_user) -%}
<table class="table">
<tr>
<th></th>
@@ -27,7 +27,7 @@
href="{{ url_for('create_edit_package_page', author=topic.author.username, repo=topic.getRepoURL(), forums=topic.topic_id, title=topic.title, bname=topic.name) }}">
Create
</a>
- {% if show_discard %}
+ {% if show_discard and current_user.is_authenticated and topic.checkPerm(current_user, "TOPIC_DISCARD") %}
<a class="btn btn-{% if topic.discarded %}success{% else %}danger{% endif %} topic-discard" data-tid={{ topic.topic_id }}>
{% if topic.discarded %}
Show
diff --git a/app/templates/todo/topics.html b/app/templates/todo/topics.html
index 5d3e7f9..b112254 100644
--- a/app/templates/todo/topics.html
+++ b/app/templates/todo/topics.html
@@ -59,7 +59,7 @@ Topics to be Added
</form>
{% from "macros/topics.html" import render_topics_table %}
- {{ render_topics_table(topics, show_discard=True) }}
+ {{ render_topics_table(topics, show_discard=True, current_user=current_user) }}
<ul class="pagination mt-4">
<li class="page-item {% if not prev_url %}disabled{% endif %}">
@@ -83,35 +83,5 @@ Topics to be Added
<script>
var csrf_token = "{{ csrf_token() }}";
</script>
- <script>
- $(".topic-discard").click(function() {
- var ele = $(this);
- var tid = ele.attr("data-tid");
- var discard = !ele.parent().parent().hasClass("discardtopic");
- fetch(new Request("{{ url_for('topic_set_discard') }}?tid=" + tid +
- "&discard=" + (discard ? "true" : "false"), {
- method: "post",
- credentials: "same-origin",
- headers: {
- "Accept": "application/json",
- "X-CSRFToken": csrf_token,
- },
- })).then(function(response) {
- response.text().then(function(txt) {
- console.log(JSON.parse(txt));
- if (JSON.parse(txt).discarded) {
- ele.parent().parent().addClass("discardtopic");
- ele.removeClass("btn-danger");
- ele.addClass("btn-success");
- ele.text("Show");
- } else {
- ele.parent().parent().removeClass("discardtopic");
- ele.removeClass("btn-success");
- ele.addClass("btn-danger");
- ele.text("Discard");
- }
- }).catch(console.log)
- }).catch(console.log)
- });
- </script>
+ <script src="/static/topic_discard.js"></script>
{% endblock %}
diff --git a/app/templates/users/user_profile_page.html b/app/templates/users/user_profile_page.html
index 8949189..3dcb369 100644
--- a/app/templates/users/user_profile_page.html
+++ b/app/templates/users/user_profile_page.html
@@ -134,11 +134,20 @@
<p class="card-body">
List of your forum topics which do not have a matching package.
+ Topics with a strikethrough have beened marked as discarded.
</p>
{% from "macros/topics.html" import render_topics_table %}
- {{ render_topics_table(topics_to_add, show_author=False) }}
+ {{ render_topics_table(topics_to_add, show_author=False, show_discard=True, current_user=current_user) }}
</div>
{% endif %}
{% endblock %}
+
+
+{% block scriptextra %}
+ <script>
+ var csrf_token = "{{ csrf_token() }}";
+ </script>
+ <script src="/static/topic_discard.js"></script>
+{% endblock %}