From 15d2f7ec4f45a03f64490a1395bdf0547f500c17 Mon Sep 17 00:00:00 2001 From: Vivek Agrawal Date: Fri, 14 Oct 2022 15:56:38 +0530 Subject: [PATCH 1/2] Add channel link to the channel published email --- .../templates/registration/channel_published_email.txt | 6 +++++- contentcuration/contentcuration/utils/publish.py | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/contentcuration/contentcuration/templates/registration/channel_published_email.txt b/contentcuration/contentcuration/templates/registration/channel_published_email.txt index b86cea7d93..ddabab61b1 100644 --- a/contentcuration/contentcuration/templates/registration/channel_published_email.txt +++ b/contentcuration/contentcuration/templates/registration/channel_published_email.txt @@ -3,7 +3,11 @@ {% autoescape off %} {% blocktrans with name=user.first_name %}Hello {{ name }},{% endblocktrans %} -{% blocktrans with channel_name=channel.name %}{{ channel_name }} has finished publishing! Here is the channel token (for importing it into Kolibri):{% endblocktrans %} +{% blocktrans with channel_name=channel.name %}{{ channel_name }} has finished publishing!{% endblocktrans %} + +{% translate "Link to the channel: " %}{{ domain }}{% url 'channel' channel_id=channel.pk %} + +{% translate "Here is the channel token (for importing it into Kolibri):" %} {% blocktrans with channel_token=token %}Token: {{ channel_token }}{% endblocktrans %} diff --git a/contentcuration/contentcuration/utils/publish.py b/contentcuration/contentcuration/utils/publish.py index 6593c14bc8..0455083597 100644 --- a/contentcuration/contentcuration/utils/publish.py +++ b/contentcuration/contentcuration/utils/publish.py @@ -14,6 +14,7 @@ from itertools import chain from django.conf import settings +from django.contrib.sites.models import Site from django.core.files import File from django.core.files.storage import default_storage as storage from django.core.management import call_command @@ -94,15 +95,18 @@ def send_emails(channel, user_id, version_notes=''): subject = render_to_string('registration/custom_email_subject.txt', {'subject': _('Kolibri Studio Channel Published')}) token = channel.secret_tokens.filter(is_primary=True).first() token = '{}-{}'.format(token.token[:5], token.token[-5:]) + domain = "https://{}".format(Site.objects.get_current().domain) if user_id: user = ccmodels.User.objects.get(pk=user_id) - message = render_to_string('registration/channel_published_email.txt', {'channel': channel, 'user': user, 'token': token, 'notes': version_notes}) + message = render_to_string('registration/channel_published_email.txt', + {'channel': channel, 'user': user, 'token': token, 'notes': version_notes, 'domain': domain}) user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL, ) else: # Email all users about updates to channel for user in itertools.chain(channel.editors.all(), channel.viewers.all()): - message = render_to_string('registration/channel_published_email.txt', {'channel': channel, 'user': user, 'token': token, 'notes': version_notes}) + message = render_to_string('registration/channel_published_email.txt', + {'channel': channel, 'user': user, 'token': token, 'notes': version_notes, 'domain': domain}) user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL, ) From c1fd3f299432fd36e6250aafdb0823f7a3977f80 Mon Sep 17 00:00:00 2001 From: Vivek Agrawal Date: Mon, 31 Oct 2022 17:55:00 +0530 Subject: [PATCH 2/2] Wrap channel name in tag & hyperlink between brackets --- .../registration/channel_published_email.html | 31 +++++++++++++++++++ .../registration/channel_published_email.txt | 27 ---------------- .../contentcuration/utils/publish.py | 8 ++--- 3 files changed, 35 insertions(+), 31 deletions(-) create mode 100644 contentcuration/contentcuration/templates/registration/channel_published_email.html delete mode 100644 contentcuration/contentcuration/templates/registration/channel_published_email.txt diff --git a/contentcuration/contentcuration/templates/registration/channel_published_email.html b/contentcuration/contentcuration/templates/registration/channel_published_email.html new file mode 100644 index 0000000000..476abbc1bd --- /dev/null +++ b/contentcuration/contentcuration/templates/registration/channel_published_email.html @@ -0,0 +1,31 @@ + +{% load i18n %} + + + + + + + {% autoescape off %} +

