Add WIP forum topic support

This commit is contained in:
rubenwardy 2018-07-06 23:15:56 +01:00
parent 9dd3570a52
commit 67a229b8a3
No known key found for this signature in database
GPG Key ID: A1E29D52FF81513C
9 changed files with 52 additions and 10 deletions

View File

@ -768,6 +768,8 @@ class ForumTopic(db.Model):
author_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False)
author = db.relationship("User")
wip = db.Column(db.Boolean, server_default="0")
type = db.Column(db.Enum(PackageType), nullable=False)
title = db.Column(db.String(200), nullable=False)
name = db.Column(db.String(30), nullable=True)

View File

@ -451,3 +451,7 @@ table.fancyTable tfoot td {
.table-topalign td {
vertical-align: top;
}
.wiptopic a {
color: #7ac;
}

View File

@ -87,8 +87,10 @@ def importTopicList():
links_by_id = getLinksFromModSearch()
info_by_id = {}
getTopicsFromForum(11, out=info_by_id, extra={ 'type': PackageType.MOD })
getTopicsFromForum(15, out=info_by_id, extra={ 'type': PackageType.GAME })
getTopicsFromForum(11, out=info_by_id, extra={ 'type': PackageType.MOD, 'wip': False })
getTopicsFromForum(9, out=info_by_id, extra={ 'type': PackageType.MOD, 'wip': True })
getTopicsFromForum(15, out=info_by_id, extra={ 'type': PackageType.GAME, 'wip': False })
getTopicsFromForum(50, out=info_by_id, extra={ 'type': PackageType.GAME, 'wip': True })
# Caches
username_to_user = {}
@ -131,6 +133,7 @@ def importTopicList():
topic.title = title
topic.name = name
topic.link = link
topic.wip = info["wip"]
topic.posts = info["posts"]
topic.views = info["views"]
topic.created_at = info["date"]

View File

@ -2,6 +2,7 @@
<table>
<tr>
<th>Id</th>
<th></th>
<th>Title</th>
{% if show_author %}<th>Author</th>{% endif %}
<th>Name</th>
@ -9,9 +10,15 @@
<th>Actions</th>
</tr>
{% for topic in topics %}
<tr>
<tr{% if topic.wip %} class="wiptopic"{% endif %}>
<td>{{ topic.topic_id }}</td>
<td>[{{ topic.type.value }}] <a href="https://forum.minetest.net/viewtopic.php?t={{ topic.topic_id}}">{{ topic.title }}</a></td>
<td>
[{{ topic.type.value }}]
</td>
<td>
<a href="https://forum.minetest.net/viewtopic.php?t={{ topic.topic_id}}">{{ topic.title }}</a>
{% if topic.wip %}[WIP]{% endif %}
</td>
{% if show_author %}
<td><a href="{{ url_for('user_profile_page', username=topic.author.username) }}">{{ topic.author.display_name}}</a></td>
{% endif %}

View File

@ -296,6 +296,7 @@
<a href="https://forum.minetest.net/viewtopic.php?t={{ t.topic_id }}">
{{ t.title }} by {{ t.author.display_name }}
</a>
{% if t.wip %}[WIP]{% endif %}
</li>
{% endfor %}
</ul>

View File

@ -65,6 +65,6 @@
<p>
There are
<a href="{{ url_for('todo_topics_page') }}">{{ topics_to_add }} packages</a>
to be added to cdb, based on forum topics picked up by Krock's mod search.
to be added to cdb, based on cdb's forum parser.
</p>
{% endblock %}

View File

@ -104,12 +104,9 @@
<div class="box-body">
<p>
List of your topics without a matching package.
Powered by Krock's Mod Search.
List of your forum topics which do not have a matching package.
</p>
{% from "macros/topictable.html" import render_topictable %}
{{ render_topictable(topics_to_add, show_author=False) }}
</div>

View File

@ -58,7 +58,7 @@ def todo_topics_page():
topics = ForumTopic.query \
.filter(~ db.exists().where(Package.forums==ForumTopic.topic_id)) \
.order_by(db.asc(ForumTopic.name), db.asc(ForumTopic.title)) \
.order_by(db.asc(ForumTopic.wip), db.asc(ForumTopic.name), db.asc(ForumTopic.title)) \
.all()
return render_template("todo/topics.html", topics=topics, total=total)

View File

@ -0,0 +1,28 @@
"""empty message
Revision ID: 9e2ac631efb0
Revises: 11b6ef362f98
Create Date: 2018-07-06 23:16:50.507010
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '9e2ac631efb0'
down_revision = '11b6ef362f98'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('forum_topic', sa.Column('wip', sa.Boolean(), nullable=False, server_default="0"))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('forum_topic', 'wip')
# ### end Alembic commands ###