Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sitemap: If older version of standard, want it to have lower priority. #781

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion iati_standard/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Model definitions for the iati_standard app."""

import os
import re
from bs4 import BeautifulSoup
from datetime import datetime

Expand Down Expand Up @@ -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."""
Expand Down
Loading