From 67a229b8a3152329917a0e783822c71d4a53d978 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Fri, 6 Jul 2018 23:15:56 +0100 Subject: [PATCH] Add WIP forum topic support --- app/models.py | 2 ++ app/scss/components.scss | 4 ++++ app/tasks/forumtasks.py | 7 ++++-- app/templates/macros/topictable.html | 11 +++++++-- app/templates/packages/view.html | 1 + app/templates/todo/list.html | 2 +- app/templates/users/user_profile_page.html | 5 +--- app/views/packages/todo.py | 2 +- migrations/versions/9e2ac631efb0_.py | 28 ++++++++++++++++++++++ 9 files changed, 52 insertions(+), 10 deletions(-) create mode 100644 migrations/versions/9e2ac631efb0_.py diff --git a/app/models.py b/app/models.py index 338b4f0b..39a86478 100644 --- a/app/models.py +++ b/app/models.py @@ -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) diff --git a/app/scss/components.scss b/app/scss/components.scss index aac5e26b..a90a510a 100644 --- a/app/scss/components.scss +++ b/app/scss/components.scss @@ -451,3 +451,7 @@ table.fancyTable tfoot td { .table-topalign td { vertical-align: top; } + +.wiptopic a { + color: #7ac; +} diff --git a/app/tasks/forumtasks.py b/app/tasks/forumtasks.py index 5513fb2b..338ffa28 100644 --- a/app/tasks/forumtasks.py +++ b/app/tasks/forumtasks.py @@ -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"] diff --git a/app/templates/macros/topictable.html b/app/templates/macros/topictable.html index 7ae8a359..8a6b31c4 100644 --- a/app/templates/macros/topictable.html +++ b/app/templates/macros/topictable.html @@ -2,6 +2,7 @@ + {% if show_author %}{% endif %} @@ -9,9 +10,15 @@ {% for topic in topics %} - + - + + {% if show_author %} {% endif %} diff --git a/app/templates/packages/view.html b/app/templates/packages/view.html index f69b5cfc..df31ce1c 100644 --- a/app/templates/packages/view.html +++ b/app/templates/packages/view.html @@ -296,6 +296,7 @@ {{ t.title }} by {{ t.author.display_name }} + {% if t.wip %}[WIP]{% endif %} {% endfor %} diff --git a/app/templates/todo/list.html b/app/templates/todo/list.html index f2172a64..5e50c2e2 100644 --- a/app/templates/todo/list.html +++ b/app/templates/todo/list.html @@ -65,6 +65,6 @@

There are {{ topics_to_add }} packages - 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.

{% endblock %} diff --git a/app/templates/users/user_profile_page.html b/app/templates/users/user_profile_page.html index 636a6100..81b59347 100644 --- a/app/templates/users/user_profile_page.html +++ b/app/templates/users/user_profile_page.html @@ -104,12 +104,9 @@

- 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.

- - {% from "macros/topictable.html" import render_topictable %} {{ render_topictable(topics_to_add, show_author=False) }}
diff --git a/app/views/packages/todo.py b/app/views/packages/todo.py index 84cfef4f..314c3741 100644 --- a/app/views/packages/todo.py +++ b/app/views/packages/todo.py @@ -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) diff --git a/migrations/versions/9e2ac631efb0_.py b/migrations/versions/9e2ac631efb0_.py new file mode 100644 index 00000000..1b10d0ea --- /dev/null +++ b/migrations/versions/9e2ac631efb0_.py @@ -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 ###
Id TitleAuthorNameActions
{{ topic.topic_id }}[{{ topic.type.value }}] {{ topic.title }} + [{{ topic.type.value }}] + + {{ topic.title }} + {% if topic.wip %}[WIP]{% endif %} + {{ topic.author.display_name}}