diff --git a/app/models.py b/app/models.py
index 488cc35..9c17da6 100644
--- a/app/models.py
+++ b/app/models.py
@@ -804,6 +804,7 @@ class ForumTopic(db.Model):
author = db.relationship("User")
wip = db.Column(db.Boolean, server_default="0")
+ discarded = db.Column(db.Boolean, server_default="0")
type = db.Column(db.Enum(PackageType), nullable=False)
title = db.Column(db.String(200), nullable=False)
@@ -836,6 +837,7 @@ class ForumTopic(db.Model):
"posts": self.posts,
"views": self.views,
"is_wip": self.wip,
+ "discarded": self.discarded,
"created_at": self.created_at.isoformat(),
}
diff --git a/app/scss/components.scss b/app/scss/components.scss
index 9724914..31b9600 100644
--- a/app/scss/components.scss
+++ b/app/scss/components.scss
@@ -80,6 +80,14 @@
color: #7ac;
}
+.discardtopic {
+ text-decoration: line-through;
+ a {
+ color: #7ac;
+ }
+ filter: brightness(0.5);
+}
+
.editor-toolbar, .editor-toolbar.fullscreen {
margin-bottom: 0 !important;
background-color: #444 !important;
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 @@
{% block title %}title{% endblock %} - {{ config.USER_APP_NAME }}
-
+
{% block headextra %}{% endblock %}
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) -%}
- Id
Title
{% if show_author %}Author {% endif %}
@@ -10,8 +9,7 @@
Actions
{% for topic in topics %}
-
- {{ topic.topic_id }}
+
[{{ topic.type.value }}]
@@ -24,8 +22,20 @@
{% endif %}
{{ topic.name or ""}}
{% if topic.link %}{{ topic.link | domain }} {% endif %}
-
- Create
+
+
+ Create
+
+ {% if show_discard %}
+
+ {% if topic.discarded %}
+ Show
+ {% else %}
+ Discard
+ {% endif %}
+
+ {% endif %}
{% 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 %}
+
+ {% if not show_discarded %}
+ Show
+ {% else %}
+ Hide
+ {% endif %}
+
+ Discarded Topics
+
+
Topics to be Added
- {{ 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.
{% from "macros/topics.html" import render_topics_table %}
- {{ render_topics_table(topics) }}
+ {{ render_topics_table(topics, show_discard=True) }}
{% endblock %}
+
+{% block scriptextra %}
+
+
+{% endblock %}
diff --git a/app/utils.py b/app/utils.py
index cb6a315..21c7fd6 100644
--- a/app/utils.py
+++ b/app/utils.py
@@ -68,7 +68,10 @@ def make_flask_user_password(plaintext_str):
import bcrypt
plaintext = plaintext_str.encode("UTF-8")
password = bcrypt.hashpw(plaintext, bcrypt.gensalt())
- return password.decode("UTF-8")
+ if isinstance(password, str):
+ return password
+ else:
+ return password.decode("UTF-8")
def _do_login_user(user, remember_me=False):
def _call_or_get(v):
diff --git a/app/views/api.py b/app/views/api.py
index 9223c8b..04f58d6 100644
--- a/app/views/api.py
+++ b/app/views/api.py
@@ -19,7 +19,7 @@ from flask import *
from flask_user import *
from app import app
from app.models import *
-from app.utils import is_package_page
+from app.utils import is_package_page, rank_required
from .packages import QueryBuilder
@app.route("/api/packages/")
@@ -43,3 +43,18 @@ def api_topics_page():
.order_by(db.asc(ForumTopic.wip), db.asc(ForumTopic.name), db.asc(ForumTopic.title))
pkgs = [t.getAsDictionary() for t in query.all()]
return jsonify(pkgs)
+
+
+@app.route("/api/topic_discard/", methods=["POST"])
+@rank_required(UserRank.EDITOR)
+def topic_set_discard():
+ tid = request.args.get("tid")
+ discard = request.args.get("discard")
+ if tid is None or discard is None:
+ abort(400)
+
+ topic = ForumTopic.query.get(tid)
+ topic.discarded = discard == "true"
+ db.session.commit()
+
+ return jsonify(topic.getAsDictionary())
diff --git a/app/views/packages/todo.py b/app/views/packages/todo.py
index 596e83a..a29a46e 100644
--- a/app/views/packages/todo.py
+++ b/app/views/packages/todo.py
@@ -54,11 +54,16 @@ def todo_page():
@app.route("/todo/topics/")
@login_required
def todo_topics_page():
- total = ForumTopic.query.count()
+ query = ForumTopic.query
- query = ForumTopic.query \
- .filter(~ db.exists().where(Package.forums==ForumTopic.topic_id)) \
- .order_by(db.asc(ForumTopic.wip), db.asc(ForumTopic.name), db.asc(ForumTopic.title))
+ show_discarded = request.args.get("show_discarded") == "True"
+ if not show_discarded:
+ query = query.filter_by(discarded=False)
+
+ total = query.count()
+
+ query = query.filter(~ db.exists().where(Package.forums==ForumTopic.topic_id)) \
+ .order_by(db.asc(ForumTopic.wip), db.asc(ForumTopic.name), db.asc(ForumTopic.title))
topic_count = query.count()
@@ -75,5 +80,5 @@ def todo_topics_page():
if query.has_prev else None
return render_template("todo/topics.html", topics=query.items, total=total, \
- topic_count=topic_count, query=search, \
+ topic_count=topic_count, query=search, show_discarded=show_discarded, \
next_url=next_url, prev_url=prev_url, page=page, page_max=query.pages)
diff --git a/migrations/versions/a791b9b74a4c_.py b/migrations/versions/a791b9b74a4c_.py
new file mode 100644
index 0000000..d4f9436
--- /dev/null
+++ b/migrations/versions/a791b9b74a4c_.py
@@ -0,0 +1,23 @@
+"""empty message
+
+Revision ID: a791b9b74a4c
+Revises: 44e138485931
+Create Date: 2018-12-23 23:52:02.010281
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'a791b9b74a4c'
+down_revision = '44e138485931'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ op.add_column('forum_topic', sa.Column('discarded', sa.Boolean(), server_default='0', nullable=True))
+
+def downgrade():
+ op.drop_column('forum_topic', 'discarded')