Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion TWLight/emails/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{% load i18n %}
<!DOCTYPE html>
<html>
<body>
{% comment %}Translators: This email will be sent only once to users to notify them that the terms of service have changed.{% endcomment %}
{% blocktranslate trimmed %}
<p>Hi,</p>

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

<p>
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 (<a href="https://meta.wikimedia.org/wiki/Library_Card_platform/Design_improvements">https://meta.wikimedia.org/wiki/Library_Card_platform/Design_improvements</a>),
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.
</p>

<p>
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 <a href="https://phabricator.wikimedia.org/T285760">https://phabricator.wikimedia.org/T285760</a>.
</p>

<p>
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:
<a href="https://wikipedialibrary.wmflabs.org/users/">https://wikipedialibrary.wmflabs.org/users/</a>
</p>

<p>Thanks,</p>

<p>The Wikipedia Library team</p>
{% endblocktranslate %}
</body>
</html>
Original file line number Diff line number Diff line change
@@ -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 %}
Original file line number Diff line number Diff line change
@@ -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' %}
17 changes: 17 additions & 0 deletions TWLight/emails/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
20 changes: 20 additions & 0 deletions TWLight/users/management/commands/email_term_of_use_change.py
Original file line number Diff line number Diff line change
@@ -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,
)
4 changes: 4 additions & 0 deletions TWLight/users/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down