Skip to content

Commit

Permalink
feat: add sitemap (#2870)
Browse files Browse the repository at this point in the history
* feat: add sitemap and update zendesk verification tags

Adds sitemap and both Production and Sanbox tags if available.

* update app json

* update setting description

* remove duplicate sandbox zendesk crawler tag
  • Loading branch information
asadali145 committed Jan 22, 2024
1 parent 8373791 commit c33dd66
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
14 changes: 11 additions & 3 deletions cms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions mitxpro/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from mitxpro.celery_utils import OffsettingSchedule
from mitxpro.sentry import init_sentry


VERSION = "0.137.1"

ENVIRONMENT = get_string(
Expand Down Expand Up @@ -143,6 +144,7 @@
"django.contrib.staticfiles",
"django.contrib.humanize",
"django.contrib.sites",
"django.contrib.sitemaps",
"django_user_agents",
"social_django",
"oauth2_provider",
Expand Down
14 changes: 8 additions & 6 deletions mitxpro/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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")),
Expand Down

0 comments on commit c33dd66

Please sign in to comment.