Skip to content

Commit

Permalink
Dashboard: promote "security logs" only if organization owner (#11304)
Browse files Browse the repository at this point in the history
The default promotion was "Security logs", but it's not the most important one.
This commit shows it only if there is no other one to show and the user is the
owner of the organization.
  • Loading branch information
humitos committed Apr 25, 2024
1 parent dea3487 commit 550e774
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions readthedocs/projects/views/private.py
Expand Up @@ -114,9 +114,9 @@ def get_context_data(self, **kwargs):
# Alternatively, dynamically override super()-derived `project_list` context_data
# context[self.get_context_object_name(filter.qs)] = filter.qs

template_name = None
projects = AdminPermission.projects(user=self.request.user, admin=True)
n_projects = projects.count()
template_name = "security-logs.html"
if n_projects < 3 and (timezone.now() - projects.first().pub_date).days < 7:
template_name = "example-projects.html"
elif (
Expand All @@ -129,8 +129,14 @@ def get_context_data(self, **kwargs):
and not projects.filter(addons__analytics_enabled=True).exists()
):
template_name = "traffic-analytics.html"

context["promotion"] = f"projects/partials/dashboard/{template_name}"
elif AdminPermission.organizations(
user=self.request.user,
owner=True,
).exists():
template_name = "security-logs.html"

if template_name:
context["promotion"] = f"projects/partials/dashboard/{template_name}"

return context

Expand Down

0 comments on commit 550e774

Please sign in to comment.