diff --git a/cms/models.py b/cms/models.py index 8205f1ea2..82508996c 100644 --- a/cms/models.py +++ b/cms/models.py @@ -90,6 +90,14 @@ from mitxpro.views import get_base_context +class DisableSitemapURLMixin: + """Mixin to Disable sitemap URLs""" + + def get_sitemap_urls(self, request): + """Disable sitemap urls for the page.""" + return [] + + class CanCreatePageMixin: """ Mixin to make sure that only a single page can be created under the home page. @@ -107,7 +115,7 @@ def can_create_at(cls, parent): ) -class CourseObjectIndexPage(Page, CanCreatePageMixin): +class CourseObjectIndexPage(DisableSitemapURLMixin, Page, CanCreatePageMixin): """ A placeholder class to group courseware object pages as children. This class logically acts as no more than a "folder" to organize @@ -147,7 +155,7 @@ def serve(self, request, *args, **kwargs): raise Http404 -class SignatoryObjectIndexPage(Page, CanCreatePageMixin): +class SignatoryObjectIndexPage(DisableSitemapURLMixin, Page, CanCreatePageMixin): """ A placeholder class to group signatory object pages as children. This class logically acts as no more than a "folder" to organize @@ -609,7 +617,7 @@ def get_context(self, request, *args, **kwargs): ) -class CertificateIndexPage(RoutablePageMixin, Page): +class CertificateIndexPage(DisableSitemapURLMixin, RoutablePageMixin, Page): """ Certificate index page placeholder that handles routes for serving certificates given by UUID diff --git a/mitxpro/settings.py b/mitxpro/settings.py index 914218c88..c91e9c112 100644 --- a/mitxpro/settings.py +++ b/mitxpro/settings.py @@ -27,6 +27,7 @@ from mitxpro.celery_utils import OffsettingSchedule from mitxpro.sentry import init_sentry + VERSION = "0.137.1" ENVIRONMENT = get_string( @@ -143,6 +144,7 @@ "django.contrib.staticfiles", "django.contrib.humanize", "django.contrib.sites", + "django.contrib.sitemaps", "django_user_agents", "social_django", "oauth2_provider", diff --git a/mitxpro/urls.py b/mitxpro/urls.py index e6d4ae5c2..a8b04f846 100644 --- a/mitxpro/urls.py +++ b/mitxpro/urls.py @@ -13,30 +13,31 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ -from mitol.common.decorators import cache_control_max_age_jitter - from django.conf import settings from django.conf.urls import include from django.conf.urls.static import static from django.contrib import admin from django.urls import path, re_path from django.views.decorators.cache import cache_control +from mitol.common.decorators import cache_control_max_age_jitter from oauth2_provider.urls import base_urlpatterns +from wagtail import urls as wagtail_urls from wagtail.admin import urls as wagtailadmin_urls +from wagtail.contrib.sitemaps.views import sitemap from wagtail.documents import urls as wagtaildocs_urls -from wagtail import urls as wagtail_urls from wagtail.images.views.serve import ServeView from wagtail.utils.urlpatterns import decorate_urlpatterns from mitxpro.views import ( - index, - restricted, AppContextView, + cms_signin_redirect_to_site_signin, handler404 as not_found_handler, handler500 as server_error_handler, - cms_signin_redirect_to_site_signin, + index, + restricted, ) + WAGTAIL_IMG_CACHE_AGE = 31_536_000 # 1 year @@ -49,6 +50,7 @@ include((base_urlpatterns, "oauth2_provider"), namespace="oauth2_provider"), ), path("hijack/", include("hijack.urls")), + path("sitemap.xml", sitemap), path("", include("authentication.urls")), path("", include("b2b_ecommerce.urls")), path("", include("courses.urls")),