|
40 | 40 | from readthedocs.core.history import UpdateChangeReasonPostView
|
41 | 41 | from readthedocs.core.mixins import ListViewWithForm, PrivateViewMixin
|
42 | 42 | from readthedocs.core.notifications import MESSAGE_EMAIL_VALIDATION_PENDING
|
| 43 | +from readthedocs.core.permissions import AdminPermission |
43 | 44 | from readthedocs.integrations.models import HttpExchange, Integration
|
44 | 45 | from readthedocs.invitations.models import Invitation
|
45 | 46 | from readthedocs.notifications.models import Notification
|
@@ -113,6 +114,25 @@ def get_context_data(self, **kwargs):
|
113 | 114 | # Alternatively, dynamically override super()-derived `project_list` context_data
|
114 | 115 | # context[self.get_context_object_name(filter.qs)] = filter.qs
|
115 | 116 |
|
| 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 | + |
116 | 136 | return context
|
117 | 137 |
|
118 | 138 | def validate_primary_email(self, user):
|
|
0 commit comments