adding topic crash

This commit is contained in:
rimu 2024-01-14 12:47:49 +13:00
parent f7022fd6a6
commit becb11ea0d
2 changed files with 7 additions and 1 deletions

View file

@ -339,10 +339,16 @@ def admin_topics():
@permission_required('administer all communities')
def admin_topic_add():
form = EditTopicForm()
form.add_community.choices = communities_for_form()
if form.validate_on_submit():
topic = Topic(name=form.name.data, num_communities=0)
db.session.add(topic)
db.session.commit()
if form.add_community.data:
community = Community.query.get(form.add_community.data)
community.topic_id = topic.id
topic.num_communities += 1
db.session.commit()
flash(_('Saved'))
return redirect(url_for('admin.admin_topics'))

View file

@ -817,7 +817,7 @@ def post_reply_edit(post_id: int, comment_id: int):
return redirect(url_for('activitypub.post_ap', post_id=post.id))
else:
form.body.data = post_reply.body
form.notify_author.data = not post_reply.notify_author
form.notify_author.data = post_reply.notify_author
return render_template('post/post_reply_edit.html', title=_('Edit comment'), form=form, post=post, post_reply=post_reply,
comment=comment, markdown_editor=True, moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.get_id()))