From 654c4fe42eb73b9687e58be6d9f15d612ef1d507 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Thu, 8 Aug 2024 19:26:07 +1200 Subject: [PATCH] tidy ups and tweaks to suggest topics form #281 --- app/email.py | 12 ++++++ app/templates/list_topics.html | 56 +++++++++++++------------ app/templates/topic/suggest_topics.html | 2 +- app/topic/forms.py | 11 +++-- app/topic/routes.py | 27 ++++-------- 5 files changed, 56 insertions(+), 52 deletions(-) diff --git a/app/email.py b/app/email.py index 7ff7b5d1..c4d3a156 100644 --- a/app/email.py +++ b/app/email.py @@ -39,6 +39,18 @@ def send_welcome_email(user, application_required): html_body=render_template('email/welcome.html', user=user, application_required=application_required)) +def send_topic_suggestion(communities_for_topic, user, recipients, subject, topic_name): + send_email(subject, + sender=f'{g.site.name} <{current_app.config["MAIL_FROM"]}>', + recipients=recipients, + text_body=render_template('email/suggested_topic.txt', site_name=g.site.name, + current_user_name=user.user_name, topic_name=topic_name, + communities_for_topic=communities_for_topic), + html_body=render_template('email/suggested_topic.html', site_name=g.site.name, + current_user_name=user.user_name, topic_name=topic_name, + communities_for_topic=communities_for_topic, + domain=current_app.config['SERVER_NAME'])) + @celery.task def send_async_email(subject, sender, recipients, text_body, html_body, reply_to): if 'ngrok.app' in sender: # for local development diff --git a/app/templates/list_topics.html b/app/templates/list_topics.html index 6954176b..ec070865 100644 --- a/app/templates/list_topics.html +++ b/app/templates/list_topics.html @@ -7,32 +7,34 @@ {% set active_child = 'list_topics' -%} {% block app_content -%} -{% if len(topics) > 0 -%} - {% macro render_topic(topic, depth) -%} -
{{ _('There are no communities yet.') }}
-{% endif -%} - - + +{{ _('There are no communities yet.') }}
+ {% endif -%} +{{ _('Explore communities') }}
+ {% if current_user.is_authenticated and current_user.trustworthy() -%} + + {% endif -%} {% endblock -%} diff --git a/app/templates/topic/suggest_topics.html b/app/templates/topic/suggest_topics.html index ac3e54a4..c7262e8a 100644 --- a/app/templates/topic/suggest_topics.html +++ b/app/templates/topic/suggest_topics.html @@ -11,7 +11,7 @@