Skip to content

Commit

Permalink
Merge pull request #3737 from vkWeb/email/published_channel
Browse files Browse the repository at this point in the history
Add channel link to the channel published email
  • Loading branch information
rtibbles authored Nov 1, 2022
2 parents 7e88e7e + c1fd3f2 commit 172eb66
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
{% load i18n %}
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
{% autoescape off %}
<p>{% blocktrans with name=user.first_name %}Hello {{ name }},{% endblocktrans %}</p>

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

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

<p>{% blocktrans with notes=notes %}Version notes: {{ notes }}{% endblocktrans %}</p>

<p>
{% translate "Thanks for using Kolibri Studio!" %}
<br>
{% translate "The Learning Equality Team" %}
</p>

<p>{% translate "You are receiving this email because you are subscribed to this channel." %}</p>
{% endautoescape %}
</body>
</html>

This file was deleted.

12 changes: 8 additions & 4 deletions contentcuration/contentcuration/utils/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -94,16 +95,19 @@ 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})
user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL, )
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, 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', {'channel': channel, 'user': user, 'token': token, 'notes': version_notes})
user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL, )
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, html_message=message)


def create_content_database(channel, force, user_id, force_exercises, progress_tracker=None):
Expand Down

0 comments on commit 172eb66

Please sign in to comment.