diff --git a/readthedocs/core/views/__init__.py b/readthedocs/core/views/__init__.py index b53533c83e1..d64f1c8b536 100644 --- a/readthedocs/core/views/__init__.py +++ b/readthedocs/core/views/__init__.py @@ -13,7 +13,6 @@ from django.views.generic import TemplateView, View from readthedocs.core.mixins import CDNCacheControlMixin, PrivateViewMixin -from readthedocs.projects.models import Project log = structlog.get_logger(__name__) @@ -45,15 +44,26 @@ class HomepageView(TemplateView): template_name = 'homepage.html' def get(self, request, *args, **kwargs): + # Redirect to login page for new dashboard if settings.RTD_EXT_THEME_ENABLED: return redirect(reverse("account_login")) - return super().get(request, *args, **kwargs) - def get_context_data(self, **kwargs): - """Add latest builds and featured projects.""" - context = super().get_context_data(**kwargs) - context['featured_list'] = Project.objects.filter(featured=True) - return context + # Redirect to user dashboard for logged in users + if request.user.is_authenticated: + return redirect("projects_dashboard") + + # Redirect to ``about.`` in production + if not settings.DEBUG: + query_string = "?ref=dotorg-homepage" + if request.META["QUERY_STRING"]: + # Small hack to not append `&` to URLs without a query_string + query_string += "&" + request.META["QUERY_STRING"] + return redirect( + f"https://about.readthedocs.com{query_string}", permanent=False + ) + + # Show the homepage for local dev + return super().get(request, *args, **kwargs) class SupportView(PrivateViewMixin, TemplateView): diff --git a/readthedocs/rtd_tests/tests/test_privacy.py b/readthedocs/rtd_tests/tests/test_privacy.py index ce88f6b7393..2ac4f2958e2 100644 --- a/readthedocs/rtd_tests/tests/test_privacy.py +++ b/readthedocs/rtd_tests/tests/test_privacy.py @@ -70,7 +70,7 @@ def _create_kong( def test_private_repo(self): """Check that private projects don't show up in: builds, downloads, - detail, homepage + detail """ self._create_kong('private', 'private') @@ -88,8 +88,6 @@ def test_private_repo(self): self.assertEqual(r.status_code, 200) self.client.login(username='tester', password='test') - r = self.client.get('/') - self.assertNotContains(r, 'Django Kong') r = self.client.get('/projects/django-kong/') self.assertEqual(r.status_code, 404) r = self.client.get('/projects/django-kong/builds/') diff --git a/readthedocs/rtd_tests/tests/test_views.py b/readthedocs/rtd_tests/tests/test_views.py index 3a4980562a9..e6f7a248951 100644 --- a/readthedocs/rtd_tests/tests/test_views.py +++ b/readthedocs/rtd_tests/tests/test_views.py @@ -3,7 +3,6 @@ from urllib.parse import urlsplit from django.contrib.auth.models import User -from django.core.cache import cache from django.test import TestCase, override_settings from django.urls import reverse from django.utils import timezone @@ -437,22 +436,3 @@ def test_generated_csv_data(self): self.assertEqual(body[0][0], 'Created Date') self.assertEqual(body[1][1], 'advertising') self.assertEqual(body[-1][1], 'hello world') - - -class TestHomepageCache(TestCase): - - def setUp(self): - cache.clear() - - def tearDown(self): - cache.clear() - - def test_homepage_queries(self): - with self.assertNumQueries(1): - r = self.client.get('/') - self.assertEqual(r.status_code, 200) - - # Cache - with self.assertNumQueries(0): - r = self.client.get('/') - self.assertEqual(r.status_code, 200) diff --git a/readthedocs/templates/core/project_list_featured.html b/readthedocs/templates/core/project_list_featured.html deleted file mode 100644 index 8d10d28c9e8..00000000000 --- a/readthedocs/templates/core/project_list_featured.html +++ /dev/null @@ -1,24 +0,0 @@ -{% load i18n %} - -{% for project in featured_list %} -
  • - {{ project.name }} - {% for user in project.users.all %} - ({{ user }}) - {% endfor %} - - - -
  • - -{% empty %} -
  • {% trans "No projects found" %}
  • -{% endfor %} diff --git a/readthedocs/templates/homepage.html b/readthedocs/templates/homepage.html index 7832c09bdbb..e8304b80a85 100644 --- a/readthedocs/templates/homepage.html +++ b/readthedocs/templates/homepage.html @@ -116,24 +116,6 @@

    {% trans "Multiple versions" %}

    {% include "core/widesearchbar.html" with form_action=search_form_action %} - {% get_current_language as language %} - {% cache 600 homepage_featured_list language %} - {% if featured_list %} - -
    -

    {% trans "Featured Projects" %}

    -
    -
    -
      - {% include "core/project_list_featured.html" %} -
    -
    -
    -
    - - {% endif %} - {% endcache %} -

    {% trans 'About Read the Docs' %}