Skip to content

Commit

Permalink
Add email for business projects and new dashboard change (#11809)
Browse files Browse the repository at this point in the history
This might not be how we've sent some of the last emails, but hte copy
should be reusable.

- Fixes readthedocs/meta#163
  • Loading branch information
agjohnson authored Dec 3, 2024
1 parent bfae64f commit 57e3523
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 0 deletions.
61 changes: 61 additions & 0 deletions readthedocs/projects/notifications.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,77 @@
"""Notifications related to projects."""
import textwrap

from django.contrib.auth.models import User
from django.db.models import Count
from django.utils import timezone
from django.utils.translation import gettext_noop as _

from readthedocs.core.permissions import AdminPermission
from readthedocs.notifications.constants import ERROR, INFO, WARNING
from readthedocs.notifications.email import EmailNotification
from readthedocs.notifications.messages import Message, registry
from readthedocs.projects.exceptions import (
ProjectConfigurationError,
RepositoryError,
SyncRepositoryLocked,
UserFileNotFound,
)
from readthedocs.projects.models import Project


class NewDashboardNotification(EmailNotification):

"""
Notification about new dashboard rollout and changes for Business users.
To send:
for user in NewDashboardNotification.for_admins():
notify = NewDashboardNotificaiton(user, user)
notify.send()
NOTE: This can be removed with RTD_EXT_THEME_ENABLED.
"""

app_templates = "projects"
name = "new_dashboard"
subject = "Upcoming changes to our dashboard"

@staticmethod
def for_projects():
# Only send to admin users of recently built projects
projects = (
Project.objects.filter(builds__date__gte=timezone.datetime(2023, 1, 1))
.annotate(successful_builds=Count("builds__success"))
.filter(successful_builds__gte=3)
.distinct()
.order_by("slug")
)

# Filter out projects that are spam. This is conditional as this module
# doesn't seem available in our tests.
try:
from readthedocsext.spamfighting.utils import spam_score

projects = filter(lambda p: spam_score(p) < 200, projects)

# Convert back to queryset
return Project.objects.filter(slug__in=[p.slug for p in projects])
except ImportError:
return projects

@staticmethod
def for_admins(projects=None):
if projects is None:
projects = NewDashboardNotification.for_projects()
usernames = set()
for project in projects:
usernames.update(
set(AdminPermission.admins(project).values_list("username", flat=True))
)

return User.objects.filter(username__in=usernames)


MESSAGE_PROJECT_SKIP_BUILDS = "project:invalid:skip-builds"
MESSAGE_PROJECT_ADDONS_BY_DEFAULT = "project:addons:by-default"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% extends "core/email/common.html" %}
{% block content %}
<p>
Earlier this month we began the last phase of a project to retire our
original user interface and replace it with a completely new dashboard.
</p>
<p>
Documentation hosted on <a href="https://readthedocs.com">Read the Docs Business</a>
will display this new dashboard in several places where documentation
readers interact with our application: documentation authentication and our
default documentation error pages.
</p>
<p>
Below is a summary of what is changing, however we cover what will be
changing and when to expect these changes in more detail on our website:
</p>
<p>
<a href="https://about.readthedocs.com/blog/2024/11/rollout-of-our-new-dashboard/">
Rollout of our new dashboard
</a>
</p>

<hr />

<p>
On <strong>Dec 10th</strong> we will make our new dashboard the default
dashboard for users logging into <a href="https://readthedocs.com">Read the Docs Business</a>
from our website. This change will mainly affect project maintainers,
especially maintainers that have not yet switched to the new dashboard.
</p>
<p>
At this same time, we will also begin using the new dashboard for
documentation authentication and documentation error pages. Documentation
readers will notice the new dashboard as they log in to view private
documentation and might notice updated error pages if they encounter an
HTTP error.
</p>
<p>
<em>There will be no changes to user generated documentation
otherwise.</em>
</p>
<p>
Projects can update to use these new pages in their documentation at
any point. If you would like to update your project to use these pages
before then, <a href="https://app.readthedocs.com/support">contact us</a>.
</p>
{% endblock content %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{% extends "core/email/common.txt" %}
{% block content %}
Earlier this month we began the last phase of a project to retire our
original user interface and replace it with a completely new dashboard.

Documentation hosted on Read the Docs Business will display this new dashboard
in several places where documentation readers interact with our application:
documentation authentication and our default documentation error pages.

Below is a summary of what is changing, however we cover what will be
changing and when to expect these changes in more detail on our website:

Rollout of our new dashboard
https://about.readthedocs.com/blog/2024/11/rollout-of-our-new-dashboard/

----

On *Dec 10th* we will make our new dashboard the default dashboard for
users logging into Read the Docs Business from our website.
This change will mainly affect project maintainers,
especially maintainers that have not yet switched to the new dashboard.

At this same time, we will also begin using the new dashboard for
documentation authentication and documentation error pages.
Documentation readers will notice the new dashboard as they log in to
view private documentation and might notice updated error pages if they
encounter an HTTP error.

*There will be no changes to user generated documentation otherwise.*

Projects can update to use these new pages in their documentation at any
point. If you would like to update your project to use these pages
before then, contact us:

https://app.readthedocs.com/support

{% endblock content %}

0 comments on commit 57e3523

Please sign in to comment.