Skip to content

Commit 85b50a9

Browse files
committed
discourse: use 0 rather than None as an empty topic_id
1 parent a313b86 commit 85b50a9

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

appstore/commands.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def import_apps(app_type):
138138
},
139139
created_at=parse_datetime(app['created_at']),
140140
developer=dev,
141+
discourse_topic_id=0,
141142
hearts=app['hearts'],
142143
releases=[
143144
*([Release(
@@ -305,6 +306,7 @@ def import_app_from_locker(locker_app):
305306
title=locker_app['title'],
306307
type=locker_app['type'],
307308
website=None,
309+
discourse_topic_id=0,
308310
visible=False,
309311
)
310312
db.session.add(app)

appstore/developer_portal_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ def submit_new_app():
177177
companions={}, # companions not supported yet
178178
created_at=datetime.datetime.utcnow(),
179179
developer=developer,
180+
discourse_topic_id=0,
180181
hearts=0,
181182
releases=[],
182183
icon_large=upload_asset(request.files['large_icon'], request.files["large_icon"].content_type),

appstore/discourse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ def _create_or_post_to_topic(app, is_generated, text):
2828
# should go in their own topic later?
2929
return
3030

31-
if app.discourse_topic_id is -1:
31+
if app.discourse_topic_id == -1:
3232
# We have manually set that we don't want a Discourse topic at all
3333
# for this app. Don't post at all.
3434
return
3535

36-
if app.discourse_topic_id is None:
36+
if app.discourse_topic_id == 0:
3737
# This app doesn't have a topic of its own yet; create a new one,
3838
# and store it in the database.
3939

migrations/versions/89e32c02be56_add_discourse_topic_id.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
def upgrade():
2020
# ### commands auto generated by Alembic - please adjust! ###
2121
op.add_column('apps', sa.Column('discourse_topic_id', sa.Integer(), nullable=True))
22+
op.execute("""
23+
UPDATE apps
24+
SET discourse_topic_id = 0
25+
""")
26+
2227
# ### end Alembic commands ###
2328

2429

0 commit comments

Comments
 (0)