Skip to content

Instantly share code, notes, and snippets.

@mathjazz
Created March 15, 2024 12:27
Show Gist options
  • Save mathjazz/2075010987abf5861d88df4336db447e to your computer and use it in GitHub Desktop.
Save mathjazz/2075010987abf5861d88df4336db447e to your computer and use it in GitHub Desktop.
Email Mozilla L10n event: LR-83
"""
Send email to all users who submitted at least 5 translations that are now approved in the last 12 months.
"""
from django.core.mail import EmailMultiAlternatives
from pontoon.base.models import *
from datetime import datetime
MIN_COUNT = 5
START_DATE = datetime(2023,3,15)
contributors = (
Translation.objects.filter(
date__gte=START_DATE,
approved=True,
)
.values("user")
.annotate(count=Count("user"))
.distinct()
)
contributors_with_min_count = [c["user"] for c in contributors if c["count"] >= MIN_COUNT]
users = User.objects.filter(pk__in=contributors_with_min_count).exclude(profile__system_user=True)
emails = [u.contact_email for u in users]
subject = "Interview: Three women in localization"
text = u"""Hello localizers,
We are excited to announce that we are organizing a live interview hosting Ayanaa, Delphine and Peiying from the Mozilla localization team on Wednesday, March 27 at 9pm UTC. We will cover topics such as: what we work on, how we got involved, and the importance of diversity in open source and tech.
The meeting will be recorded to accommodate for availability and timezone issues. Here is the link to both the live and recorded session:
https://mzl.la/three-women-in-localization-2024-03-27
If you’d like to submit any questions beforehand, you may do so here:
https://forms.gle/R7jUci94WPWNb6WF7
You will be able to ask questions live in our l10n Matrix channel, too:
https://chat.mozilla.org/#/room/#l10n-community:mozilla.org
Thank you,
Mozilla L10n Team
"""
html = u"""Hello localizers,
<br><br>
We are excited to announce that we are organizing a live interview hosting Ayanaa, Delphine and Peiying from the Mozilla localization team on Wednesday, March 27 at 9pm UTC. We will cover topics such as: what we work on, how we got involved, and the importance of diversity in open source and tech.
<br><br>
The meeting will be recorded to accommodate for availability and timezone issues. <a href="https://mzl.la/three-women-in-localization-2024-03-27">Here</a> is the link to both the live and recorded session.
<br><br>
If you’d like to submit any questions beforehand, you may do so <a href="https://forms.gle/R7jUci94WPWNb6WF7">here</a>.
<br><br>
You will be able to ask questions live in our <a href="https://chat.mozilla.org/#/room/#l10n-community:mozilla.org">l10n Matrix channel</a>, too.
<br><br>
Thank you,<br>
Mozilla L10n Team
"""
for email in emails:
msg = EmailMultiAlternatives(
subject=subject,
body=text,
from_email='Mozilla L10n Team <[email protected]>',
# Do not put the entire list into the "to" field
# or everyone will see all email addresses.
to=[email]
)
msg.attach_alternative(html, 'text/html')
msg.send()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment