From 7867b5b346b2ee3ea18864720f2303f93d0f6a68 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Thu, 9 May 2024 19:21:45 +1200 Subject: [PATCH] add language choices to UI - logged in users only #51 --- app/community/routes.py | 8 ++++---- app/post/routes.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/community/routes.py b/app/community/routes.py index b05b5993..cb44895c 100644 --- a/app/community/routes.py +++ b/app/community/routes.py @@ -517,7 +517,7 @@ def add_discussion_post(actor): else: form.communities.data = community.id form.notify_author.data = True - form.language_id.data = current_user.language_id if current_user.language_id else english_language_id() + form.language_id.data = current_user.language_id if current_user.is_authenticated and current_user.language_id else english_language_id() if community.posting_warning: flash(community.posting_warning) @@ -599,7 +599,7 @@ def add_image_post(actor): else: form.communities.data = community.id form.notify_author.data = True - form.language_id.data = current_user.language_id if current_user.language_id else english_language_id() + form.language_id.data = current_user.language_id if current_user.is_authenticated and current_user.language_id else english_language_id() return render_template('community/add_image_post.html', title=_('Add post to community'), form=form, community=community, markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor, @@ -679,7 +679,7 @@ def add_link_post(actor): else: form.communities.data = community.id form.notify_author.data = True - form.language_id.data = current_user.language_id if current_user.language_id else english_language_id() + form.language_id.data = current_user.language_id if current_user.is_authenticated and current_user.language_id else english_language_id() return render_template('community/add_link_post.html', title=_('Add post to community'), form=form, community=community, markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor, @@ -759,7 +759,7 @@ def add_video_post(actor): else: form.communities.data = community.id form.notify_author.data = True - form.language_id.data = current_user.language_id if current_user.language_id else english_language_id() + form.language_id.data = current_user.language_id if current_user.is_authenticated and current_user.language_id else english_language_id() return render_template('community/add_video_post.html', title=_('Add post to community'), form=form, community=community, markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor, diff --git a/app/post/routes.py b/app/post/routes.py index 35cbdac0..e718a642 100644 --- a/app/post/routes.py +++ b/app/post/routes.py @@ -229,7 +229,7 @@ def show_post(post_id: int): else: replies = post_replies(post.id, sort) form.notify_author.data = True - form.language_id.data = current_user.language_id if current_user.language_id else english_language_id() + form.language_id.data = current_user.language_id if current_user.is_authenticated and current_user.language_id else english_language_id() og_image = post.image.source_url if post.image_id else None description = shorten_string(markdown_to_text(post.body), 150) if post.body else None @@ -771,7 +771,7 @@ def add_reply(post_id: int, comment_id: int): return redirect(url_for('post.continue_discussion', post_id=post_id, comment_id=reply.parent_id)) else: form.notify_author.data = True - form.language_id.data = current_user.language_id if current_user.language_id else english_language_id() + form.language_id.data = current_user.language_id if current_user.is_authenticated and current_user.language_id else english_language_id() return render_template('post/add_reply.html', title=_('Discussing %(title)s', title=post.title), post=post, is_moderator=is_moderator, form=form, comment=in_reply_to, markdown_editor=current_user.is_authenticated and current_user.markdown_editor,