From 28a16bcf722ad7cfdb0a2697450a0c7b8a936d4d Mon Sep 17 00:00:00 2001 From: James B Date: Fri, 25 Oct 2024 15:30:19 +0100 Subject: [PATCH] sitemap: If older version of standard, want it to have lower priority. --- iati_standard/models.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/iati_standard/models.py b/iati_standard/models.py index 1d13e9c0..8d2f5fb6 100644 --- a/iati_standard/models.py +++ b/iati_standard/models.py @@ -1,6 +1,7 @@ """Model definitions for the iati_standard app.""" import os +import re from bs4 import BeautifulSoup from datetime import datetime @@ -397,10 +398,34 @@ def save(self, *args, **kwargs): class ActivityStandardPage(AbstractGithubPage): - """A model for the Activity Standard Page, an IATI reference page.""" + """A model for the Activity Standard Page, an IATI reference page. + + Used for Standard reference pages like /en/iati-standard/202/ + And guidance developer pages like /en/guidance/developer/ + """ template = 'iati_standard/activity_standard_page.html' + def get_sitemap_urls(self, request=None): + """If it's an older version of the standard, we want it to have a lower priority.""" + url = self.get_url(request) + if re.match(r"^\/\w+\/iati-standard\/", url) and not re.match(r"^\/\w+\/iati-standard\/203\/", url): + return [ + { + 'location': self.get_full_url(request), + 'lastmod': (self.last_published_at or self.latest_revision_created_at), + 'changefreq': 'yearly', + 'priority': .1, + } + ] + else: + return [ + { + 'location': self.get_full_url(request), + 'lastmod': (self.last_published_at or self.latest_revision_created_at), + } + ] + class StandardGuidancePage(AbstractGithubPage): """A model for the Standard Guidance Page, an IATI reference page."""