Skip to content

Commit 3912b7d

Browse files
authored
Dashboard: promote features in the right bar (#11287)
* Dashboard: promote features in the right bar Small logic to decide which feature to promote. This is pretty simple for now, but it shows the pattern we are thinking about. Required by readthedocs/ext-theme#103 * Improve logic from feedback * Move partials to a better place * Updates from feedback
1 parent fb90a34 commit 3912b7d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

readthedocs/projects/views/private.py

+20
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from readthedocs.core.history import UpdateChangeReasonPostView
4141
from readthedocs.core.mixins import ListViewWithForm, PrivateViewMixin
4242
from readthedocs.core.notifications import MESSAGE_EMAIL_VALIDATION_PENDING
43+
from readthedocs.core.permissions import AdminPermission
4344
from readthedocs.integrations.models import HttpExchange, Integration
4445
from readthedocs.invitations.models import Invitation
4546
from readthedocs.notifications.models import Notification
@@ -113,6 +114,25 @@ def get_context_data(self, **kwargs):
113114
# Alternatively, dynamically override super()-derived `project_list` context_data
114115
# context[self.get_context_object_name(filter.qs)] = filter.qs
115116

117+
projects = AdminPermission.projects(user=self.request.user, admin=True)
118+
n_projects = projects.count()
119+
if n_projects < 3 and (timezone.now() - projects.first().pub_date).days < 7:
120+
template_name = "example-projects.html"
121+
elif (
122+
n_projects
123+
and not projects.filter(external_builds_enabled=True).exists()
124+
):
125+
template_name = "pull-request-previews.html"
126+
elif (
127+
n_projects
128+
and not projects.filter(addons__analytics_enabled=True).exists()
129+
):
130+
template_name = "traffic-analytics.html"
131+
else:
132+
context["promotion"] = "security-logs.html"
133+
134+
context["promotion"] = f"projects/partials/dashboard/{template_name}"
135+
116136
return context
117137

118138
def validate_primary_email(self, user):

0 commit comments

Comments
 (0)