Include last modified date in sitemap

This commit is contained in:
Magnus Hagander
2012-01-14 16:55:53 +01:00
parent ad895a7661
commit 78ab264578
4 changed files with 16 additions and 10 deletions

View File

@ -1,16 +1,20 @@
from datetime import date
from models import DocPage
from django.db import connection
from core.models import Version
def get_struct():
now = date.today()
currentversion = Version.objects.get(current=True)
for d in DocPage.objects.all().extra(where=['version in (select tree from core_version where supported)']):
yield ('docs/%s/static/%s' % (d.version, d.file),
None)
# Can't use a model here, because we don't (for some reason) have a
# hard link to the versions table here
curs = connection.cursor()
curs.execute("SELECT d.version, d.file, v.docsloaded FROM docs d INNER JOIN core_version v ON v.tree=d.version WHERE v.supported")
for version, filename, loaded in curs.fetchall():
yield ('docs/%s/static/%s' % (version, filename),
None, loaded)
#FIXME ^ do something smart with priorities on older
#versions
if d.version == currentversion.tree:
yield ('docs/current/static/%s' % d.file,
1.0)
if version == currentversion.tree:
yield ('docs/current/static/%s' % filename,
1.0, loaded)