diff --git a/bedrock/sitemaps/migrations/0002_remove_sitemapurl_lastmod.py b/bedrock/sitemaps/migrations/0002_remove_sitemapurl_lastmod.py new file mode 100644 index 00000000000..48f49c3148f --- /dev/null +++ b/bedrock/sitemaps/migrations/0002_remove_sitemapurl_lastmod.py @@ -0,0 +1,20 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. + +# Generated by Django 4.2.16 on 2024-09-27 17:51 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("sitemaps", "0001_initial"), + ] + + operations = [ + migrations.RemoveField( + model_name="sitemapurl", + name="lastmod", + ), + ] diff --git a/bedrock/sitemaps/models.py b/bedrock/sitemaps/models.py index 753ffd5a7bb..134e93f33d0 100644 --- a/bedrock/sitemaps/models.py +++ b/bedrock/sitemaps/models.py @@ -12,33 +12,21 @@ def load_sitemaps_data(): - with SITEMAPS_DATA.joinpath("etags.json").open() as fh: - etags = json.load(fh) - with SITEMAPS_DATA.joinpath("sitemap.json").open() as fh: sitemap = json.load(fh) - return sitemap, etags + return sitemap def get_sitemap_objs(): objs = [] - sitemap, etags = load_sitemaps_data() + sitemap = load_sitemaps_data() for url, locales in sitemap.items(): if not locales: locales = [NO_LOCALE] for locale in locales: - if locale == NO_LOCALE: - full_url = f"{settings.CANONICAL_URL}{url}" - else: - full_url = f"{settings.CANONICAL_URL}/{locale}{url}" - - kwargs = {"path": url, "locale": locale} - etag = etags.get(full_url) - if etag: - kwargs["lastmod"] = etag["date"] - objs.append(SitemapURL(**kwargs)) + objs.append(SitemapURL(path=url, locale=locale)) return objs @@ -59,7 +47,6 @@ def all_locales(self): class SitemapURL(models.Model): path = models.CharField(max_length=200) locale = models.CharField(max_length=5) - lastmod = models.CharField(max_length=40, blank=True) objects = SitemapURLManager() diff --git a/bedrock/sitemaps/tests/test_views.py b/bedrock/sitemaps/tests/test_views.py index 1f65a82d50f..836cc50c79d 100644 --- a/bedrock/sitemaps/tests/test_views.py +++ b/bedrock/sitemaps/tests/test_views.py @@ -11,14 +11,14 @@ class TestSitemapView(TestCase): def setUp(self): data = [ - {"path": "/firefox/all/", "locale": "de", "lastmod": "2020-07-01T21:07:08.730133+00:00"}, - {"path": "/firefox/", "locale": "de", "lastmod": "2020-07-01T21:07:08.730133+00:00"}, + {"path": "/firefox/all/", "locale": "de"}, + {"path": "/firefox/", "locale": "de"}, { "path": "/privacy/", "locale": "fr", }, - {"path": "/firefox/", "locale": "fr", "lastmod": "2020-07-01T21:07:08.730133+00:00"}, - {"path": "/keymaster/gatekeeper/there.is.only.xul", "locale": NO_LOCALE, "lastmod": "2020-07-01T21:07:08.730133+00:00"}, + {"path": "/firefox/", "locale": "fr"}, + {"path": "/keymaster/gatekeeper/there.is.only.xul", "locale": NO_LOCALE}, { "path": "/locales/", "locale": NO_LOCALE, @@ -52,7 +52,6 @@ def test_none(self): https://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul - 2020-07-01T21:07:08.730133+00:00 https://www.mozilla.org/locales/ @@ -69,11 +68,9 @@ def test_locales(self): https://www.mozilla.org/de/firefox/ - 2020-07-01T21:07:08.730133+00:00 https://www.mozilla.org/de/firefox/all/ - 2020-07-01T21:07:08.730133+00:00 """ ) @@ -86,7 +83,6 @@ def test_locales(self): https://www.mozilla.org/fr/firefox/ - 2020-07-01T21:07:08.730133+00:00 https://www.mozilla.org/fr/privacy/