diff --git a/app/experimenter/experiments/constants.py b/app/experimenter/experiments/constants.py index 68f03f9a97..6069c6595f 100644 --- a/app/experimenter/experiments/constants.py +++ b/app/experimenter/experiments/constants.py @@ -754,6 +754,10 @@ class ExperimentConstants(object): {attention}""" ) + INTENT_TO_SHIP_EMAIL_SUBJECT = ( + "SHIELD Study Intent to ship: {name} {version} {channel}" + ) + BUGZILLA_OVERVIEW_TEMPLATE = ( """ {experiment.name} diff --git a/app/experimenter/experiments/email.py b/app/experimenter/experiments/email.py index 62d0f6641e..1f974c895e 100644 --- a/app/experimenter/experiments/email.py +++ b/app/experimenter/experiments/email.py @@ -1,7 +1,10 @@ +import datetime from urllib.parse import urljoin from django.conf import settings from django.core.mail import send_mail +from django.urls import reverse +from django.template.loader import render_to_string from experimenter.experiments.models import Experiment @@ -22,3 +25,68 @@ def send_review_email(experiment_name, experiment_url, needs_attention): [settings.EMAIL_REVIEW], fail_silently=False, ) + + +def send_intent_to_ship_email(experiment_id, experiment_url): + + def make_url(uri): + return urljoin("https://{}".format(settings.HOSTNAME), uri) + + # XXX Is there already a routine for doing this? + def format_date(date, format="%Y-%m-%d"): + assert isinstance(date, datetime.date) + return date.strftime(format) + + experiment = Experiment.objects.get(id=experiment_id) + + version = experiment.firefox_version + channel = experiment.firefox_channel + experiment_url = make_url(experiment.experiment_url) + + bug_url = settings.BUGZILLA_DETAIL_URL.format(id=experiment.bugzilla_id) + + # XXX Not all experiments have a Project! + project_url = make_url( + reverse("projects-detail", kwargs={"slug": experiment.project.slug}) + ) + + proposed_start_date = experiment.proposed_start_date + proposed_end_date = proposed_start_date + datetime.timedelta( + days=experiment.proposed_duration + ) + # Because that's how it's done in Experiment.population (property) + percent_of_population = f"{experiment.population_percent:g}%" + # XXX https://github.com/mozilla/experimenter/issues/747#issuecomment-468404348 + platforms = "(unknown)" + # XXX https://github.com/mozilla/experimenter/issues/747#issuecomment-468407307 + locales = "(unknown)" + + content = render_to_string( + "my_template.html", + { + "experiment_url": experiment_url, + "bug_url": bug_url, + "project_url": project_url, + "experiment_owner": experiment.owner.email, + "short_description": experiment.short_description, + "version": version, + "channel": channel, + "proposed_start_date": format_date(proposed_start_date), + "proposed_end_date": format_date(proposed_end_date), + "percent_of_population": percent_of_population, + "platforms": platforms, + "locales": locales, + "qa_status": experiment.qa_status, + "feature_bugzilla_url": experiment.feature_bugzilla_url, + "related_work": experiment.related_work, + }, + ).lstrip() + send_mail( + Experiment.INTENT_TO_SHIP_EMAIL_SUBJECT.format( + name=experiment.name, version=version, channel=channel + ), + content, + settings.EMAIL_SENDER, + [settings.EMAIL_REVIEW], + fail_silently=False, + ) diff --git a/app/experimenter/templates/experiments/intent_to_ship.txt b/app/experimenter/templates/experiments/intent_to_ship.txt new file mode 100644 index 0000000000..07aecd3851 --- /dev/null +++ b/app/experimenter/templates/experiments/intent_to_ship.txt @@ -0,0 +1,24 @@ +Hello Release Drivers, + +This request is coming from information entered in Experimenter. +Please reach out to the person(s) on cc: with any questions, details, +or discussion. They will email an update if any of the key information +changes. Otherwise they will reach out once the study has fully passed +QA for Release Management sign-off. + +Experimenter Bug: {{bug_url }} +Experimenter Project: {{ project_url }} +Study owner: {{ experiment_owner }} +Description: {{ short_description }} +Timeline & Channel: {{ version }} {{ channel }} +Intended study dates: {{ proposed_start_date }} - {{ proposed_end_date }} +Percent of Population: {{ percent_of_population }} +Platforms: {{ platforms }} +Locales: {{ locales }} +QA Status: {{ qa_status }} +Meta Bug: {{ feature_bugzilla_url }} +Related links: {{ related_work }} +Risk: {{ Risk Box - only if it exists }} +Technical Complexity: {{ Technical Complexity Box - only if it exists }} + +Thank you!!