From f358d24afbeb1629a4942db8462bc4f0d26a6255 Mon Sep 17 00:00:00 2001 From: suecarmol Date: Fri, 6 Aug 2021 18:44:54 -0500 Subject: [PATCH] Create templates for terms of use change email --- TWLight/emails/tasks.py | 24 +++++++++- ...redesign_terms_update_email-body-html.html | 44 +++++++++++++++++++ ...redesign_terms_update_email-body-text.html | 32 ++++++++++++++ ...y_redesign_terms_update_email-subject.html | 4 ++ TWLight/emails/tests.py | 17 +++++++ .../commands/email_term_of_use_change.py | 20 +++++++++ TWLight/users/signals.py | 4 ++ 7 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 TWLight/emails/templates/emails/library_redesign_terms_update_email-body-html.html create mode 100644 TWLight/emails/templates/emails/library_redesign_terms_update_email-body-text.html create mode 100644 TWLight/emails/templates/emails/library_redesign_terms_update_email-subject.html create mode 100644 TWLight/users/management/commands/email_term_of_use_change.py diff --git a/TWLight/emails/tasks.py b/TWLight/emails/tasks.py index 5cf69f49a3..431ff86941 100644 --- a/TWLight/emails/tasks.py +++ b/TWLight/emails/tasks.py @@ -39,7 +39,11 @@ from TWLight.emails.signals import ContactUs from TWLight.resources.models import AccessCode, Partner from TWLight.users.groups import get_restricted -from TWLight.users.signals import Notice, ProjectPage2021Launch +from TWLight.users.signals import ( + Notice, + ProjectPage2021Launch, + LibraryRedesignTermsUpdate, +) logger = logging.getLogger(__name__) @@ -85,6 +89,10 @@ class ProjectPage2021Email(template_mail.TemplateMail): name = "project_page_2021_email" +class LibraryRedesignTermsUpdateEmail(template_mail.TemplateMail): + name = "library_redesign_terms_update_email" + + @receiver(Reminder.coordinator_reminder) def send_coordinator_reminder_emails(sender, **kwargs): """ @@ -182,6 +190,20 @@ def send_project_page_2021_launch_notice(sender, **kwargs): email.send(user_email, {"username": user_wp_username}) +@receiver(LibraryRedesignTermsUpdate.launch_notice) +def send_library_redesign_terms_update(sender, **kwargs): + """ + Sends the email to notify users that new project pages + have launched. Will only need to be sent once as-is. + """ + user_wp_username = kwargs["user_wp_username"] + user_email = kwargs["user_email"] + + email = LibraryRedesignTermsUpdateEmail() + + email.send(user_email, {"username": user_wp_username}) + + @receiver(comment_was_posted) def send_comment_notification_emails(sender, **kwargs): """ diff --git a/TWLight/emails/templates/emails/library_redesign_terms_update_email-body-html.html b/TWLight/emails/templates/emails/library_redesign_terms_update_email-body-html.html new file mode 100644 index 0000000000..90dcf5a512 --- /dev/null +++ b/TWLight/emails/templates/emails/library_redesign_terms_update_email-body-html.html @@ -0,0 +1,44 @@ +{% load i18n %} + + + + {% comment %}Translators: This email will be sent only once to users to notify them that the terms of service have changed.{% endcomment %} + {% blocktranslate trimmed %} +

Hi,

+ +

