aboutsummaryrefslogtreecommitdiff
path: root/app/templates
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2018-12-23 23:49:49 +0000
committerrubenwardy <rw@rubenwardy.com>2018-12-23 23:54:20 +0000
commit50889ccca57cea9166ab7c64a83d540d6c0a20ce (patch)
tree57d757bc7250517b8f4b5e38251b9dfc8422bf8c /app/templates
parentb8ca5d24c50f108ea574c89405e2ce2e70ea18af (diff)
downloadcheatdb-50889ccca57cea9166ab7c64a83d540d6c0a20ce.tar.xz
Add topic searching and topic discarding
Diffstat (limited to 'app/templates')
-rw-r--r--app/templates/base.html2
-rw-r--r--app/templates/macros/topics.html22
-rw-r--r--app/templates/todo/topics.html53
3 files changed, 67 insertions, 10 deletions
diff --git a/app/templates/base.html b/app/templates/base.html
index 522e349..b3f467e 100644
--- a/app/templates/base.html
+++ b/app/templates/base.html
@@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}title{% endblock %} - {{ config.USER_APP_NAME }}</title>
<link rel="stylesheet" type="text/css" href="/static/bootstrap.css">
- <link rel="stylesheet" type="text/css" href="/static/custom.css?v=2">
+ <link rel="stylesheet" type="text/css" href="/static/custom.css?v=3">
{% block headextra %}{% endblock %}
</head>
diff --git a/app/templates/macros/topics.html b/app/templates/macros/topics.html
index a3d40c6..66d11b4 100644
--- a/app/templates/macros/topics.html
+++ b/app/templates/macros/topics.html
@@ -1,7 +1,6 @@
-{% macro render_topics_table(topics, show_author=True) -%}
+{% macro render_topics_table(topics, show_author=True, show_discard=False) -%}
<table class="table">
<tr>
- <th>Id</th>
<th></th>
<th>Title</th>
{% if show_author %}<th>Author</th>{% endif %}
@@ -10,8 +9,7 @@
<th>Actions</th>
</tr>
{% for topic in topics %}
- <tr{% if topic.wip %} class="wiptopic"{% endif %}>
- <td>{{ topic.topic_id }}</td>
+ <tr class="{% if topic.wip %}wiptopic{% endif %}{% if topic.discarded %}discardtopic{% endif %}">
<td>
[{{ topic.type.value }}]
</td>
@@ -24,8 +22,20 @@
{% endif %}
<td>{{ topic.name or ""}}</td>
<td>{% if topic.link %}<a href="{{ topic.link }}">{{ topic.link | domain }}</a>{% endif %}</td>
- <td>
- <a 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>
+ <td class="btn-group">
+ <a class="btn btn-primary"
+ 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 %}
+ <a class="btn btn-{% if topic.discarded %}success{% else %}danger{% endif %} topic-discard" data-tid={{ topic.topic_id }}>
+ {% if topic.discarded %}
+ Show
+ {% else %}
+ Discard
+ {% endif %}
+ </a>
+ {% endif %}
</td>
</tr>
{% endfor %}
diff --git a/app/templates/todo/topics.html b/app/templates/todo/topics.html
index 4236a40..d2fcd28 100644
--- a/app/templates/todo/topics.html
+++ b/app/templates/todo/topics.html
@@ -5,11 +5,21 @@ Topics to be Added
{% endblock %}
{% block content %}
+ <a class="btn btn-primary float-right" href="{{ url_for('todo_topics_page', q=query, show_discarded=not show_discarded) }}">
+ {% if not show_discarded %}
+ Show
+ {% else %}
+ Hide
+ {% endif %}
+
+ Discarded Topics
+ </a>
+
<h1>Topics to be Added</h1>
<p>
- {{ total - (topic_count) }} / {{ total }} packages have been added.
- {{ topics | count }} remaining.
+ {{ total - (topic_count) }} / {{ total }} topics have been added as packages to CDB.
+ {{ topic_count }} remaining.
</p>
<form method="GET" action="{{ url_for('todo_topics_page') }}" class="my-4">
@@ -18,7 +28,7 @@ Topics to be Added
</form>
{% from "macros/topics.html" import render_topics_table %}
- {{ render_topics_table(topics) }}
+ {{ render_topics_table(topics, show_discard=True) }}
<ul class="pagination mt-4">
<li class="page-item {% if not prev_url %}disabled{% endif %}">
@@ -37,3 +47,40 @@ Topics to be Added
</li>
</ul>
{% endblock %}
+
+{% block scriptextra %}
+ <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>
+{% endblock %}