{% blocktrans with name=user.first_name %}Hello {{ name }},{% endblocktrans %}

+ +

{% blocktrans with channel_name=channel.name %}{{ channel_name }}{% endblocktrans %} ({{ domain }}{% url 'channel' channel_id=channel.pk %}) {% translate "has finished publishing! Here is the channel token (for importing it into Kolibri):" %}

+ +

+ {% blocktrans with channel_token=token %}Token: {{ channel_token }}{% endblocktrans %} +
+ {% blocktrans with channel_id=channel.pk %}ID (for Kolibri version 0.6.0 and below): {{ channel_id }}{% endblocktrans %} +

+ +

{% blocktrans with notes=notes %}Version notes: {{ notes }}{% endblocktrans %}

+ +

+ {% translate "Thanks for using Kolibri Studio!" %} +
+ {% translate "The Learning Equality Team" %} +

+ +

{% translate "You are receiving this email because you are subscribed to this channel." %}

+ {% endautoescape %} + + diff --git a/contentcuration/contentcuration/templates/registration/channel_published_email.txt b/contentcuration/contentcuration/templates/registration/channel_published_email.txt deleted file mode 100644 index ddabab61b1..0000000000 --- a/contentcuration/contentcuration/templates/registration/channel_published_email.txt +++ /dev/null @@ -1,27 +0,0 @@ -{% load i18n %} - -{% autoescape off %} -{% blocktrans with name=user.first_name %}Hello {{ name }},{% endblocktrans %} - -{% blocktrans with channel_name=channel.name %}{{ channel_name }} has finished publishing!{% endblocktrans %} - -{% translate "Link to the channel: " %}{{ domain }}{% url 'channel' channel_id=channel.pk %} - -{% translate "Here is the channel token (for importing it into Kolibri):" %} - -{% blocktrans with channel_token=token %}Token: {{ channel_token }}{% endblocktrans %} - -{% blocktrans with channel_id=channel.pk %}ID (for Kolibri version 0.6.0 and below): {{ channel_id }}{% endblocktrans %} - -{% blocktrans with notes=notes %}Version notes: {{ notes }}{% endblocktrans %} - - -{% translate "Thanks for using Kolibri Studio!" %} - -{% translate "The Learning Equality Team" %} - - - -{% translate "You are receiving this email because you are subscribed to this channel." %} - -{% endautoescape %} diff --git a/contentcuration/contentcuration/utils/publish.py b/contentcuration/contentcuration/utils/publish.py index 0455083597..b3bbad1f37 100644 --- a/contentcuration/contentcuration/utils/publish.py +++ b/contentcuration/contentcuration/utils/publish.py @@ -99,15 +99,15 @@ def send_emails(channel, user_id, version_notes=''): if user_id: user = ccmodels.User.objects.get(pk=user_id) - message = render_to_string('registration/channel_published_email.txt', + message = render_to_string('registration/channel_published_email.html', {'channel': channel, 'user': user, 'token': token, 'notes': version_notes, 'domain': domain}) - user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL, ) + user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL, html_message=message) else: # Email all users about updates to channel for user in itertools.chain(channel.editors.all(), channel.viewers.all()): - message = render_to_string('registration/channel_published_email.txt', + message = render_to_string('registration/channel_published_email.html', {'channel': channel, 'user': user, 'token': token, 'notes': version_notes, 'domain': domain}) - user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL, ) + user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL, html_message=message) def create_content_database(channel, force, user_id, force_exercises, progress_tracker=None):