+ You are receiving this email because you have an account with The Wikipedia Library + (https://wikipedialibrary.wmflabs.org/). + We are emailing to notify you that we have updated the text of our Terms of Use. +

+ +

+ We have updated the wording of the Terms of Use primarily to make a small change + to who is eligible to use the library. Alongside the recent deployment of a new + user interface (https://meta.wikimedia.org/wiki/Library_Card_platform/Design_improvements), + we are going to be enforcing eligibility requirements for the library more consistently. + Users who don’t quite meet the requirements will no longer be able to file applications + for access to collections and must wait until they meet the criteria in full before + they can use the library. We hope this change will make access more consistent, + and reduce the workload generated by applications from editors who are far below + the activity requirements. +

+ +

+ As part of this update we have also taken the opportunity to clarify and reword + some areas of the Terms of Use which were unclear or outdated. A full list of the + changes can be found at https://phabricator.wikimedia.org/T285760. +

+ +

+ If you no longer wish to use the library, you can delete your account by clicking + the Delete button in the Data section of your user page: + https://wikipedialibrary.wmflabs.org/users/ +

+ +

Thanks,

+ +

The Wikipedia Library team

+ {% endblocktranslate %} + + diff --git a/TWLight/emails/templates/emails/library_redesign_terms_update_email-body-text.html b/TWLight/emails/templates/emails/library_redesign_terms_update_email-body-text.html new file mode 100644 index 0000000000..3ee5eb3249 --- /dev/null +++ b/TWLight/emails/templates/emails/library_redesign_terms_update_email-body-text.html @@ -0,0 +1,32 @@ +{% load i18n %} + +{% comment %}Translators: This email will be sent only once to users to notify them that the terms of service have changed.{% endcomment %} +{% blocktranslate trimmed %} + Hi, + + You are receiving this email because you have an account with The Wikipedia Library + (https://wikipedialibrary.wmflabs.org/). We are emailing to notify you that we have + updated the text of our Terms of Use. + + We have updated the wording of the Terms of Use primarily to make a small change + to who is eligible to use the library. Alongside the recent deployment of a new + user interface (https://meta.wikimedia.org/wiki/Library_Card_platform/Design_improvements), + we are going to be enforcing eligibility requirements for the library more consistently. + Users who don’t quite meet the requirements will no longer be able to file applications + for access to collections and must wait until they meet the criteria in full before + they can use the library. We hope this change will make access more consistent, + and reduce the workload generated by applications from editors who are far below + the activity requirements. + + As part of this update we have also taken the opportunity to clarify and reword + some areas of the Terms of Use which were unclear or outdated. A full list of the + changes can be found at https://phabricator.wikimedia.org/T285760. + + If you no longer wish to use the library, you can delete your account by clicking + the Delete button in the Data section of your user page: + https://wikipedialibrary.wmflabs.org/users/ + + Thanks, + + The Wikipedia Library team +{% endblocktranslate %} diff --git a/TWLight/emails/templates/emails/library_redesign_terms_update_email-subject.html b/TWLight/emails/templates/emails/library_redesign_terms_update_email-subject.html new file mode 100644 index 0000000000..43cba615e4 --- /dev/null +++ b/TWLight/emails/templates/emails/library_redesign_terms_update_email-subject.html @@ -0,0 +1,4 @@ +{% load i18n %} + +{% comment %}Translators: This is the subject of an email which will be sent once to users notifying them of changes in the terms of use.{% endcomment %} +{% trans 'We have updated our Terms of Use' %} diff --git a/TWLight/emails/tests.py b/TWLight/emails/tests.py index 26622e2038..d8e5edd196 100644 --- a/TWLight/emails/tests.py +++ b/TWLight/emails/tests.py @@ -703,3 +703,20 @@ def test_project_page_2021_launch_email_4(self): call_command("project_page_2021_launch") self.assertEqual(len(mail.outbox), 0) + + +class TermsOfUseChangeEmailTest(TestCase): + @classmethod + @wrap_testdata + def setUpTestData(cls): + super().setUpTestData() + editor1 = EditorFactory(user__email="editor@example.com") + editor2 = EditorFactory(user__email="editor2@example.com") + + def test_change_of_terms(self): + """ + Adding an inactive user shouldn't send another email. + """ + call_command("email_term_of_use_change") + + self.assertEqual(len(mail.outbox), 2) diff --git a/TWLight/users/management/commands/email_term_of_use_change.py b/TWLight/users/management/commands/email_term_of_use_change.py new file mode 100644 index 0000000000..648539b364 --- /dev/null +++ b/TWLight/users/management/commands/email_term_of_use_change.py @@ -0,0 +1,20 @@ +from datetime import timedelta + +from django.core.management.base import BaseCommand +from django.utils import timezone +from TWLight.users.signals import LibraryRedesignTermsUpdate +from TWLight.users.models import Authorization, Editor +from django.contrib.auth.models import User + + +class Command(BaseCommand): + help = "Sends an email to all users to let them know the terms of use have changed." + + def handle(self, *args, **options): + editors = Editor.objects.all() + for editor in editors: + LibraryRedesignTermsUpdate.launch_notice.send( + sender=self.__class__, + user_wp_username=editor.wp_username, + user_email=editor.user.email, + ) diff --git a/TWLight/users/signals.py b/TWLight/users/signals.py index b2c7ceb46f..e3de5613f4 100644 --- a/TWLight/users/signals.py +++ b/TWLight/users/signals.py @@ -23,6 +23,10 @@ class ProjectPage2021Launch(object): launch_notice = Signal(providing_args=["user_wp_username", "user_email"]) +class LibraryRedesignTermsUpdate(object): + launch_notice = Signal(providing_args=["user_wp_username", "user_email"]) + + @receiver(pre_save, sender=Authorization) def validate_authorization(sender, instance, **kwargs): """Authorizations are generated by app code instead of ModelForm, so full_clean() before saving."""